Jump to content

If Save button is pressed


Recommended Posts

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

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.
Link to comment
Share on other sites

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

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.
Link to comment
Share on other sites

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

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.
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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

$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.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...