williejh Posted July 6, 2023 Posted July 6, 2023 I am writing a script that generates notes for technicians that are working on computers. I have all the functions working correctly, except when multiple GUIs are involved. The issue I am having involves having a second GUI window open. When I close it, the original GUI disappears behind any other windows that are open at the time. This is not what I am intending to happen. I want the original GUI to return to focus when a second GUI window is closed. Here is the code below for the script I am working on. expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Global $NotesBox TemplateCreator() Func TemplateCreator() $TemplateCreator = GUICreate("Template Creator", 910, 290, 304, 443) $Diagnostics = GUICtrlCreateButton("Diagnostics", 8, 16, 161, 41) $Cleanup = GUICtrlCreateButton("Cleanup", 8, 64, 161, 41) $VirusRem = GUICtrlCreateButton("Virus Removal", 8, 112, 161, 41) $HardwareFail = GUICtrlCreateButton("Hardware Failure", 8, 160, 161, 41) $Quote = GUICtrlCreateButton("Quote", 176, 16, 161, 41) $DataQuote = GUICtrlCreateButton("Data Quote", 176, 64, 161, 41) $BlankQuote = GUICtrlCreateButton("Blank Quote", 176, 112, 161, 41) $MoboFail = GUICtrlCreateButton("Motherboard Fail", 176, 160, 161, 41) $Backup = GUICtrlCreateButton("Backup Checklist", 176, 208, 161, 41) $Reinstall = GUICtrlCreateButton("Reinstall (Select Below)", 8, 208, 161, 17) GUICtrlSetFont(-1, 7, 400, 0, "MS Sans Serif") $Clipboard = GUICtrlCreateButton("Copy to Clipboard", 344, 16, 161, 41) $Clear = GUICtrlCreateButton("Clear", 344, 64, 161, 41) $XPdead = GUICtrlCreateButton("Add XP is Dead Text", 344, 112, 78, 41, $BS_MULTILINE) $VistaDead = GUICtrlCreateButton("Add Vista is Dead Text", 424, 112, 78, 41, $BS_MULTILINE) $Win7Dead = GUICtrlCreateButton("Add 7 is Dead Text", 344, 160, 78, 41, $BS_MULTILINE) $Win8Dead = GUICtrlCreateButton("Add 8/8.1 is Dead Text", 424, 160, 78, 41, $BS_MULTILINE) $NotesBox = GUICtrlCreateEdit("", 512, 16, 393, 257, BitOR($ES_AUTOVSCROLL,$WS_VSCROLL)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") $ReinstallList = GUICtrlCreateCombo("", 8, 232, 161, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Reinstall with Data|Reinstall no Data|Hard drive install with Data|Hard drive install no Data") GUICtrlSetFont(-1, 6, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) GUISetState() While 1 Local $aMsg Switch GUIGetMsg() Case $GUI_EVENT_NONE ContinueLoop Case $GUI_EVENT_CLOSE ExitLoop Case $Diagnostics ; Disable the first GUI GUISetState(@SW_DISABLE, $TemplateCreator) Diagnostics() ; Re-enable the first GUI GUISetState(@SW_ENABLE, $TemplateCreator) Case $Cleanup GUICtrlSetData($NotesBox, "") GUICtrlSetData($NotesBox, "- No viruses found" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Removed malware programs (adware/spyware/tracking)" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Updated Adobe Reader" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Installed Critical and Important Windows Updates" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Cleared internet history, temporary files, and cookies" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Emptied Recycle bin" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Optimized Windows start-up program list" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Fixed registry errors" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Created restore point" & @CRLF , 1) Case $VirusRem $VirusCount = InputBox("Virus Count", "Enter the number of viruses found") GUICtrlSetData($NotesBox, "") GUICtrlSetData($NotesBox, "- Removed "&$VirusCount&" viruses from the system" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Repaired damage done by viruses" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Updated Adobe Reader" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Installed Critical and Important Windows Updates" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Cleared internet history, temporary files, and cookies" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Emptied Recycle bin" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Optimized Windows start-up program list" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Fixed registry errors" & @CRLF , 1) GUICtrlSetData($NotesBox, "- Created restore point" & @CRLF , 1) Case $HardwareFail $HdwDescript = InputBox("Hardware Description", "Enter the Hardware that was installed.") GUICtrlSetData($NotesBox, "- Removed old " & $HdwDescript & @CRLF , 1) GUICtrlSetData($NotesBox, "- Installed new " & $HdwDescript & @CRLF , 1) GUICtrlSetData($NotesBox, "- Tested " & $HdwDescript & @CRLF , 1) GUICtrlSetData($NotesBox, "- Created restore point" & @CRLF , 1) Case $Quote GUISetState(@SW_DISABLE, $TemplateCreator) Quote() ; Re-enable the first GUI GUISetState(@SW_ENABLE, $TemplateCreator) Case $DataQuote $DataAmt = InputBox("Data Amount", "Enter the amount of data backed up in GigaBytes") GUICtrlSetData($NotesBox, "") GUICtrlSetData($NotesBox, "_______________________DATA BACK UP QUOTE_____" & @CRLF , 1) GUICtrlSetData($NotesBox, "Approximate Data Amount: " & $DataAmt & "GB" & @CRLF & @CRLF , 1) If $DataAmt <= 0.7 Then GUICtrlSetData($NotesBox, "Intermediate Level 1, 0-700MB: $50" & @CRLF , 1) If $DataAmt > 0.7 And $DataAmt <= 8 Then GUICtrlSetData($NotesBox, "Intermediate Level 2, 701MB-8GB: $60" & @CRLF , 1) If $DataAmt > 8 Then GUICtrlSetData($NotesBox, "Intermediate Level 3, 8GB-32GB: $75" & @CRLF , 1) Case $BlankQuote GUICtrlSetData($NotesBox, "") GUICtrlSetData($NotesBox, "___________________QUOTE____________________" & @CRLF , 1) GuiCtrlSetData($NotesBox, "Labor: $" & @CRLF , 1) GUICtrlSetData($NotesBox, "Parts: $" & @CRLF , 1) GUICtrlSetData($NotesBox, "Subtotal: $" & @CRLF , 1) GUICtrlSetData($NotesBox, "Tax: $" & @CRLF , 1) GUICtrlSetData($NotesBox, "Total: $" & @CRLF , 1) GUICtrlSetData($NotesBox, "Payments: ($ )" & @CRLF , 1) GUICtrlSetData($NotesBox, "Balance: $" & @CRLF , 1) Case $MoboFail ; Disable the first GUI GUISetState(@SW_DISABLE, $TemplateCreator) MoboFail() ; Re-enable the first GUI GUISetState(@SW_ENABLE, $TemplateCreator) Case $Backup GUICtrlSetData($NotesBox, "BACKUP CHECKLIST:" & @CRLF , 1) GUICtrlSetData($NotesBox, "List User profiles backed up:" & @CRLF , 1) GUICtrlSetData($NotesBox, "1: " & @CRLF , 1) GUICtrlSetData($NotesBox, "2: " & @CRLF , 1) GUICtrlSetData($NotesBox, "3: " & @CRLF , 1) GUICtrlSetData($NotesBox, "4: " & @CRLF , 1) GUICtrlSetData($NotesBox, "All Users/Public backup................: " & @CRLF , 1) GUICtrlSetData($NotesBox, "Entire User folder backed up...........: " & @CRLF , 1) GUICtrlSetData($NotesBox, "AppData folder from each user..........: " & @CRLF , 1) GUICtrlSetData($NotesBox, "system32\config........................: " & @CRLF , 1) GUICtrlSetData($NotesBox, "Extra Folders on C:\...................: " & @CRLF , 1) GUICtrlSetData($NotesBox, "Note Mail program......................: " & @CRLF , 1) GUICtrlSetData($NotesBox, "Mail backed up.........................: " & @CRLF , 1) GUICtrlSetData($NotesBox, ".pst file present?.....................: " & @CRLF , 1) GUICtrlSetData($NotesBox, "Office Keys found......................: " & @CRLF , 1) GUICtrlSetData($NotesBox, " List any Financial software installed:" & @CRLF , 1) GUICtrlSetData($NotesBox, "1: " & @CRLF , 1) GUICtrlSetData($NotesBox, " Financial software data backed up......: " & @CRLF , 1) Case $Reinstall $choice = GUICtrlRead($ReinstallList) If Not ($choice) = "" Then $AVsoftware = InputBox("Antivirus Software", "Enter Antivirus") EndIf If $choice = "Reinstall with Data" Then GUICtrlSetData($NotesBox, "") GUICtrlSetData($NotesBox, "- Installed Windows Operating System" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed drivers" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Updated Windows" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed and updated Adobe Reader" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed and updated " & $AVsoftware & @CRLF, 1) GUICtrlSetData($NotesBox, "- Transferred Data" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Created restore point" & @CRLF, 1) EndIf If $choice = "Reinstall no Data" Then GUICtrlSetData($NotesBox, "") GUICtrlSetData($NotesBox, "- Installed Windows Operating System" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed drivers" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Updated Windows" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed and updated Adobe Reader" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed and updated " & $AVsoftware & @CRLF, 1) GUICtrlSetData($NotesBox, "- Created restore point" & @CRLF, 1) EndIf If $choice = "Hard drive install with Data" Then GUICtrlSetData($NotesBox, "") GUICtrlSetData($NotesBox, "- Installed hard drive" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed Windows Operating System" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed drivers" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Updated Windows" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed and updated Adobe Reader" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed and updated " & $AVsoftware & @CRLF, 1) GUICtrlSetData($NotesBox, "- Transferred Data from old hard drive to new hard drive" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Created restore point" & @CRLF, 1) EndIf If $choice = "Hard drive install no Data" Then GUICtrlSetData($NotesBox, "") GUICtrlSetData($NotesBox, "- Installed hard drive" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed Windows Operating System" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed drivers" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Updated Windows" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed and updated Adobe Reader" & @CRLF, 1) GUICtrlSetData($NotesBox, "- Installed and updated " & $AVsoftware & @CRLF, 1) GUICtrlSetData($NotesBox, "- Created restore point" & @CRLF, 1) EndIf Case $Clipboard $BOXcontents = GUICtrlRead( $NotesBox) ClipPut($BOXcontents) Case $Clear GUICtrlSetData($NotesBox, "") Case $XPdead GUICtrlSetData($NotesBox, "<em>As of April 8, 2014, Microsoft is no longer supporting Windows XP. Your system may be vulnerable to security threats and you should use this computer with caution.</em>" & @CRLF , 1) GUICtrlSetData($NotesBox, "<em>As of April 2016, Google chrome is no longer supporting Windows XP.</em>" & @CRLF , 1) GUICtrlSetData($NotesBox, "<em>As of September 2017, Mozilla Firefox will be ending support for Windows XP computers.</em>" & @CRLF , 1) Case $VistaDead GUICtrlSetData($NotesBox, "<em>As of April 11, 2017, Microsoft is no longer supporting Windows Vista. Your system will be vulnerable to security threats and you should use this computer with caution.</em>" & @CRLF , 1) GUICtrlSetData($NotesBox, "<em>As of April 2016, Google chrome is no longer supporting Windows Vista.</em>" & @CRLF , 1) GUICtrlSetData($NotesBox, "<em>As of September 2017, Mozilla Firefox will be ending support for Windows Vista computers.</em>" & @CRLF , 1) Case $Win7Dead GUICtrlSetData($NotesBox, "<em>As of January 14, 2020, Microsoft is no longer supporting Windows 7. Your system will be vulnerable to security threats and you should use this computer with caution</em>" & @CRLF , 1) GUICtrlSetData($NotesBox, "<em>As of February 2023, Google Chrome and Microsoft Edge are no longer supporting Windows 7.</em>" & @CRLF , 1) Case $Win8Dead GUICtrlSetData($NotesBox, "<em>As of January 10, 2023, Microsoft is no longer supporting Windows 8.1. Your system will be vulnerable to security threats and you should use this computer with caution</em>" & @CRLF , 1) GUICtrlSetData($NotesBox, "<em>As of February 2023, Google Chrome and Microsoft Edge are no longer supporting Windows 8.1.</em>" & @CRLF , 1) EndSwitch WEnd EndFunc ;==>TemplateCreator Func Diagnostics() $DiagForm = GUICreate("Diagnostics", 567, 552, 203, 129, -1, -1) $WODesc_Label = GUICtrlCreateLabel("Original Work Order Description", 8, 8, 153, 17) $DescriptionBox = GUICtrlCreateEdit("", 8, 24, 545, 73, $ES_WANTRETURN) GUICtrlSetData(-1, "") $Hardware = GUICtrlCreateGroup("Hardware", 8, 104, 545, 33) $HdwPass = GUICtrlCreateRadio("Pass", 168, 116, 113, 17) GUICtrlSetState(-1, $GUI_CHECKED) $HdwFail = GUICtrlCreateRadio("Fail", 288, 116, 113, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $HardDrive = GUICtrlCreateGroup("Hard Drive", 8, 144, 545, 33) $DiskPass = GUICtrlCreateRadio("Pass", 168, 156, 113, 17) GUICtrlSetState(-1, $GUI_CHECKED) $DiskFail = GUICtrlCreateRadio("Fail", 288, 156, 113, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Antivirus = GUICtrlCreateGroup("Antivirus", 8, 184, 545, 153) $AV_none = GUICtrlCreateRadio("None", 16, 208, 113, 17) GUICtrlSetState(-1, $GUI_CHECKED) $AV_Norton = GUICtrlCreateRadio("Norton", 168, 208, 113, 17) $AV_McAfee = GUICtrlCreateRadio("McAfee", 288, 208, 113, 17) $AV_Symantec = GUICtrlCreateRadio("Symantec", 168, 232, 113, 17) $AV_Kaspersky = GUICtrlCreateRadio("Kaspersky", 288, 232, 113, 17) $AV_WebRoot = GUICtrlCreateRadio("WebRoot", 168, 256, 113, 17) $AV_WinDefender = GUICtrlCreateRadio("Windows Defender", 288, 256, 113, 17) $AV_Avast = GUICtrlCreateRadio("Avast!", 168, 280, 113, 17) $AV_AVG = GUICtrlCreateRadio("AVG", 288, 280, 113, 17) $AV_Other = GUICtrlCreateRadio("Other (enter below)", 16, 280, 113, 17) $AV_OtherInput = GUICtrlCreateInput("", 32, 304, 105, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $WindowsActivated = GUICtrlCreateGroup("Windows Activated", 8, 344, 545, 33) GUICtrlSetState(-1, $GUI_CHECKED) $ActivatedYes = GUICtrlCreateRadio("Activated", 168, 356, 113, 17) $ActivatedNo = GUICtrlCreateRadio("Not Activated", 280, 356, 113, 17) $ActivatedUnknown = GUICtrlCreateRadio("Unknown", 400, 356, 113, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $ProblemLabel = GUICtrlCreateLabel("List Specific Problems Found:", 8, 392, 143, 17) $ProblemBox = GUICtrlCreateEdit("", 8, 408, 545, 89, $ES_WANTRETURN) GUICtrlSetData(-1, "- ") Local $SubmitButton = GUICtrlCreateButton("Send To Creator", 191, 512, 185, 25) GUISetState(@SW_SHOW) While 1 ; We can only get messages from the second GUI Switch GUIGetMsg() Case $GUI_EVENT_NONE ContinueLoop Case $GUI_EVENT_CLOSE GUIDelete($DiagForm) ExitLoop Case $SubmitButton GUICtrlSetData($NotesBox, "") ;read the Description $Description = GUICtrlRead($DescriptionBox) GUICtrlSetData($NotesBox, "Original Work Order Description: " & $Description & @CRLF & @CRLF , 1) GUICtrlSetData($NotesBox, "Physically Cleaned computer" & @CRLF , 1) ;Hardware Diags $Hdw = GUICtrlRead($HdwPass) If $Hdw = 1 Then GUICtrlSetData($NotesBox, "Hardware Diagnostics..........................Pass" & @CRLF , 1) Else GUICtrlSetData($NotesBox, "Hardware Diagnostics..........................Fail" & @CRLF , 1) EndIf ;Hard Drive Diags $Disk = GUICtrlRead($DiskPass) If $Disk = 1 Then GUICtrlSetData($NotesBox, "Hard Drive...........................................Pass" & @CRLF , 1) Else GUICtrlSetData($NotesBox, "Hard Drive...........................................Fail" & @CRLF , 1) EndIf ; Is Windows Activated? Local $Activate = "0" If GUICtrlRead($ActivatedYes) = $GUI_CHECKED Then $Activate = "Activated" If GUICtrlRead($ActivatedNo) = $GUI_CHECKED Then $Activate = "Not Activated" If GuiCtrlRead($ActivatedUnknown) = $GUI_CHECKED Then $Activate = "0" If Not ($Activate = "0") Then GUICtrlSetData($NotesBox, "Windows Activation............................." & $Activate & @CRLF , 1) If $Activate = "0" Then GuiCtrlSetData($NotesBox, @CRLF , 1) ; Antivirus Installed If GUICtrlRead($AV_Norton) = $GUI_CHECKED Then $AV = "Norton" If GUICtrlRead($AV_McAfee) = $GUI_CHECKED Then $AV = "McAfee" If GUICtrlRead($AV_Symantec) = $GUI_CHECKED Then $AV = "Symantec" If GUICtrlRead($AV_Kaspersky) = $GUI_CHECKED Then $AV = "Kaspersky" If GUICtrlRead($AV_WebRoot) = $GUI_CHECKED Then $AV = "WebRoot" If GUICtrlRead($AV_WinDefender) = $GUI_CHECKED Then $AV = "Windows Defender" If GUICtrlRead($AV_Avast) = $GUI_CHECKED Then $AV = "Avast!" If GUICtrlRead($AV_AVG) = $GUI_CHECKED Then $AV = "AVG" If GUICtrlRead($AV_Other) = $GUI_CHECKED Then $AV = GUICtrlRead($AV_OtherInput) If GUICtrlRead($AV_none) = $GUI_CHECKED Then $AV = "0" If Not($AV = "0") Then GUICtrlSetData($NotesBox, "Antivirus Installed................................"& $AV & @CRLF & @CRLF , 1) If $AV = "0" Then GUICtrlSetData($NotesBox, @CRLF, 1) ; List Specific Problems Found $Problems = GUICtrlRead($ProblemBox) GuiCtrlSetData($NotesBox, $Problems & @CRLF , 1) GUIDelete($DiagForm) ExitLoop EndSwitch WEnd EndFunc ;==>Diagnostics Func MoboFail() $MoboFailForm = GUICreate("Motherboard Failure Checklist", 615, 522, 189, 127) $MoboFailLabel = GUICtrlCreateLabel("Fill in the form for what has been tested. Assume that pass means yes. Fail means that it could not be tested or did not work.", 8, 8, 585, 17) $MoboFailLabel2 = GUICtrlCreateLabel("Not Tested means that it was not looked at.", 8, 24, 210, 17) $NotTestLeft = GUICtrlCreateLabel("Not Tested", 200, 48, 57, 17) $VideoTest = GUICtrlCreateGroup("", 8, 64, 257, 49) $VideoYes = GUICtrlCreateRadio("Computer Showed External video", 16, 72, 177, 17) $VideoNo = GUICtrlCreateRadio("Computer showed no External video", 16, 92, 193, 17) GUICtrlSetState(-1, $GUI_CHECKED) $VideoUntest = GUICtrlCreateRadio("", 216, 72, 25, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $BootTest = GUICtrlCreateGroup("", 8, 120, 257, 49) $BootYes = GUICtrlCreateRadio("Able to Boot to CD/USB Drive", 16, 128, 169, 17) $BootNo = GUICtrlCreateRadio("Not Able to boot to CD/USB Drive", 16, 148, 185, 17) $BootUntest = GUICtrlCreateRadio("", 216, 128, 25, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $PwrButtonTest = GUICtrlCreateGroup("", 8, 176, 257, 49) $PwrButtonYes = GUICtrlCreateRadio("Power Button Works", 16, 184, 121, 17) $PwrButtonNo = GUICtrlCreateRadio("Power Button does not work", 16, 204, 161, 17) $PwrButtonUntest = GUICtrlCreateRadio("", 216, 184, 25, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $PSU_Test = GUICtrlCreateGroup("Does the Powr Supply Work?", 8, 232, 257, 41) $PSU_Yes = GUICtrlCreateRadio("Yes", 16, 248, 50, 17) $PSU_No = GUICtrlCreateRadio("No", 96, 248, 50, 17) $PSU_Untest = GUICtrlCreateRadio("", 216, 248, 25, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $NewPSU = GUICtrlCreateGroup("Different Power Supply tested?", 8, 280, 257, 41) $NewPSU_Yes = GUICtrlCreateRadio("Yes", 16, 296, 50, 17) $NewPSU_No = GUICtrlCreateRadio("No", 96, 296, 50, 17) $NewPSU_Untest = GUICtrlCreateRadio("", 216, 296, 25, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $MoboPwr = GUICtrlCreateGroup("", 8, 328, 257, 49) $MoboPwrYes = GUICtrlCreateRadio("Motherboard is getting power", 16, 336, 161, 17) $MoboPwrNo = GUICtrlCreateRadio("Motherboard not getting power", 16, 356, 169, 17) $MoboPwrUntest = GUICtrlCreateRadio("", 216, 336, 25, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $RAM_Reset = GUICtrlCreateGroup("Was the RAM Reset", 8, 384, 257, 41) $RAM_ResetYes = GUICtrlCreateRadio("Yes", 16, 400, 50, 17) $RAM_ResetNo = GUICtrlCreateRadio("No", 96, 400, 50, 17) $RAM_ResetUntest = GUICtrlCreateRadio("", 216, 400, 25, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $NewRAM_Test = GUICtrlCreateGroup("Was different RAM tested?", 8, 432, 257, 41) $NewRAM_Yes = GUICtrlCreateRadio("Yes", 16, 448, 50, 17) $NewRAM_No = GUICtrlCreateRadio("No", 96, 448, 50, 17) $NewRAM_Untest = GUICtrlCreateRadio("", 216, 448, 25, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $NotTestRight = GUICtrlCreateLabel("Not Tested", 504, 48, 57, 17) $CMOS_Battery = GUICtrlCreateGroup("CMOS Battery Test", 296, 64, 249, 65) $CMOS_Yes = GUICtrlCreateRadio("CMOS was Tested", 304, 80, 113, 17) $CMOS_No = GUICtrlCreateRadio("No", 440, 80, 50, 17) $CMOS_Untest = GUICtrlCreateRadio("", 520, 80, 20, 17) GUICtrlSetState(-1, $GUI_CHECKED) $CMOS_Voltage = GUICtrlCreateLabel("Voltage", 304, 104, 40, 17) $VoltageBox = GUICtrlCreateInput("", 352, 100, 50, 21) GUICtrlSetLimit(-1, 5) GUICtrlCreateGroup("", -99, -99, 1, 1) $DisconnectTest = GUICtrlCreateGroup("Were all peripherals disconnected?", 296, 136, 249, 41) $DisconnectYes = GUICtrlCreateRadio("Yes", 304, 152, 50, 17) $DisconnectNo = GUICtrlCreateRadio("No", 400, 152, 50, 17) $DisconnectUntest = GUICtrlCreateRadio("", 520, 152, 20, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $CPU_Reset = GUICtrlCreateGroup("Was the processor reset?", 296, 184, 249, 41) $CPU_ResetYes = GUICtrlCreateRadio("Yes", 304, 200, 50, 17) $CPU_ResetNo = GUICtrlCreateRadio("No", 400, 200, 50, 17) $CPU_ResetUntest = GUICtrlCreateRadio("", 520, 200, 20, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group1 = GUICtrlCreateGroup("Was a different processor tested?", 296, 232, 249, 41) $NewCPU_Yes = GUICtrlCreateRadio("Yes", 304, 248, 50, 17) $NewCPU_No = GUICtrlCreateRadio("None Available", 400, 248, 100, 17) $NewCPU_Untest = GUICtrlCreateRadio("", 520, 248, 20, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $NewTech = GUICtrlCreateGroup("Tested by different Technician", 296, 280, 249, 65) $NewTechYes = GUICtrlCreateRadio("Yes", 304, 296, 50, 17) $NewTechNo = GUICtrlCreateRadio("No", 400, 296, 113, 17) GUICtrlSetState(-1, $GUI_CHECKED) $TechName = GUICtrlCreateLabel("Name of Tech", 304, 320, 72, 17) $NameBox = GUICtrlCreateInput("", 392, 316, 121, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Result = GUICtrlCreateGroup("Results", 296, 352, 305, 121) $Result1 = GUICtrlCreateRadio("Computer powers on but with nothing on screen", 304, 368, 250, 17) $Result2 = GUICtrlCreateRadio("Computer turns on and flashes splash screen and turns off", 304, 388, 300, 17) $Result3 = GUICtrlCreateRadio("Computer starts to boot but continusly reboots", 304, 408, 275, 17) $Result4 = GUICtrlCreateRadio("Computer does not power on at all", 304, 428, 275, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $SubmitButton2 = GUICtrlCreateButton("Send to Creator", 238, 488, 139, 25) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_NONE ContinueLoop Case $GUI_EVENT_CLOSE GUIDelete($MoboFailForm) ExitLoop Case $SubmitButton2 GUICtrlSetData($NotesBox, "") GUICtrlSetData($NotesBox, "MOTHERBOARD FAILURE CHECKLIST" & @CRLF & @CRLF, 1) ;external video If GUICtrlRead($VideoYes) = $GUI_CHECKED Then $Video = "External Video works" If GUICtrlRead($VideoNo) = $GUI_CHECKED Then $Video = "External Video does not work" If GuiCtrlRead($VideoUntest) = $GUI_CHECKED Then $Video = "Not Tested" GUICtrlSetData($NotesBox, "Able to get video via external Video connection....: " & $Video & @CRLF , 1) ;boot to CD/USB drive If GUICtrlRead($BootYes) = $GUI_CHECKED Then $Boot = "Boots to CD/USB Drive" If GUICtrlRead($BootNo) = $GUI_CHECKED Then $Boot = "Does not boot to CD/USB Drive" If GuiCtrlRead($BootUntest) = $GUI_CHECKED Then $Boot = "Not Tested" GUICtrlSetData($NotesBox, "Able to boot to CD or USB drive....................: " & $Boot & @CRLF , 1) ;test power button If GUICtrlRead($PwrButtonYes) = $GUI_CHECKED Then $PwrButton = "Power button works" If GUICtrlRead($PwrButtonNo) = $GUI_CHECKED Then $PwrButton = "Power button does not work" If GuiCtrlRead($PwrButtonUntest) = $GUI_CHECKED Then $PwrButton = "Not Tested" GUICtrlSetData($NotesBox, "Tested Power button................................: " & $PwrButton & @CRLF , 1) ;test power supply If GUICtrlRead($PSU_Yes) = $GUI_CHECKED Then $PSU = "Power Supply works" If GUICtrlRead($PSU_No) = $GUI_CHECKED Then $PSU = "Power Supply does not work" If GUICtrlRead($PSU_Untest) = $GUI_CHECKED Then $PSU = "Not Tested" GUICtrlSetData($NotesBox, "Tested Power supply................................: " & $PSU & @CRLF , 1) ;test using different power supply If GUICtrlRead($NewPSU_Yes) = $GUI_CHECKED Then $NewPSU = "Different power supply was tested" If GUICtrlRead($NewPSU_No) = $GUI_CHECKED Then $NewPSU = "Different power supply was not tested" If GUICtrlRead($NewPSU_Untest) = $GUI_CHECKED Then $NewPSU = "Not Tested" GUICtrlSetData($NotesBox, "Tested with different power supply (universal).....: " & $NewPSU & @CRLF , 1) ;test if motherboard gets power If GUICtrlRead($MoboPwrYes) = $GUI_CHECKED Then $MoboPwr = "Motherboard is getting power" If GUICtrlRead($MoboPwrNo) = $GUI_CHECKED Then $MoboPwr = "Motherboard is not getting power" If GUICtrlRead($MoboPwrUntest) = $GUI_CHECKED Then $MoboPwr = "Not Tested" GUICtrlSetData($NotesBox, "Test that power is getting to the motherboard.....: " & $MoboPwr & @CRLF , 1) ;reset RAM If GUICtrlRead($RAM_ResetYes) = $GUI_CHECKED Then $RAM_Reset = "RAM was reset" If GUICtrlRead($RAM_ResetNo) = $GUI_CHECKED Then $RAM_Reset = "RAM was not reset" If GUICtrlRead($RAM_ResetUntest) = $GUI_CHECKED Then $RAM_Reset = "Not Tested" GUICtrlSetData($NotesBox, "Reset RAM..........................................: " & $RAM_Reset & @CRLF , 1) ;test with different RAM If GUICtrlRead($NewRAM_Yes) = $GUI_CHECKED Then $NewRAM = "Different RAM was tested" If GUICtrlRead($NewRAM_No) = $GUI_CHECKED Then $NewRAM = "Different RAM was not tested" If GUICtrlRead($NewRAM_Untest) = $GUI_CHECKED Then $NewRAM = "Not Tested" GUICtrlSetData($NotesBox, "Tested motherboard with different RAM..............: " & $NewRAM & @CRLF , 1) ;test CMOS battery If GUICtrlRead($CMOS_Yes) = $GUI_CHECKED Then $Battery = "CMOS Battery Tested" If GUICtrlRead($CMOS_Yes) = $GUI_CHECKED Then $Voltage = GUICtrlRead($VoltageBox);gets the voltage If GUICtrlRead($CMOS_No) = $GUI_CHECKED Then $Battery = "Not Tested" If GuiCtrlRead($CMOS_Untest) = $GUI_CHECKED Then $Battery = "Unable to Test" ;output line with battery voltage if tested If GUICtrlRead($CMOS_Yes) = $GUI_CHECKED Then GUICtrlSetData($NotesBox, "Reset/Tested CMOS battery..........................: " & $Battery & " (" & $Voltage &"v)" & @CRLF , 1) ;if CMOS not tested then dont output voltage If Not (GUICtrlRead($CMOS_Yes) = $GUI_CHECKED) Then GUICtrlSetData($NotesBox, "Reset/Tested CMOS battery..........................: " & $Battery & @CRLF , 1) ;disconnected peripherals If GUICtrlRead($DisconnectYes) = $GUI_CHECKED Then $Disconnect = "All Peripherals were disconnected" If GUICtrlRead($DisconnectNo) = $GUI_CHECKED Then $Disconnect = "Not everything was disconnected" If GuiCtrlRead($DisconnectUntest) = $GUI_CHECKED Then $Disconnect = "Not Tested" GUICtrlSetData($NotesBox, "Disconnected all peripherals.......................: " & $Disconnect & @CRLF , 1) ;reset processor If GUICtrlRead($CPU_ResetYes) = $GUI_CHECKED Then $CPU_Reset = "Processor was reset" If GUICtrlRead($CPU_ResetNo) = $GUI_CHECKED Then $CPU_Reset = "Processor was not reset" If GUICtrlRead($CPU_ResetUntest) = $GUI_CHECKED Then $CPU_Reset = "Not Tested" GUICtrlSetData($NotesBox, "Reset Processor....................................: " & $CPU_Reset & @CRLF , 1) ;test with different CPU If GUICtrlRead($NewCPU_Yes) = $GUI_CHECKED Then $NewCPU = "A different processor was tested" If GUICtrlRead($NewCPU_No) = $GUI_CHECKED Then $NewCPU = "No compatible processors available" If GUICtrlRead($NewCPU_Untest) = $GUI_CHECKED Then $NewCPU = "Not Tested" GUICtrlSetData($NotesBox, "Tested with different Processor....................: " & $NewCPU & @CRLF , 1) ;tested by another tech If GUICtrlRead($NewTechYes) = $GUI_CHECKED Then $NewTech = "Tested by " & GUICtrlRead($NameBox) If GUICtrlRead($NewTechNo) = $GUI_CHECKED Then $NewTech = "Self-tested" GUICtrlSetData($NotesBox, "Double checked by another Technician...............: " & $NewTech & @CRLF & @CRLF , 1) GUICtrlSetData($NotesBox, "Results after testing:" & @CRLF , 1) ;results If GUICtrlRead($Result1) = $GUI_CHECKED Then $Result = "Computer powers on but shows nothing on the screen" If GUICtrlRead($Result2) = $GUI_CHECKED Then $Result = "Computer turns on and flashes splash screen and turns off" If GUICtrlRead($Result3) = $GUI_CHECKED Then $Result = "Computer starts to boot and continuously reboots" If GUICtrlRead($Result4) = $GUI_CHECKED Then $Result = "Computer does not power on at all" GUICtrlSetData($NotesBox, $Result & @CRLF , 1) GUIDelete($MoboFailForm) ExitLoop EndSwitch WEnd EndFunc ;-->MoboFail Func Quote() $QuoteForm = GUICreate("Quote Form", 350, 356, 225, 134) $QuoteInst = GUICtrlCreateLabel("Enter the information from the inovice in AtWork to generate a quote", 8, 8, 325, 17) $LaborLabel = GUICtrlCreateLabel("Labor", 40, 48, 31, 17) $LaborBox = GUICtrlCreateInput("0.00", 136, 44, 81, 21) $Part1Label = GUICtrlCreateLabel("Part1", 40, 75, 29, 17) $Part1Box = GUICtrlCreateInput("0.00", 136, 71, 81, 21) $Part2Label = GUICtrlCreateLabel("Part2", 40, 102, 29, 17) $Part2Box = GUICtrlCreateInput("0.00", 136, 98, 81, 21) $Part3Label = GUICtrlCreateLabel("Part3", 40, 129, 29, 17) $Part3Box = GUICtrlCreateInput("0.00", 136, 125, 81, 21) $Part4Box = GUICtrlCreateInput("0.00", 136, 152, 81, 21) $Part4Label = GUICtrlCreateLabel("Part4", 42, 156, 29, 17) $SubtotalBox = GUICtrlCreateInput("0.00", 136, 179, 81, 21) $SubTotalLabel = GUICtrlCreateLabel("Subtotal", 40, 183, 43, 17) $TaxBox = GUICtrlCreateInput("0.00", 136, 206, 81, 21) $TaxLabel = GUICtrlCreateLabel("Tax", 40, 210, 22, 17) $TotalBox = GUICtrlCreateInput("0.00", 136, 233, 81, 21) $TotalLabel = GUICtrlCreateLabel("Total", 40, 237, 28, 17) $PaymentsBox = GUICtrlCreateInput("0.00", 136, 260, 81, 21) $PaymentsLabel = GUICtrlCreateLabel("Payments", 40, 264, 50, 17) $BalanceBox = GUICtrlCreateInput("0.00", 136, 287, 81, 21) $BalanceLabel = GUICtrlCreateLabel("Balance", 40, 291, 43, 17) $QuoteSubmit = GUICtrlCreateButton("Send to Creator", 128, 320, 100, 25) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_NONE ContinueLoop Case $GUI_EVENT_CLOSE GUIDelete($QuoteForm) ExitLoop Case $QuoteSubmit $Labor = GUICtrlRead($LaborBox) $Part1 = GUICtrlRead($Part1Box) $Part2 = GUICtrlRead($Part2Box) $Part3 = GUICtrlRead($Part3Box) $Part4 = GUICtrlRead($Part4Box) $Subtotal = GUICtrlRead($SubtotalBox) $Tax = GUICtrlRead($TaxBox) $Total = GUICtrlRead($TotalBox) $Payments = GUICtrlRead($PaymentsBox) $Balance = GUICtrlRead ($BalanceBox) GUICtrlSetData($NotesBox, "") GUICtrlSetData($NotesBox, "___________________QUOTE____________________" & @CRLF, 1) GUICtrlSetData($NotesBox, "Labor: $" & $Labor & @CRLF, 1) GUICtrlSetData($NotesBox, "Parts: $" & $Part1 & @CRLF, 1) If Not ($Part2 = 0.00) Then GUICtrlSetData($NotesBox, "Parts: $" & $Part2 & @CRLF, 1) If Not ($Part3 = 0.00) Then GUICtrlSetData($NotesBox, "Parts: $" & $Part3 & @CRLF, 1) If Not ($Part4 = 0.00) Then GUICtrlSetData($NotesBox, "Parts: $" & $Part4 & @CRLF, 1) GUICtrlSetData($NotesBox, "Subtotal: $" & $Subtotal & @CRLF, 1) GUICtrlSetData($NotesBox, "Tax: $" & $Tax & @CRLF, 1) GUICtrlSetData($NotesBox, "Total: $" & $Total & @CRLF, 1) GUICtrlSetData($NotesBox, "Payments: ($" & $Payments & ")" & @CRLF, 1) GUICtrlSetData($NotesBox, "Balance: $" & $Balance & @CRLF, 1) GUIDelete($QuoteForm) ExitLoop EndSwitch WEnd EndFunc If anyone can suggest what I need to change to bring focus back to the first GUI when the second one is closed I would appreciate it. The Quote, Diagnostics, and Motherboard Fail buttons are the ones that open a second GUI if it helps with what is going on.
Andreik Posted July 6, 2023 Posted July 6, 2023 (edited) Why do you disable the main GUI since the messages are not processed in the loop of your child GUI? Anyway, if you still want to do it that way, here is a basic example: Global $hMain = GUICreate('Example') $cButton = GUICtrlCreateButton('Click me', 100, 100, 100, 30) GUISetState(@SW_SHOW, $hMain) While True Switch GUIGetMsg() Case -3 ; GUI_EVENT_CLOSE Exit Case $cButton NewGUI() EndSwitch WEnd Func NewGUI() GUISetState(@SW_DISABLE, $hMain) Local $hGUI = GUICreate('I am a new GUI', 300, 200) GUISetState(@SW_SHOW, $hGUI) While True Switch GUIGetMsg() Case -3 ; GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Order or these 2 is important GUISetState(@SW_ENABLE, $hMain) GUIDelete($hGUI) EndFunc Or following the logic of your script, you need to activate the window before enable it: $hMain = GUICreate('Example') $cButton = GUICtrlCreateButton('Click me', 100, 100, 100, 30) GUISetState(@SW_SHOW, $hMain) While True Switch GUIGetMsg() Case -3 ; GUI_EVENT_CLOSE Exit Case $cButton GUISetState(@SW_DISABLE, $hMain) NewGUI() WinActivate($hMain) GUISetState(@SW_ENABLE, $hMain) EndSwitch WEnd Func NewGUI() GUISetState(@SW_DISABLE, $hMain) Local $hGUI = GUICreate('I am a new GUI', 300, 200) GUISetState(@SW_SHOW, $hGUI) While True Switch GUIGetMsg() Case -3 ; GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) EndFunc  Edited July 6, 2023 by Andreik
pixelsearch Posted July 6, 2023 Posted July 6, 2023 williejh, just add a ControlFocus() line when necessary, for example in the Case $Diagnostics part : Case $Diagnostics ; Disable the first GUI GUISetState(@SW_DISABLE, $TemplateCreator) Diagnostics() ; Re-enable the first GUI GUISetState(@SW_ENABLE, $TemplateCreator) ControlFocus($TemplateCreator, "", $Diagnostics) ; <======== added line "I think you are searching a bug where there is no bug... don't listen to bad advice."
argumentum Posted July 6, 2023 Posted July 6, 2023 (edited) 4 hours ago, williejh said: When I close it, the original GUI disappears behind expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Global $NotesBox, $TemplateCreator TemplateCreator() Func TemplateCreator() $TemplateCreator = GUICreate("Template Creator", 910, 290, 304, 443) $Diagnostics = GUICtrlCreateButton("Diagnostics", 8, 16, 161, 41) $Cleanup = GUICtrlCreateButton("Cleanup", 8, 64, 161, 41) $VirusRem = GUICtrlCreateButton("Virus Removal", 8, 112, 161, 41) $HardwareFail = GUICtrlCreateButton("Hardware Failure", 8, 160, 161, 41) $Quote = GUICtrlCreateButton("Quote", 176, 16, 161, 41) $DataQuote = GUICtrlCreateButton("Data Quote", 176, 64, 161, 41) $BlankQuote = GUICtrlCreateButton("Blank Quote", 176, 112, 161, 41) $MoboFail = GUICtrlCreateButton("Motherboard Fail", 176, 160, 161, 41) $Backup = GUICtrlCreateButton("Backup Checklist", 176, 208, 161, 41) $Reinstall = GUICtrlCreateButton("Reinstall (Select Below)", 8, 208, 161, 17) GUICtrlSetFont(-1, 7, 400, 0, "MS Sans Serif") $Clipboard = GUICtrlCreateButton("Copy to Clipboard", 344, 16, 161, 41) $Clear = GUICtrlCreateButton("Clear", 344, 64, 161, 41) $XPdead = GUICtrlCreateButton("Add XP is Dead Text", 344, 112, 78, 41, $BS_MULTILINE) $VistaDead = GUICtrlCreateButton("Add Vista is Dead Text", 424, 112, 78, 41, $BS_MULTILINE) $Win7Dead = GUICtrlCreateButton("Add 7 is Dead Text", 344, 160, 78, 41, $BS_MULTILINE) $Win8Dead = GUICtrlCreateButton("Add 8/8.1 is Dead Text", 424, 160, 78, 41, $BS_MULTILINE) $NotesBox = GUICtrlCreateEdit("", 512, 16, 393, 257, BitOR($ES_AUTOVSCROLL,$WS_VSCROLL)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") $ReinstallList = GUICtrlCreateCombo("", 8, 232, 161, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Reinstall with Data|Reinstall no Data|Hard drive install with Data|Hard drive install no Data") GUICtrlSetFont(-1, 6, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) GUISetState() While 1 Local $aMsg Switch GUIGetMsg() Case $GUI_EVENT_NONE ContinueLoop Case $GUI_EVENT_CLOSE ExitLoop Case $Diagnostics Diagnostics() Case $Quote Quote() Case $MoboFail MoboFail() EndSwitch WEnd EndFunc ;==>TemplateCreator Func Diagnostics() $DiagForm = GUICreate("Diagnostics", 567, 552, 203, 129, -1, -1, $TemplateCreator) GUISetState(@SW_SHOW) While 1 ; We can only get messages from the second GUI Switch GUIGetMsg() Case $GUI_EVENT_NONE ContinueLoop Case $GUI_EVENT_CLOSE WinSetOnTop($TemplateCreator, "", 1) ; <--- this is what I do GUIDelete($DiagForm) WinSetOnTop($TemplateCreator, "", 0) ; <--- this is what I do ExitLoop EndSwitch WEnd EndFunc ;==>Diagnostics Func MoboFail() $MoboFailForm = GUICreate("Motherboard Failure Checklist", 615, 522, 189, 127, -1, -1, $TemplateCreator) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_NONE ContinueLoop Case $GUI_EVENT_CLOSE WinSetOnTop($TemplateCreator, "", 1) ; <--- this is what I do GUIDelete($MoboFailForm) WinSetOnTop($TemplateCreator, "", 0) ; <--- this is what I do ExitLoop EndSwitch WEnd EndFunc ;-->MoboFail Func Quote() $QuoteForm = GUICreate("Quote Form", 350, 356, 225, 134, -1, -1, $TemplateCreator) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_NONE ContinueLoop Case $GUI_EVENT_CLOSE WinSetOnTop($TemplateCreator, "", 1) ; <--- this is what I do GUIDelete($QuoteForm) WinSetOnTop($TemplateCreator, "", 0) ; <--- this is what I do ExitLoop EndSwitch WEnd EndFunc  Edited July 6, 2023 by argumentum oops Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
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