Sign in to follow this  
Followers 0
apt1706

How to record a button click action using AutoIT

9 posts in this topic

Hi,

I have a java applet window on which i have two button. Without using the mouse coordinate, is there a way i can identify these button using AutoIT script and click the button as need? Two button do not have hard keys so i am unable to use my keyboard while recording the script.

Mouse coordinate are really tough to handle as the window is not at one position everytime it pop's up.

Appreciate your advice.

Thanks in advance.

Share this post


Link to post
Share on other sites



With just what you told us, I would say take a look at WinActivate and WinGetPos. If the button is always at the same location within the popup window, you should be able to add a certain amount of pixels to the WinGetPos coordinates to click the button.

1 person likes this

RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites

You might also be able to use the AutoIT Window Info application that comes bundled with AutoIT to find the "Class" of the button, then use that info in the "ControlClick" method

Share this post


Link to post
Share on other sites

Thanks for your reply. Below is my code which i have used. First i click on the Browse Button on the popup window to select a file ( i used keyboard function to click the browser button, as the Browse button has shortcut key). As soon as i select the file two other button get enabled, however as the buttons do not have Shortcut key, i am using mouse coordinates. Both the buttons which get enabled on the popup window are always at the same location. Can you please advice, where and how i need to use the WinGetPos? I am new to AutoIT so i am not very clear on how the function. Appreciate your help.

WinWait ("Test Window","")

Sleep(10000)

WinActivate("Test Window","")

Send("{TAB}{ALTDOWN}b{ALTUP}")

WinWait ("Open","")

WinActivate("Open","")

Send("c:documents{SPACE}and{SPACE}settingstest{SPACE}test.doc{TAB}{TAB}{ENTER}")

Sleep(10000)

WinActivate("Test Window","")

Sleep(5000)

MouseMove(660,712)

MouseDown("left")

Sleep(100)

MouseUp("left")

Sleep(1000)

MouseMove(413,764)

MouseDown("left")

Sleep(100)

MouseUp("left")

WinActivate("Confirm","")

Send("{TAB}{ALTDOWN}n{ALTUP}")

Share this post


Link to post
Share on other sites

Look into ControlGetHandle, as well as 'Controls' section in the help file...save yourself headaches of mousemoves and send...as you have coded, the window must be in the same location, and the controls must never move.


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

Hi Abberation

I used the following line of code for WinGetPos in my above mentioned code but i see a an error "Subscript used with non array variable"

$size = WinGetPos("Name of the popup Window", "Button Name on the popup window")

The first parameter passed to the function is the Popup Window Name and the second is the name of the button on the popup window.

Can you pls advice?

Thanks in advance

Share this post


Link to post
Share on other sites

Can someone please advice on my query?

Share this post


Link to post
Share on other sites

Hi Kevinsyle -

I used AutoIT Windows Info to capture the buttons on the window, however it wont capture the button info at all. Under controls i dont see buttons at all in the Window info.

Its displaying the class of whole info for the popup window but not displaying any button related info.

Can you please advice?

Thanks in advance

Share this post


Link to post
Share on other sites

AutoIt Window Info works on windows created with the Windows API. As you are not seeing button info, this is not the case with the application you're trying to interact with. Have you taken a look at the JAVA UDF in the Examples section of the forum? It may offer some direction on what you're trying to do.


√-1 2^3 ∑ π, and it was delicious!

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  
Followers 0