Jump to content
Sign in to follow this  
boogieoompa

Find String Location on Screen

Recommended Posts

boogieoompa

I am new to AutoIt and I must say I am VERY, VERY impressed however I have one problem (at the moment) that I can't seem to figure out.

I want to find the x,y corrdinates of a string (it only appears once per form). This particular string happens to be on a button however if this makes things easier. Effectivly I would like to extract the X,Y values and then add a number to X since the object that I am looking for is always located a fixed distance from this button however the object changes so often that I would be impossible for me to script the action to the object itself.

Any help would be great

Thanks

Share this post


Link to post
Share on other sites
GaryFrost

try using the AutoIt Window Info tool to get the control id

for exampel "Button1"

then use ControlGetPos ( "title", "text", controlID )

to get the x, y coords of the button

these are in the help.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
boogieoompa

Thanks but I seem to be having a problem

$pos = ControlGetPos("Form", "", "button1")
MsgBox(0, "Window Stats:", "POS: " & $pos[0] & "," $pos[1] & " SIZE: " & $pos[2] & "," & $pos[3] )

I get an error

"Subscript used with non array variable"

Shouldn't $pos be assigned as an array variable when it is defined as being equal to a function with 2 numbers?

Share this post


Link to post
Share on other sites
buzz44

$Pos[0] and $Pos[1] will only exist if there isn't an error with the function.

Try this...

$pos = ControlGetPos("Form", "", "button1")
If Not @Error Then
   MsgBox(0, "Window Stats:", "POS: " & $pos[0] & "," $pos[1] & " SIZE: " & $pos[2] & "," & $pos[3] )
Else
   Msgbox(0,"Error!", "@Error = " & @Error)
EndIf

qq

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.