kyle2727 Posted November 7, 2013 Share Posted November 7, 2013 I'm working on a script that will run as long as someone is logged into the pc. It simply waits for a specific window to become active and then launches a window with several selections to choose from. These will be shortcuts to speed up the most used processes. It works without a problem the first time. After a selection is made the window is closed until that specific window becomes active again. When this happens the window pops up as it should but none of the buttons work, everything is unresponsive. I'm not sure what I'm missing here. expandcollapse popup#include <Misc.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> Opt("GUIOnEventMode", 1) AutoItSetOption("TrayIconDebug", 1) Global $Initial Wait() Func Wait() WinWaitActive("The window") GUI_1() EndFunc Func GUI_1() $Initial = GUICreate("", 500, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") GUICtrlCreateLabel("Would you like to use one of the shortcuts below?", 10, 10) $No = GUICtrlCreateButton("No Thanks", 20, 190) GUICtrlSetOnEvent($No, "Close") guisetstate(@SW_SHOW) While 1 sleep(100) WEnd EndFunc Func Close() GUISetState(@SW_HIDE, $Initial) WinWaitClose("The Window") Sleep(10000) Wait() EndFunc Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted November 7, 2013 Moderators Solution Share Posted November 7, 2013 kyle2727,Welcome to the AutoIt forum. That was a fun logic flow to interpret. I think should do what you want - I used the AutoIt Help window as the trigger:expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $Initial, $hWinHandle = 0, $fWaiting = True While 1 ; Get target window handle If $hWinHandle = 0 And WinExists("AutoIt Help") Then $hWinHandle = WinGetHandle("AutoIt Help") EndIf ; If waiting for this window to become active and it becomes active If $fWaiting = True And WinActive("AutoIt Help") Then ; Create the GUI GUI_1() ; Clear the flag $fWaiting = False EndIf ; If the flag has been cleared AND the GUI is not active And the window is no longer active If $fWaiting = False And Not(WinActive($Initial)) And Not(WinActive("AutoIt Help")) Then ; Set the flag to look again $fWaiting = True EndIf WEnd Func GUI_1() $Initial = GUICreate("", 500, 500) WinSetOnTop($Initial, "", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") GUICtrlCreateLabel("Would you like to use one of the shortcuts below?", 10, 10) $No = GUICtrlCreateButton("No Thanks", 20, 190) GUICtrlSetOnEvent($No, "Close") GUISetState(@SW_SHOW) EndFunc ;==>GUI_1 Func Close() GUIDelete($Initial) WinActivate($hWinHandle) EndFunc ;==>CloseI hope the comments are clear enough - please ask if not. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
kyle2727 Posted November 7, 2013 Author Share Posted November 7, 2013 That is perfect! Does exactly what I need it to. Thank you! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 7, 2013 Moderators Share Posted November 7, 2013 kyle2727,Glad I could help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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