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 

Using CoordMode incorrectly? newbie here

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Finitee
Guest





PostPosted: Thu Jul 24, 2008 1:37 am    Post subject: Using CoordMode incorrectly? newbie here Reply with quote

Let first start by saying I am a total newb, but I love the program so far and have made some simple scripts just to have some fun with it. Anyway, I am trying to use CoordMode with mouse clicks to get something to work, though I'm not sure that's the right way to go about it.

I have three windows of exactly the same program of the exact same size. I want to have one open on my screen, and the other two off to the sides where I can't see them. When I click somewhere on the main window, I make want to make AHK do a click command, wait one sec, switch to another one of the programs, and click the same spot relative to the first window. For example, if I click on the upper right of the first window, I'd have it click there, wait a sec, switch over to the second window, and it would click on the upper right of that one. I attempted to use this script, but I got an error:

MouseClick
Sleep 1000
IfWinExist Window A
{
WinActivate
CoordMode, Relative
MouseClick
}
Sleep 1000
IfWinExist Window B
{
WinActivate
CoordMode, Relative
MouseClick
}

Can anyone offer any advice? I think part of it is I'm just using CoordMode completely wrong, or maybe I'm just misunderstanding it entirely. Any help would be appreciated.
Back to top
infinitee
Guest





PostPosted: Thu Jul 24, 2008 1:48 am    Post subject: Reply with quote

If no one knows directly, if anyone has any information on the correct way to use CoordMode, Relative, that'd be a great help.
Back to top
Krogdor



Joined: 18 Apr 2008
Posts: 935
Location: The Interwebs

PostPosted: Thu Jul 24, 2008 1:51 am    Post subject: Reply with quote

If you don't give MouseClick any parameters, it will just click wherever the cursor is... Try something like this:

Code:
MouseGetPos, X, Y
Click, %X%, %Y%
Sleep 1000
IfWinExist Window A
{
WinActivate
Click, %X%, %Y%
}
Sleep 1000
IfWinExist Window B
{
WinActivate
Click, %X%, %Y%
}


CoordMode is relative by default, so there is no need to specify that.
Back to top
View user's profile Send private message AIM Address
infinitee
Guest





PostPosted: Thu Jul 24, 2008 2:16 am    Post subject: Reply with quote

Worked perfectly, I didn't even realize I could leave X and Y as just X and Y- I thought they required actual numbers. Exactly what I needed, thanks Very Happy
Back to top
Krogdor



Joined: 18 Apr 2008
Posts: 935
Location: The Interwebs

PostPosted: Thu Jul 24, 2008 3:33 am    Post subject: Reply with quote

infinitee wrote:
Worked perfectly, I didn't even realize I could leave X and Y as just X and Y- I thought they required actual numbers. Exactly what I needed, thanks Very Happy


It only works because MouseGetPos stored the position of the mouse in the variables "X" and "Y", and then I use those variables to pass the position to Click.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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