grimmlock Posted April 30, 2013 Share Posted April 30, 2013 Good Afternoon, I am trying to have a msgbox pop up when a user presses the saved button in an specific application. I can provide screenshot if you need some. The only thing I am missing how to get Autoitscript to pick up on the fact that the save button is pressed. I have tried searching the web and the only thing that I can find is the ControlClick function. I have tried this but I am not sure what the ControlID should be. Anyone got any ideas? Thanks Grimm Thanks Grimm Link to comment Share on other sites More sharing options...
jdelaney Posted April 30, 2013 Share Posted April 30, 2013 (edited) Is this a window application? (need to use the actual handle of the button...returned from ControlGetHandle)...added a sleep before the message box, or sometimes, the application doesn't register the click #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> $iYourControlIdentifier = 15212 $hwnd = WinGetHandle("User") $hControl = ControlGetHandle($hwnd, "", $iYourControlIdentifier if IsHWnd($hControl) then ConsoleWrite("ready" & @CRLF) Else MsgBox(1,1,"need to get the control handle correctly") Exit EndIf While IsHWnd($hControl) $value = _GUICtrlButton_GetState($hControl) If BitAND($value, $BST_PUSHED) Then While True $value = _GUICtrlButton_GetState($hControl) If Not BitAND($value, $BST_PUSHED) Then ExitLoop WEnd MsgBox(1,1,"clicked") ;~ ExitLoop EndIf $hControl = ControlGetHandle($hwnd, "", $iYourControlIdentifier) WEnd edit: added another loop to wait for the click to terminate...else the window can become deadlocked by the messagebox. Edited April 30, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
grimmlock Posted May 2, 2013 Author Share Posted May 2, 2013 Sorry for the delay, Yes this is a windows application. I am not sure how to use ControlGetHandle to get the controlhandle. Any thoughts? Thanks Grimm Thanks Grimm Link to comment Share on other sites More sharing options...
jdelaney Posted May 2, 2013 Share Posted May 2, 2013 Use the autoit window info tool...throw the corsair over the button...navigate to the 'control tab', and send back the output IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
grimmlock Posted May 3, 2013 Author Share Posted May 3, 2013 I opened the Window Info tool and used the Finder Tool to select the toolbar that has the save button, Here is the data from the Control Tab Class: ToolbarWindow32 Instance: 1 ClassnameNN: ToolbarWindow321 Name: Advanced Mode: [CLASS:ToolbarWindow32; INSTANCE:1] ID: 59392 Text: Position: 0, 0 Size: 756, 47 ControlClick Coords: 134, 28 Style: 0x5400004E ExSyle: 0x00000000 Handle: 0x000E0558 Thanks for your help Grimm Thanks Grimm Link to comment Share on other sites More sharing options...
jdelaney Posted May 3, 2013 Share Posted May 3, 2013 replace$iYourControlIdentifier = 15212 with$iYourControlIdentifier = 59392and $hwnd = WinGetHandle("User") replace "user" with the title of your application. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
grimmlock Posted May 3, 2013 Author Share Posted May 3, 2013 Awesome thank you However for some odd reason nothing happen when I press the Save Button But if I do not have the specific application window open then I get the message "need to get the control handle correctly" Any ideas? Thanks Grimm Thanks Grimm Link to comment Share on other sites More sharing options...
jdelaney Posted May 3, 2013 Share Posted May 3, 2013 (edited) Under:$hwnd = WinGetHandle("User")Add error handling$hwnd = WinGetHandle("Your window title") If IsHwnd($hwnd) Then ConsoleWrite("Found window with hwnd=" & $hwnd & @CRLF) MsgBox(1,1,"verify HWND=[" & $hwnd & "] matches autoit info tool") Else ConsoleWrite("UNABLE to find window handle...you are not using the correct title, or window is not found" & @CRLF) EndIfsend back the output...if the window is found, verify the hwnd matches the actual windows hwnd (use the autoit info tools)post back your full script, with modifications, as well Edited May 3, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
grimmlock Posted May 3, 2013 Author Share Posted May 3, 2013 Here is what I got. Thanks Grimm Thanks Grimm Link to comment Share on other sites More sharing options...
jdelaney Posted May 3, 2013 Share Posted May 3, 2013 (edited) and...did you verify it Edited May 3, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
grimmlock Posted May 3, 2013 Author Share Posted May 3, 2013 I need to compare it to the handle value in the Window Info Tool correct? Thanks Grimm Thanks Grimm Link to comment Share on other sites More sharing options...
jdelaney Posted May 3, 2013 Share Posted May 3, 2013 Yes...first step: verify you find the proper window. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
grimmlock Posted May 3, 2013 Author Share Posted May 3, 2013 Screenshot of Window Info Tool... Thanks Grimm Thanks Grimm Link to comment Share on other sites More sharing options...
jdelaney Posted May 3, 2013 Share Posted May 3, 2013 So, you grabbed the wrong window in the script...and you didn't post your code, so I can't really help you. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
grimmlock Posted May 3, 2013 Author Share Posted May 3, 2013 (edited) Sorry Here is the code: #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> $iYourControlIdentifier = 15212 $hwnd = WinGetHandle("Administration Explorer - System - ") If IsHwnd($hwnd) Then ConsoleWrite("Found window with hwnd=" & $hwnd & @CRLF) MsgBox(1,1,"verify HWND=[" & $hwnd & "] matches autoit info tool") Else ConsoleWrite("UNABLE to find window handle...you are not using the correct title, or window is not found" & @CRLF) EndIf $hControl = ControlGetHandle($hwnd, "", $iYourControlIdentifier) if IsHWnd($hControl) then ConsoleWrite("ready" & @CRLF) Else MsgBox(1,1,"need to get the control handle correctly") Exit EndIf While IsHWnd($hControl) $value = _GUICtrlButton_GetState($hControl) If BitAND($value, $BST_PUSHED) Then While True $value = _GUICtrlButton_GetState($hControl) If Not BitAND($value, $BST_PUSHED) Then ExitLoop WEnd MsgBox(1,1,"clicked") ;~ ExitLoop EndIf $hControl = ControlGetHandle($hwnd, "", $iYourControlIdentifier) WEnd Thanks Grimm Edited May 3, 2013 by grimmlock Thanks Grimm Link to comment Share on other sites More sharing options...
jdelaney Posted May 3, 2013 Share Posted May 3, 2013 Why do you have the appended " -" at the end of the title? The info tools doesn't display that...cut that off:$hwnd = WinGetHandle("Administration Explorer - System") reapeat step 9 and 12 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
grimmlock Posted May 3, 2013 Author Share Posted May 3, 2013 I had to cut the rest off as it contains sensitive information. But I can assure you that the $hwnd = WinGetHandle("...") exactly matches the title of the window. Thanks Grimm Thanks Grimm Link to comment Share on other sites More sharing options...
grimmlock Posted May 3, 2013 Author Share Posted May 3, 2013 My bad.... I made a mistake with the code that I posted a little earlier Here is the corrected code: $iYourControlIdentifier = 59392 $hwnd = WinGetHandle("Administration Explorer - System - ") If IsHwnd($hwnd) Then ConsoleWrite("Found window with hwnd=" & $hwnd & @CRLF) MsgBox(1,1,"verify HWND=[" & $hwnd & "] matches autoit info tool") Else ConsoleWrite("UNABLE to find window handle...you are not using the correct title, or window is not found" & @CRLF) EndIf $hControl = ControlGetHandle($hwnd, "", $iYourControlIdentifier) if IsHWnd($hControl) then ConsoleWrite("ready" & @CRLF) Else MsgBox(1,1,"need to get the control handle correctly") Exit EndIf While IsHWnd($hControl) $value = _GUICtrlButton_GetState($hControl) If BitAND($value, $BST_PUSHED) Then While True $value = _GUICtrlButton_GetState($hControl) If Not BitAND($value, $BST_PUSHED) Then ExitLoop WEnd MsgBox(1,1,"clicked") ;~ ExitLoop EndIf $hControl = ControlGetHandle($hwnd, "", $iYourControlIdentifier) WEnd it gives me the correct WinGetHandle now but the "clicked" msgbox does not come up. Sorry for all the confusion. Thanks Grimm Thanks Grimm Link to comment Share on other sites More sharing options...
jdelaney Posted May 3, 2013 Share Posted May 3, 2013 Use the same title in WinList, it outputs an array...on the output, use _arraydisplay...tell me multiple windows are returned. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
jdelaney Posted May 3, 2013 Share Posted May 3, 2013 (edited) $value = _GUICtrlButton_GetState($hControl)Do a consolewrite on the $value...if it's 0, then autoit can't read the state of the control Edited May 3, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. 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