McMuffinTop Posted October 28, 2019 Share Posted October 28, 2019 (edited) expandcollapse popup#Region INCLUDE #include <AVIConstants.au3> #include <ColorConstants.au3> #include <Excel.au3> #include <File.au3> #include <FileConstants.au3> #include <FontConstants.au3> #Include <GuiButton.au3> #include <GuiConstants.au3> #include <GuiConstantsEx.au3> #include <MsgBoxConstants.au3> #include <TreeViewConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <WinAPIShellEx.au3> #EndRegion INCLUDE #Region FileWrite $File = FileOpen("C:\Windows\Temp\UserPreferenceFile.txt", 10) Local $sChromeFilePath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Google\Update\Clients\{8A69D345-D564-463c-AFF1-A69D9E530F96}", "pv") If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Else FileWrite($file, "USERNAME: " & @UserName & @CRLF) FileWrite($file, "CHROMEVERSION: " & $sChromeFilePath & @CRLF) FileClose($file) EndIf #EndRegion FileWrite #Region FileWriteToLineThenRead Example() Func Example() ; Create a constant variable in Local scope of the filepath that will be read/written to. Local Const $sFilePath = "C:\Windows\Temp\UserPreferenceFile.txt" ; Create data to be written to the file. Local $sData = "Line 1: This is an example of using _FileWriteToLine()" & @CRLF ;"Line 2: This is an example of using _FileWriteToLine()" & @CRLF ; Create a temporary file to read data from. If Not FileWrite($sFilePath, $sData) Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.") Return False EndIf ; Write to line 3 with overwriting set to true. _FileWriteToLine($sFilePath, 3, "Line 3: THIS HAS BEEN REPLACED", True) ; Read the contents of the file using the filepath. Local $sFileRead = FileRead($sFilePath) ; Display the contents of the file. MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & $sFileRead) EndFunc ;==>Example #EndRegion FileWriteToLineThenRead #Region Main GUI $hGUI = GUICreate("QA Analyst Tool", 365, 505) GUICtrlSetBkColor(-1, 0x808080) GUISetIcon("..\..\Pictures\MOT.ico", 0) GUISetFont(9) $cTab = GUICtrlCreateTab(10, 10, 345, 400) $cTab = GUICtrlSetBkColor(-1, 0xC0C0C0) #EndRegion Main GUI #Region Selenium $cTab_1 = GUICtrlCreateTabItem("Selenium") $cTab_1 = GUICtrlCreateList("BROWSER VERSIONS", 15, 300, 330, 115) GUICtrlSetTip(-1, "Browser versions found on this machine") $cTab_1 = GUICtrlSetBkColor(-1, 0xC0C0C0) Local $sFilePath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Google\Update\Clients\{8A69D345-D564-463c-AFF1-A69D9E530F96}", "pv") GUICtrlSetData(-1, "Chrome: " & $sFilePath) Local $sFireFilePath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\mozilla.org\Mozilla", "CurrentVersion") GUICtrlSetData(-1, "Firefox: " & $sFireFilePath) $sEdgeFilePath = "FileVersion" Local $sStringValue = FileGetVersion("C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe", $sEdgeFilePath) GUICtrlSetData(-1, "Edge: " & $sStringValue) $SeleniumTestButton = GUICtrlCreateButton("Run Selenium Tests", 100, 75, 150, 35) GUICtrlSetColor($SeleniumTestButton, 0x0000ff) GUICtrlSetTip(-1, "Run tests specified in your local wdio file") $ReportResultsButton = GUICtrlCreateButton("Open Spreadsheet to Report Results", 70, 150, 220, 35) GUICtrlSetColor($ReportResultsButton, 0x0000ff) GUICtrlSetTip(-1, "Launch the Selenium Test Health spreadsheet in Z:\QA") $UpdateChromeDriverButton = GUICtrlCreateButton("Update Chrome Driver", 70, 225, 220, 35) GUICtrlSetColor($UpdateChromeDriverButton, 0x0000ff) GUICtrlSetTip(-1, "Find the matching Chrome driver, then download and extract to:" & @CR & "C:\Automation\opie-anywhere-tests\OAFramework\node_modules\chromedriver\lib\chromedriver") #EndRegion Selenium #Region OPIE Anywhere $cTab_2 = GUICtrlCreateTabItem("OPIE Anywhere") GUIStartGroup() $hRadio_QAUS = GUICtrlCreateRadio("QA-US", 35, 50, 100, 35) $hRadio_QAINTL = GUICtrlCreateRadio("QA-INTL", 35, 90, 100, 35) $hRadio_STAGING = GUICtrlCreateRadio("Staging", 35, 130, 100, 35) GUIStartGroup() $hRadio_CHROME = GUICtrlCreateRadio("Chrome", 200, 50, 100, 35) $hRadio_Edge = GUICtrlCreateRadio("Edge", 200, 90, 100, 35) $hRadio_Firefox = GUICtrlCreateRadio("Firefox", 200, 130, 100, 35) $LogInButton = GUICtrlCreateButton("Log In", 20, 210, 320, 35) GUICtrlSetTip(-1, "Launch OPIE Anywhere based on your database and browser selections") GUICtrlSetColor($LogInButton, 0x0000ff) GUIStartGroup() $hGroup_SERVER = GUICtrlCreateGroup("Database", 25, 35, 150, 140) $hGroup_BROWSER = GUICtrlCreateGroup("Browser", 190, 35, 145, 140) GUICtrlSetState($hRadio_QAUS, $GUI_CHECKED) GUICtrlSetState($hRadio_CHROME, $GUI_CHECKED) #EndRegion OPIE Anywhere #Region OPIE Suite $cTab_3 = GUICtrlCreateTabItem("OPIE Suite") $cTab_3 = GUICtrlCreateList("", 20, 40, 320, 105) GUICtrlSetTip(-1, "Versions of the OPIE Suite products installed on this machine") $sOPIEStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\OPIE.exe", $sOPIEStringName) GUICtrlSetData(-1, "OPIE PM version is: " & $sStringValue) $sBillingStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\OPIEBilling\OPIEBilling.exe", $sBillingStringName) GUICtrlSetData(-1, "Billing version is: " & $sStringValue) $sSchedulerStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\SchedulerV3\OpieSchedulerV3.exe", $sSchedulerStringName) GUICtrlSetData(-1, "Scheduler version is: " & $sStringValue) $sReportsStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\OPIEReports\OpieReporting.exe", $sReportsStringName) GUICtrlSetData(-1, "Reports version is: " & $sStringValue) $sSentryStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\OPIESentry.exe", $sSentryStringName) GUICtrlSetData(-1, "Sentry version is: " & $sStringValue) $sWardenStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\Warden\OPIE.Warden.exe", $sWardenStringName) GUICtrlSetData(-1, "Warden version is: " & $sStringValue) $cTab_3 = GUICtrlCreateList("", 20, 145, 320, 165) GUICtrlSetTip(-1, "Versions of the OPIE Suite helper files installed on this machine") $sSentryConsoleStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\SentryConsole.exe", $sSentryConsoleStringName) GUICtrlSetData(-1, "Sentry Console version is: " & $sStringValue) $sOPIEBridgeStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\OPIE_Bridge.exe", $sOPIEBridgeStringName) GUICtrlSetData(-1, "Bridge version is: " & $sStringValue) $sOPIELibsStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\OPIE.Library.Interop.dll", $sOPIELibsStringName) GUICtrlSetData(-1, "InteropLibs.DLL version is: " & $sStringValue) $sOPIEMaintenanceStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\OPIEMaintenance.exe", $sOPIEMaintenanceStringName) GUICtrlSetData(-1, "OPIE Maintenance version is: " & $sStringValue) $sOPIEMercuryStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\OPIEMercury.exe", $sOPIEMercuryStringName) GUICtrlSetData(-1, "OPIE Mercury version is: " & $sStringValue) $sFileWatcherStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\OPIE.Library.FileCreationWatcher.dll", $sFileWatcherStringName) GUICtrlSetData(-1, "File Creation Watcher version is: " & $sStringValue) $sReportHelperStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\ReportHelper\ReportHelperHost.exe", $sReportHelperStringName) GUICtrlSetData(-1, "Report Helper version is: " & $sStringValue) $sHl7StringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\HL7Importer\HL7Importer.exe", $sHl7StringName) GUICtrlSetData(-1, "HL7 version is: " & $sStringValue) $sDirectScanStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\DirectScan.exe", $sDirectScanStringName) GUICtrlSetData(-1, "Direct Scan version is: " & $sStringValue) $sLCodeStringName = "FileVersion" Local $sStringValue = FileGetVersion("D:\OPIE\LCodeExplorer\LCodeExplorer.exe", $sLCodeStringName) GUICtrlSetData(-1, "LCode Explorer version is: " & $sStringValue) $cTab_3 = GUICtrlCreateTabItem("OPIE Services") $cTab_4 = GUICtrlCreateList("", 20, 60, 320, 55) If ProcessExists("OPIE.Warden.exe") Then GUICtrlSetData(-1, "Warden is running") GUICtrlSetBkColor(-1, 0x00FF00) Else GUICtrlSetData(-1, "Warden is not running") GUICtrlSetBkColor(-1, 0xFF0000) EndIf $StartWardenButton = GUICtrlCreateButton("Start Warden", 20, 105, 150, 35) GUICtrlSetColor($StartWardenButton, 0x008000) GUICtrlSetTip(-1, "Starts the Warden service on this machine, if installed") $StopWardenButton = GUICtrlCreateButton("Stop Warden", 190, 105, 150, 35) GUICtrlSetColor($StopWardenButton, 0xFF0000) GUICtrlSetTip(-1, "Stops the Warden service on this machine, if installed") $cTab_4 = GUICtrlCreateList("", 20, 155, 320, 55) If ProcessExists("OPIESentry.exe") Then GUICtrlSetData(-1, "Sentry is running") GUICtrlSetBkColor(-1, 0x00FF00) Else GUICtrlSetData(-1, "Sentry is not running") GUICtrlSetBkColor(-1, 0xFF0000) EndIf $StartSentryButton = GUICtrlCreateButton("Start Sentry", 20, 205, 150, 35) GUICtrlSetColor($StartSentryButton, 0x008000) GUICtrlSetTip(-1, "Starts the Sentry service on this machine, if installed") $StopSentryButton = GUICtrlCreateButton("Stop Sentry", 190, 205, 150, 35) GUICtrlSetColor($StopSentryButton, 0xFF0000) GUICtrlSetTip(-1, "Stops the Sentry service on this machine, if installed") GUISetState() #EndRegion OPIE Suite #Region BUTTON MAGIC $B_oIE1 = ObjCreate("Shell.Explorer.2") $Breaktime = GUICtrlCreateObj($B_oIE1, 600, 480, 535, 100) $html = "about:" & @CR $BrkEnd = GUICtrlCreateButton("&Exit", 90, 440, 180, 35) GUICtrlSetTip(-1, "Close the Analyst Tool") GUISetState() #EndRegion BUTTON MAGIC While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Or $msg = $BrkEnd Then Exit EndIf If $msg = $StartWardenButton Then Run("cmd.exe") WinWaitActive("Administrator: C:\Windows\system32\cmd.exe", "", 5) Send("cd c:\") Send("{ENTER}") Send("net start OPIE.Warden") Send("{ENTER}") EndIf If $msg = $StopWardenButton Then Run("cmd.exe") WinWaitActive("Administrator: C:\Windows\system32\cmd.exe", "", 5) Send("cd c:\") Send("{ENTER}") Send("net stop OPIE.Warden") Send("{ENTER}") EndIf If $msg = $StartSentryButton Then Run("cmd.exe") WinWaitActive("Administrator: C:\Windows\system32\cmd.exe", "", 5) Send("cd c:\") Send("{ENTER}") Send("net start OPIESentry") Send("{ENTER}") EndIf If $msg = $StopSentryButton Then Run("cmd.exe") WinWaitActive("Administrator: C:\Windows\system32\cmd.exe", "", 5) Send("cd c:\") Send("{ENTER}") Send("net stop OPIESentry") Send("{ENTER}") EndIf If $msg = $SeleniumTestButton Then Run("cmd.exe") WinWaitActive("Administrator: C:\Windows\system32\cmd.exe", "", 5) Send("cd c:\AUTOMATION") Send("{ENTER}") Send("cd opie-anywhere-tests\OAframework") Send("{ENTER}") Send("node_modules\.bin\wdio wdio.conf.js 1> test_results.txt") Send("{ENTER}") EndIf If $msg = $ReportResultsButton Then Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, "Z:\QA\Selenium Test Health.xlsx", True, True, "", "") Local $Message Select Case @error = 2 $Message = "File does not exist" Case @error = 3 $Message = "Unable to open File" EndSelect If @error then MsgBox(65,"Problems with File",$Message) EndIf EndIf If $msg = $LogInButton Then ShellExecute("browser", "my url --new-window --start-fullscreen") EndIf If $msg = $UpdateChromeDriverButton Then ShellExecute("chrome.exe", "https://sites.google.com/a/chromium.org/chromedriver/downloads --new-window --start-fullscreen") EndIf WEnd #Region GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() #EndRegion First time poster, and new to the community, so I'll ask my question and hope that i posted it correctly and accurately. I have been working with the help topic 'radio buttons' and 'radio groups', and have run into a problem that i cannot solve, so any help is greatly appreciated. I created a GUI with multiple tabs for gathering data and logging into servers, and on this particular tab i have two groups of buttons. One group consists of online databases to log into, the second group consists of the local browsers that are installed to connect with. When i select the 'Log In' button, i would like it to respect the radio buttons selected. Can anyone assist and thank you in advance. Tab code: $cTab_2 = GUICtrlCreateTabItem("OA") GUIStartGroup() $hRadio_QAUS = GUICtrlCreateRadio("US", 35, 50, 100, 35) $hRadio_QAINTL = GUICtrlCreateRadio("INTL", 35, 90, 100, 35) $hRadio_STAGING = GUICtrlCreateRadio("Staging", 35, 130, 100, 35) GUIStartGroup() $hRadio_CHROME = GUICtrlCreateRadio("Chrome", 200, 50, 100, 35) $hRadio_Edge = GUICtrlCreateRadio("Edge", 200, 90, 100, 35) $hRadio_Firefox = GUICtrlCreateRadio("Firefox", 200, 130, 100, 35) $LogInButton = GUICtrlCreateButton("Log In", 20, 210, 320, 35) GUICtrlSetColor($LogInButton, 0x0000ff) GUIStartGroup() $hGroup_SERVER = GUICtrlCreateGroup("Database", 25, 35, 150, 140) $hGroup_BROWSER = GUICtrlCreateGroup("Browser", 190, 35, 145, 140) GUICtrlSetState($hRadio_US, $GUI_CHECKED) GUICtrlSetState($hRadio_CHROME, $GUI_CHECKED) At the end of the script, i have this button 'logic' (which is not logical yet, it's basically hard-coded): While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Or $msg = $BrkEnd Then Exit EndIf If $msg = $LogInButton Then ShellExecute("browser", "myurl" --new-window --start-fullscreen") EndIf WEnd GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() Edited October 28, 2019 by McMuffinTop Link to comment Share on other sites More sharing options...
Nine Posted October 28, 2019 Share Posted October 28, 2019 (edited) When you post code please use this tool. Also it makes our life easier if you could provide a runnable script that we could use to advise you. Not like you did with a part of a larger script that we need to modify if we want to test it. In your particular case, you can read the radio button with GUICtrlRead and execute the proper .exe with the requested parameters. Edited October 28, 2019 by Nine FrancescoDiMuro and McMuffinTop 1 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Zedna Posted October 28, 2019 Share Posted October 28, 2019 expandcollapse popup#include <GUIConstantsEx.au3> $gui = GUICreate("Test", 400,300) $cTab_2 = GUICtrlCreateTabItem("OA") GUIStartGroup() $hRadio_QAUS = GUICtrlCreateRadio("US", 35, 50, 100, 35) $hRadio_QAINTL = GUICtrlCreateRadio("INTL", 35, 90, 100, 35) $hRadio_STAGING = GUICtrlCreateRadio("Staging", 35, 130, 100, 35) GUIStartGroup() $hRadio_CHROME = GUICtrlCreateRadio("Chrome", 200, 50, 100, 35) $hRadio_Edge = GUICtrlCreateRadio("Edge", 200, 90, 100, 35) $hRadio_Firefox = GUICtrlCreateRadio("Firefox", 200, 130, 100, 35) $LogInButton = GUICtrlCreateButton("Log In", 20, 210, 320, 35) GUICtrlSetColor($LogInButton, 0x0000ff) GUIStartGroup() $hGroup_SERVER = GUICtrlCreateGroup("Database", 25, 35, 150, 140) $hGroup_BROWSER = GUICtrlCreateGroup("Browser", 190, 35, 145, 140) GUICtrlSetState($hRadio_QAUS, $GUI_CHECKED) GUICtrlSetState($hRadio_CHROME, $GUI_CHECKED) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $LogInButton $DB = '' If IsChecked($hRadio_QAUS) Then $DB = 'US' If IsChecked($hRadio_QAINTL) Then $DB = 'INTL' If IsChecked($hRadio_STAGING) Then $DB = 'Staging' $browser = '' If IsChecked($hRadio_CHROME) Then $browser = 'chrome.exe' If IsChecked($hRadio_Edge) Then $browser = 'edge.exe' If IsChecked($hRadio_Firefox) Then $browser = 'firefox.exe' MsgBox(0,'Result','database: ' & $DB & @CRLF & 'browser: ' & $browser) ;~ ShellExecute($browser, "myurl" & " --new-window --start-fullscreen") EndSwitch WEnd Func IsChecked($control) Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED EndFunc McMuffinTop 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
McMuffinTop Posted October 28, 2019 Author Share Posted October 28, 2019 Thank you very much Nine & Zedna, I copied in the full code block i have been working on since being introduced to the tool. Love it so far, but so much to learn Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now