AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Solved] ControlClick - give X & Y to click known contro
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Mon Jun 09, 2008 9:05 pm    Post subject: [Solved] ControlClick - give X & Y to click known contro Reply with quote

I have a Control that appears in different places depending on machine, resolution, etc...


Currently, I have to use

Code:
loop, 12 ; # of users in lobby can vary between 1 and 12ish…
{
  ControlSend, Control3, {Up},Lobby
  Sleep, 1
}

… or something like this to move the highlight bar up to the top row so that I can start scanning highlighted User Names…

In an effort to speed up the script, I’d like to quickly send a ControlClick to the top row of the Control (relative x and y in the control are always the same).

However, it seems that ControlClick takes either a Window Title and Xn Yn relative to the entire window, or a Control and then a button name. My control has no buttons—I simply want to send a click to XAny Y3. Is this possible?


Last edited by CannedCheese on Thu Jun 12, 2008 5:21 am; edited 1 time in total
Back to top
View user's profile Send private message
PurloinedHeart



Joined: 04 Apr 2008
Posts: 209
Location: Canada

PostPosted: Mon Jun 09, 2008 9:46 pm    Post subject: Reply with quote

CoordMode?
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Mon Jun 09, 2008 9:57 pm    Post subject: Reply with quote

Appreciate the response... but I don't think coordmode will help because coordmode, relative will set X & Y relative to the entire window, whereas I want to send a controlclick relative to the specific control. For ease of use and debugging, I'm currently WinMoving the window to 0,0 -- but Control3 can be located in slightly different places depending on Screen Resolution, etc.
Back to top
View user's profile Send private message
pokercurious



Joined: 16 Dec 2007
Posts: 47

PostPosted: Mon Jun 09, 2008 10:20 pm    Post subject: Reply with quote

ControlGetPos
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Mon Jun 09, 2008 11:05 pm    Post subject: Reply with quote

This could help... so something like
Code:

Coordmode, mouse, relative
ControlGetPos,  X, Y,,, Control3, Lobby ; gets X & Y of control relative to Lobby Window
WinActivate, ahk_id%lobby_ID%
SendInput {Click %X%, %Y%}

... would work, maybe?

Is there a way to accomplish this by posting a click without the WinActivate command (I am afraid of interfering with the user who will be moving the mouse, clicking, and typing outside of this window)?

Maybe I need something like...
Code:

Coordmode, mouse, screen
WinGetPos, X1, Y1,,ahk_id %lobby_id%
ControlGetPos,  X, Y,,, Control3, Lobby,,, ; gets X & Y of control relative
X = %X1% + %X%
Y = %Y1% + %Y%
SendInput {Click %X%, %Y%}


Control commands seem to be capable of operating in the background, which is what I would like this to do (as much as possible).
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Mon Jun 09, 2008 11:10 pm    Post subject: Reply with quote

Duh... I should probably be using ControlClick X%x% Y%Y%, ahk_id %lobby_id%

making sure I'm using relative coordinates

instead of SendInput {Click X, Y}
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Tue Jun 10, 2008 12:27 am    Post subject: Reply with quote

is this a web app or some standalone software
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Tue Jun 10, 2008 1:03 am    Post subject: Reply with quote

Its stand alone software-- a game lobby. Can't read text so I wrote an imagesearch function that can scrape the (unreadable) user name text once it is highlighted. I'm just trying to shave a second off the routine-- selecting the initial (top) 20 pixel line would be faster (I think) than ControlSend {up} in a loop, since the software is a bit slow to respond.

There is nothing unique or visible in the control other than its name (Control3), but I'm thinking that I can get the control position relative to the window with ControlGetPos and then use ControlClick. Controls are still very new to me, as is the ability to buffer & balance automated tasks in the background with a user performing simultaneous unrelated tasks as the scripts execute.
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Tue Jun 10, 2008 2:35 am    Post subject: Reply with quote

and what shows as classnn in window spy when you hover mouse over it
_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Tue Jun 10, 2008 4:14 am    Post subject: Reply with quote

Control3...

Code:

loop, 12 ; # of users in lobby can vary between 1 and 12ish…
{
  ControlSend, Control3, {Up},Lobby
  Sleep, 1
}


^ is the same code as I posted in my original post, and it accesses the control correctly (though I hate looping {UP}). I can spy the location of the control as well.

I'm not trying to spy the control's text, as its not viewable anyway (hidden or not), and I had to write a search function to scrape it.

I think I just need to send a
Code:

ControlGetPos, RelX, RelY,,,Control3
RelY++
RelX++
ControlClick, x%X% y%Y%, ahk_id %lobbyID%


Not sure if I need something like...
Code:

CoordMode, Mouse, Screen
WinGet, LobbyID, ID, Lobby
WinGetPos, X, Y,,ahk_id %lobby_id%
ControlX := X + RelX +1
ControlY := Y + RelY + 1
ControlClick, x%ControlX%, Y%ControlY%, ahk_id %lobbyID%


.. or not. I geet confused with relative coordinates-- if I use ControlGetPos, can I just do...
Code:

SetCoordMode, Mouse, Relative
X++
Y++
ControlClick, x%X% y%Y%, ahk_id %lobbyID%

without first activating ahk_id %lobby%

I'll have to experiment. Thanks!
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Tue Jun 10, 2008 5:29 am    Post subject: Reply with quote

Code:

ControlGetPos, RelX, RelY,,,Control3
RelY++
RelX++
ControlClick, x%X% y%Y%, ahk_id %lobbyID%


This seemed to do it. I'm guessing that this is the cleanest way to hit a control without buttons.
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 1033

PostPosted: Tue Jun 10, 2008 1:29 pm    Post subject: Reply with quote

so what happens when you just try this?
Code:
ControlClick, Control3, ahk_id %lobbyID%

_________________
Read this
Com
Automate IE7 with Tabs
Back to top
View user's profile Send private message
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Tue Jun 10, 2008 3:30 pm    Post subject: Reply with quote

I will try, but I think that the default behavior for ControlClick is to click the middle point in the control(?), whereas I need to highlight (by clicking) a 20 pixel line at the top of the control.
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Tue Jun 10, 2008 3:40 pm    Post subject: Reply with quote

why not use the X and Y Options parameters in ControlClick?

Code:

;ControlClick [, Control-or-Pos, WinTitle, WinText, WhichButton, ClickCount, Options, ExcludeTitle, ExcludeText]
ControlClick, Control3, ahk_id %lobbyID%, , , , X20 Y20, ,

_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
CannedCheese



Joined: 21 May 2008
Posts: 85

PostPosted: Tue Jun 10, 2008 4:11 pm    Post subject: Reply with quote

That's what I had initially tried and I'm wondering if I just screwed up the syntax. I'll give it another shot when I get home.
[Edit] Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group