AutoHotkey Community

It is currently May 27th, 2012, 10:55 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: December 12th, 2006, 9:30 pm 
Offline

Joined: October 7th, 2005, 9:46 pm
Posts: 13
I need to pull information frequently from a window's edit controls, but the control names are not consistent with each instance of the window. However, the location of the control is constant. I was wondering if someone could kindly suggest a way to get the name of the control (or the information in the control) with the coordinates, without using a mouse function.
Thank you in advance for your help. Great forum, by the way.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2006, 1:01 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Quote:
How to get a Control's ClassNN by coordinates ?
http://www.autohotkey.com/forum/viewtop ... 4327#94327

Case: I want to programatically click 1 four times in the windows Calculator and the ClassNN for 1 was changing every time it was run.

I run the Calculator and check the ClassNN for that particular button with Spy utility to find it as Button7.
Let us try to ascertian the exact coordinates of Button7

Code:
AppWinTitle := "Calculator" ; Make sure Calculator is running & not minimised
ID := WinExist(AppWinTitle)

WinGet, ClassNNList, ControlList, ahk_id %ID%

Loop, PARSE, ClassNNList, `n
  {
    ControlGetPos, X, Y, Width, Height, %A_LoopField%, ahk_id %ID%
    NewList .= A_LoopField . " = " . X . "," . Y . "`n"
  }

StringTrimRight, NewList, NewList, 1
MsgBox, 0, Control List: %AppWinTitle%, %NewList%


    Image

Ah yes! Button7 is located @ 57,179

Now, lets see on how to programatically retrieve the ClassNN of a control that is located @ 57,179 and click it four times.

Code:
AppWinTitle := "Calculator" ; Make sure the file is open
ID := WinExist(AppWinTitle)
WinGet, ClassNNList, ControlList, ahk_id %ID%

Loop, PARSE, ClassNNList, `n
  {
    ControlGetPos, X, Y, Width, Height, %A_LoopField%, ahk_id %ID%
    If ( X=57 AND Y=179 ) {
                            ClassNN := A_LoopField
                            Break
                          }
  }

MsgBox, % ClassNN ; Got the Control's ClassNN

Loop 4 ; Key in the amount = 1111
  ControlClick , %ClassNN%, ahk_id %ID%


That is it ....

However, I noticed that:
Control positions are slightly different when Calculator is minimised.
ControlGetPos does not work when Calculator is minimised.
Calculator's control never change its ClassNN .. :wink: ( I used Calculator as an example )

Thanks to those who read this patiently.

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2006, 6:30 pm 
Offline

Joined: October 7th, 2005, 9:46 pm
Posts: 13
Thank you for the help!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: HotkeyStick and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group