Search the Community
Showing results for tags 'winactivate()'.
-
Hello, I have a script which uses a GUI with two buttons. It gets shown and hidden., and pressing the buttons (including their hotkeys) highlights the button, making you able to press enter the next time. However, I don't want that. I've tried using WinActivate() to make enter do things on another program, but the enter is still tied to the AutoIT GUI (which still has the button highlighted). Here's the important part of my code: $MY_GUI = GUICreate("Check.exe", 400, 300, ((@DesktopWidth / 2) - 200), -500) WinSetOnTop($MY_GUI, "", 1) ;Keeps the window on the top. $Button1 = GUICtrlCreateButton("Pass (Ctrl+P)", 40, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Button2 = GUICtrlCreateButton("Fail (Ctrl+F)", 240, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $GUIText = GUICtrlCreateLabel("", 20, 10, 360, 230) GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif") GUICtrlSetData($GUIText, Execute($stepMessage[$step])) $showGUI = "True" GUISetState(@SW_SHOW) While($showGUI = "True") $buttonPressed = GUIGetMsg() Switch $buttonPressed Case $Button1 ;Pass $pass = "True" $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) Case $Button2 ;Fail $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) While($message = "") $message = InputBox("Check.exe", "Please enter the reason the step failed." & @CRLF, "", "", 300, 200, ((@DesktopWidth / 2) - 150), -400) WEnd Return $message EndSwitch WEnd Local $pass = "False" ;Whether "Pass" or "Fail" was pressed. Local $failLog = xxxfunc($pass) ;Returns a message to log if the step failed. ##THIS CALLS THE CODE SNIPPET ABOVE## FileWrite($file, _Now() & ": Step " & $step & getStatus($pass) & "and took " & Ceiling(TimerDiff($timer) / 1000) & " seconds." & @CRLF) If($failLog <> "") Then FileWrite($file, "Logged comment: " & $failLog & @CRLF) EndIf WinActivate("[TITLE:ProgramName]") ;Hotkeys: HotKeySet("^{p}", "pressPass") HotKeySet("^{f}", "pressFail") Func pressPass() $buttonPressed = $Button1 EndFunc Func pressFail() $buttonPressed = $Button2 EndFunc The GUI's button/hotkey pressing works correctly. The same WinActivate code works in another script of mine. Together, WinActivate is not take "Active" away from the GUI's last-pressed button. How do I fix this? Thank you in advance.