Jump to content
Sign in to follow this  
vela

On desktop and select an option

Recommended Posts

vela

Hey folks,

I am trying to create a script that will right click on a field in an application and then select an option from the list that pops up. Using the GUI, I can right click the correct field, but I cannot get the script to select an option from the popup. The AutoIt Windows Info tool, shows no content when I highlight this popup (except a handle). How can I get that handle without having the title, text, or controlID of the popup?

Thanks,

Vela Systems QA Intern

P.S. I have attached a screen shot if you can't understand what I mean

post-50843-1245266941_thumb.jpg

Share this post


Link to post
Share on other sites
dantay9

If you know the placement of the button you want to click, you can just use MouseGetPos() to find out where the right click took place. Then do MouseClick(). The x position is a certain amount of pixels right of the right click and the y position is a certain amount of pixels down from the right click position.

Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites
vela

If you know the placement of the button you want to click, you can just use MouseGetPos() to find out where the right click took place. Then do MouseClick(). The x position is a certain amount of pixels right of the right click and the y position is a certain amount of pixels down from the right click position.

Thank you for the suggestion. Unfortunately this script is going to be used by different people on different machines, so the window may not always be in the same place (making the mouse coords incorrect).

I appreciate the post though!

Share this post


Link to post
Share on other sites
PieMan

Have you tried using the send() function? send a left arrow key etc to select the correct field? Its not the best way to do it but it works....

Share this post


Link to post
Share on other sites
electrico

Firstly, you can define your mouse coordinates, (screen resolution, in pixels must be same as in the pc where you made this script). Run This script and see what coordinates you have when the mouse cursoir is in the right position. And then run again previous script, move it again to the place of the window named "Form designer", define your window position, so mousemove function will not miss then, because WinMove will be used too. You have 3 seconds to move your mouse cursor to the place where right click and window location on the screen is expected.

CODE

Sleep (3000)

$pos = MouseGetPos()

MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])

Then: ( the main code to automate your defined actions )

CODE

WinWaitActive ("Form designer")

WinMove ("Form designer", "", x, y) ; write the values that you got from previous codebox, accordingly.

MouseMove (x,y) ; write the values that you got from previous codebox, accordingly.

MouseClick ("right")

Send ("{RIGHT}")

Send ("{DOWN}") ; if you need to choose first variant of the submenu. If second, so Send down 2 times and so on...

Send ("{Enter}")

Thats should work fine.

Edited by electrico

Share this post


Link to post
Share on other sites
vela

Firstly, you can define your mouse coordinates, (screen resolution, in pixels must be same as in the pc where you made this script). Run This script and see what coordinates you have when the mouse cursoir is in the right position. And then run again previous script, move it again to the place of the window named "Form designer", define your window position, so mousemove function will not miss then, because WinMove will be used too. You have 3 seconds to move your mouse cursor to the place where right click and window location on the screen is expected.

I certainly appreciate the suggestion, and I do think that I will be able to implement it into my code.

However, the other issue is that the variant of the submenu is a parameter that the user will input (ie it changes everytime), and the real kicker is the the submenu is not always the same either. Basically the script needs to be able to take an input parameter and find it on that submenu.

Any suggestions?

Share this post


Link to post
Share on other sites
vela

Interestingly enough each of the submenu's has it's own unique handle and class number. Is there any way to use this class number to get the handle?

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.