ransej Posted July 1, 2017 Posted July 1, 2017 Ok, so ive made a gui that has start button and will do a specific task like, it will automatically move the cursor and do other stuff on a different window and will take some time to stop, i wanted to make a hotkey/shortcuts to make it stop even the focus window is in notepad, please help
Moderators JLogan3o13 Posted July 1, 2017 Moderators Posted July 1, 2017 @ransej so you want to make a hot key, did you search in the help file? Look at HotKeySet, which should do exactly what you're after. If you read through that entry in the help file, you'll even find not one but two examples on how to use it. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
ransej Posted July 1, 2017 Author Posted July 1, 2017 yes i would like to make a hotkey for making the gui to stop, when my cursor moves to an out of place position, ive tried the example it only works on script, not on the gui.exe something
Xandy Posted July 3, 2017 Posted July 3, 2017 (edited) First we find what window is under mouse cursor. Then we close it? Two Hotkey methods here: The _IsPressed and the HotKeySet expandcollapse popup#include <WinAPI.au3>; _WinAPI_GetMousePos, _WinAPI_WindowFromPoint, _WinAPI_GetParent #include <GUIConstants.au3>; GUI_EVENT_CLOSE #include <Misc.au3>; _IsPressed #include <MsgBoxConstants.au3>; $MB_YESNOCANCEL, $IDYES $hGui = GUICreate("Get Window Under Mouse", 320, 200) GUICtrlCreateLabel( "Press CTRL + K or" & @CRLF & _ "Press CTRL + Left Mouse Button to close window under mouse", 5, 25, 320, 50) GUISetState(); show the gui HotKeySet("^k", "WinCloseUnderMouse"); CTRL + K Do ; Get window messages such as the Close Button $msg = GUIGetMsg() If _IsPressed("11") And _IsPressed("1") Then ; CTRL + Left mouse button pressed WinCloseUnderMouse() EndIf;get window title Until $msg = $GUI_EVENT_CLOSE Func WinUnderMouse() $pos= _WinAPI_GetMousePos() $hWnd= _WinAPI_WindowFromPoint($pos) ; Get parent window $phWnd= _WinAPI_GetParent($hWnd) If $phWnd > 0 Then ; Found a parent $hWnd_found= WinGetTitle($phWnd); Else ; Didn't find a parent $hWnd_found= WinGetTitle($hWnd); EndIf Return $hWnd_found EndFunc; WinGetUnderMouse Func WinCloseUnderMouse() $hWnd= WinUnderMouse() $rc= MsgBox($MB_YESNOCANCEL, "Verify", "Window Title: " & @CRLF & WinGetTitle($hWnd) & @CRLF & "Close Window, Correct?", 0, $hGui) ; Close the window If $rc = $IDYES Then WinClose($hWnd) EndFunc EDIT: Updated to use handles found to avoid logical error of more then one window title match We could try a process suspend, if you wanted to simply pause the GUI under mouse. Edited July 3, 2017 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker)
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