Jump to content
Sign in to follow this  
grimmlock

If Save button is pressed

Recommended Posts

grimmlock

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

Share this post


Link to post
Share on other sites
jdelaney

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 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.

Share this post


Link to post
Share on other sites
grimmlock

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

Share this post


Link to post
Share on other sites
jdelaney

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.

Share this post


Link to post
Share on other sites
grimmlock

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

Share this post


Link to post
Share on other sites
jdelaney

replace

$iYourControlIdentifier = 15212

with

$iYourControlIdentifier = 59392

and

$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.

Share this post


Link to post
Share on other sites
grimmlock

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

Share this post


Link to post
Share on other sites
jdelaney

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)
EndIf

send 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 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.

Share this post


Link to post
Share on other sites
grimmlock

Here is what I got.

Thanks

Grimm

post-76479-0-93243400-1367608788_thumb.p


Thanks

Grimm

Share this post


Link to post
Share on other sites
jdelaney

and...did you verify it :)

Edited 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.

Share this post


Link to post
Share on other sites
grimmlock

I need to compare it to the handle value in the Window Info Tool correct?

Thanks

Grimm


Thanks

Grimm

Share this post


Link to post
Share on other sites
jdelaney

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.

Share this post


Link to post
Share on other sites
grimmlock

Screenshot of Window Info Tool...

Thanks

Grimm

post-76479-0-44859900-1367610292_thumb.p


Thanks

Grimm

Share this post


Link to post
Share on other sites
jdelaney

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.

Share this post


Link to post
Share on other sites
grimmlock

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 by grimmlock

Thanks

Grimm

Share this post


Link to post
Share on other sites
jdelaney

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.

Share this post


Link to post
Share on other sites
grimmlock

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

Share this post


Link to post
Share on other sites
grimmlock

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

Share this post


Link to post
Share on other sites
jdelaney

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.

Share this post


Link to post
Share on other sites
jdelaney

$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 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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×