Jump to content


find coordinates of text on screen

  • Please log in to reply
6 replies to this topic

#1 zthaynes



  • Active Members
  • 5 posts

Posted 01 May 2011 - 01:53 AM

Greetings! I am new to this forum, and to AutoIt as well. I have found that the programming seems to be very straight forward, and usually with a little trial and error I can figure out whatever i need to, However...

There is one feature that SHOULD be available, or at least a feasible work around should be available. AutoIt was created to automate windows tasks. There are many programs (especially now) that utilize different methods of interacting with the user, and even if a specific control is not available, there should be a way to identify a specific location on the screen, then allow the program to "click", etc...

That being said, I am continually running into programs that have no set controls, and no keyboard commands. This means the mouse is the only option of I/O. There is a command that allows the program to identify some text from the window... and much of that text is associated with where you need to "click". There is also a command that allows you to see the x,y index of the mouse cursor. What there does not seem to be, is a command that will find a single instance of text, and return the location of that text's coordinates.

I have heavily "googled" this topic, and I have also searched the threads here. One example here ends up providing different solutions for a different problem, and the other seems to rally around an unknown dll file that must be installed on the machine (as well as no clear examples of what to actually do with it to find text).

Does ANYONE know how ( not theory, and not lecture :unsure: ) to locate a word on the screen (that the program already can find) like "SETTINGS" and find it's x,y coordinates so I can move the mouse there, and click.

Any help would be greatly appreciated!

FYI: I know that I could use the recorder or the reader to find the position, and as long as the program is used on this computer, using this screen resolution that would be fine... but any minute differences and I could end up configuring the wrong setting, wiping my hard drive, who knows?

Edited by zthaynes, 01 May 2011 - 01:59 AM.

#2 pieeater



  • Active Members
  • PipPipPip
  • 184 posts

Posted 01 May 2011 - 02:20 AM

u could use ControlClick()

an example:
$gui=GUICreate("example",100,200,500,500)  $input=GUICtrlCreateInput("this is the text",0,0)  $button=GUICtrlCreateButton("this is a button",0,50)  $lable=GUICtrlCreateCheckbox("checkbox",0,100)  $combo=GUICtrlCreateCombo("combo text",0,150)  GUISetState()  While 1     $nMsg=GUIGetMsg()     ControlClick("","",$input)                           ;<===== you can use the variable if you have predefined the control, however it will not work in other programs     ControlClick("","",$button)     ControlClick("","",$lable)     ControlClick("","","[CLASS:ComboBox; INSTANCE:1]")   ;<===== you can use the autoit information tool to figure this out so you can use it outside of your program  WEnd

notice how the gui is looping through clicking the buttons, which is why they are flashing

#3 zthaynes



  • Active Members
  • 5 posts

Posted 01 May 2011 - 03:23 AM

Maybe I didn't explain well enough... I do tend to ramble a bit. One program that I want to automate install is Stardock's Object Dock. to go into settings, you would:
run("c:\program files\stardock\objectdockfree\objectdockui.exe")

Once this program is up, I want to do something like this (!!!I know this isn't how to do it!!!)
;array[2] = x,y coordinates for the text "settings" $xycord[2] = {WinGetText("","Settings")} ;left click the mouse at the coordinates MouseClick("Left",$xycord),2)

I cannot tab through controls, nor can I identify them through the window info tool. There are none, only links embedded into the program. Now... The text "Settings", as well as other commands are shown in the window info tool, so I know there is text to find...

#4 czardas


  • MVPs
  • 7,705 posts

Posted 01 May 2011 - 09:53 AM

If the window is always the same size, then you could use WinGetPos and hardcode the coordinates.

#5 fmen



  • Active Members
  • PipPip
  • 137 posts

Posted 21 November 2012 - 12:22 PM

Searching the forum for the very same question, I came upon this post. Unfortunately, the question remains unresolved.
Any fresh input into a solution would be greatly appreciated by myself and the original poster, I am sure.

#6 MetalOx



  • Normal Members
  • 1 posts

Posted 18 March 2013 - 06:47 PM

I have this exact same question! I've also spent countless hours searching for a solution to this question. I've implemented workarounds, but it would be great to have a straightforward solution!

#7 jdelaney



  • Active Members
  • PipPipPipPipPipPip
  • 2,496 posts

Posted 18 March 2013 - 07:34 PM



Edited by jdelaney, 18 March 2013 - 07:43 PM.

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.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users