Kruxe Posted February 23, 2020 Posted February 23, 2020 Hi All, i was wondering if there is a way to know when a button is clicked by using its handle? I have an application I am monitoring and want my script to fire when a specific button is clicked. i can retrieve the buttons handle buy using ControlGetHandle but am having issues figuring what syntax to use to have the script watch for that handle to be used. I have also tried to use _GUICtrlButton_GetState to get the state of the button but this only ever returns a 0. Can anyone guide me in the right direction? Thanks in advanced!
Nine Posted February 23, 2020 Posted February 23, 2020 There is multiple ways to achieve this. But without a basic snippet of your code, it is hard to suggest one solution. Maybe _IsPressed ("01") could be an easy way to detect mouse clicks ? Otherwise, mouse rawinput, or mouse hook ? “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Kruxe Posted February 23, 2020 Author Posted February 23, 2020 Hello Again @Nine bellow is a snippet of the code. Essentially there are 3 scenarios that will trigger the execution of the external app im monitoring. 1st is a keyboard shortcut the second is opening a child window and the third is the one im struggling with because i have to somehow monitor the execution button. I cant just have a mouse click "01" because then any mouse click will trigger the script. what would you suggest? is there anything i can do with ControlGetHandle()? Thanks for your time! Local $control = ("11") Local $Q = ("51") Local $EXECUTE = ControlGetHandle("[CLASS:WilcoxAssociatesIncPC-DMISWndClass]","QuickMeasure","[CLASS:ToolbarWindow32; INSTANCE:5]") While 1 If _IsPressed($control) And _IsPressed($Q) = True Then _CycleStart() ElseIf WinExists("Multiple Execution Wizard") = True Then _CycleStartMulti() ElseIf _IsPressed("01") = true Then _CycleStart() EndIf WEnd
Nine Posted February 23, 2020 Posted February 23, 2020 I made it work with my own GUI, you just need to replace with yours : #include <Misc.au3> #include <WinAPISysWin.au3> Local $hWnd = WinGetHandle("My GUI") Local $EXECUTE = ControlGetHandle($hWnd, "", 3) While True If WinActive ($hWnd) And _IsPressed("01") Then $aPos = MouseGetPos() $tRect = _WinAPI_GetWindowRect($EXECUTE) If $aPos[0] >= DllStructGetData ($tRect,"left") And $aPos[0] <= DllStructGetData ($tRect,"right") And _ $aPos[1] >= DllStructGetData ($tRect,"top") And $aPos[1] <= DllStructGetData ($tRect,"bottom") Then While _IsPressed("01") Sleep (100) WEnd ConsoleWrite ("clicked" & @CRLF) EndIf EndIf Sleep (100) WEnd “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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