MattH Posted September 20, 2007 Posted September 20, 2007 I understand how to capture return information from the controls that I create in a GUI. What I can't figure out is how to get "return" information from a control in another application. Specifically, I have a program that has an OK and Cancel button on it. I want to be able to know when those are pressed by the user. This is not a program I wrote so I can't get inside it. The Au3Info tool shows me that the controls are called Button1 and Button2. Sending a click is no problem, but I want to know when a click is received. Is that possible?
JBeef Posted September 20, 2007 Posted September 20, 2007 get hwnd button (ControlGetHandle). get mousehook. compare hwnd mousehook to hwnd of you. no resources, only high level idea. ~Jap
JBeef Posted September 20, 2007 Posted September 20, 2007 fine. i have no faith of you. run this and it tell you if Cancel of "Run" window clicked. need hook.dll provided expandcollapse popupConst $WH_MOUSE = 7 Const $WM_AUTOITLBUTTONDOWN = 0x1400 + 0x0A30 $gui = GUICreate("test") Global $DLLinst = DLLCall("kernel32.dll","hwnd","LoadLibrary","str",".\hook.dll") Global $mouseHOOKproc = DLLCall("kernel32.dll","hwnd","GetProcAddress","hwnd",$DLLInst[0],"str","MouseProc") Global $hhMouse = DLLCall("user32.dll","hwnd","SetWindowsHookEx","int",$WH_MOUSE, _ "hwnd",$mouseHOOKproc[0],"hwnd",$DLLinst[0],"int",0) DLLCall(".\hook.dll","int","SetValuesMouse","hwnd",$gui,"hwnd",$hhMouse[0]) GUIRegisterMsg($WM_AUTOITLBUTTONDOWN,"myfunc") Send("#r") WinWait("Run") Global $smellyHWND = ControlGetHandle("Run","","Cancel") Global $t = TimerInit() Sleep(250) While WinExists("Run") $msg = GUIGetMsg() If $msg = -3 Then ExitLoop ToolTip("click Cancel on Run window") If TimerDiff($t) < 250 Then Sleep(1000) Exit EndIf WEnd Func MyFunc($hWndGUI, $MsgID, $WParam, $LParam) If HWnd($WParam) = $smellyHWND Then ToolTip("Run / Cancel clicked") $t = TimerInit() EndIf EndFunc Func OnAutoItExit() DLLCall("user32.dll","int","UnhookWindowsHookEx","hwnd",$hhMouse[0]) DLLCall("kernel32.dll","int","FreeLibrary","hwnd",$DLLinst[0]) EndFunchook.dll
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