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 

Help with incrementing Mousemove

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
john tuomi



Joined: 22 May 2006
Posts: 150

PostPosted: Mon Feb 08, 2010 5:53 pm    Post subject: Help with incrementing Mousemove Reply with quote

Hi! I'm trying to write a script that will move my mouse incrementally along a menu. This is used to identify scanned pages in order. What I need for the script to do is to first move to a slider to a particular position on the screen, then move left to select the proper entry, and save this mouse position for future reference (this part I already have completed).

Script #2 is where I am having a problem. What I need script #2 to do is to return to the saved mouseposition plus 1 position lower on the screen. The starting position will vary depending upon what location was set in script one, but the distance between page 1 & page 2 will always be the same.

This is what I have come up with so far:
Code:
^8::
Mouseclickdrag,l,233,234,233,287
Mousemove,54,374
Mouseclick,l,54,374
mousegetpos,mX, mY
return

F1::
Mousemove,%mx%,%mY%
mouseclick,l,%mX%,%mY%
mousemove,%mx+1%,%my%
return


The first part works, but I can't get the second part to work. Any ideas?
Back to top
View user's profile Send private message
OceanMachine



Joined: 15 Oct 2007
Posts: 780
Location: England

PostPosted: Mon Feb 08, 2010 6:21 pm    Post subject: Re: Help with incrementing Mousemove Reply with quote

john tuomi wrote:

This is what I have come up with so far:
Code:
^8::
Mouseclickdrag,l,233,234,233,287
Mousemove,54,374
Mouseclick,l,54,374
mousegetpos,mX, mY
return

F1::
Mousemove,%mx%,%mY%
mouseclick,l,%mX%,%mY%
mousemove,%mx+1%,%my%
return


Not quite sure what you are trying to do - surely mX is always going to be 54 and mY is always going to be 374? (unless you haven't triggered the "^8" hotkey first, in which case they will be blank)

Anyway, you want to move to "1 position lower on the screen", then you will have to move in the Y direction, no? Probably more than 1 aswell, because this will be 1 pixel. So let's use 10 pixels:

Code:
^8::
Mouseclickdrag,l,233,234,233,287
Mousemove, 54, 374
Click, 54, 374
mousegetpos,mX, mY ; If you are moving the mouse to 54, 374 before doing this, then surely mx will always be 54 and my will always be 374...?
return

F1::
Mousemove,%mx%,%mY%
Click, %mX%,%mY%
mousemove, %mx%, % my + 10 ; change the 10 to be more or less depending on how far you want it to move down
return
Back to top
View user's profile Send private message
john tuomi



Joined: 22 May 2006
Posts: 150

PostPosted: Mon Feb 08, 2010 6:29 pm    Post subject: Reply with quote

Thanks, I appreciate the help. In testing my original script, it occurred to me that a loop might be more efficient.

For example, pressing ^8 would scroll the screen, and select the first numbered page for that particular scanned image set. Pressing ^8 would trigger the script to scroll the screen, and move to the last selected page plus however many pixels lower on the screen necessary to select the next page.

Each successive press of the ^8 would then duplicate all of the necessary motions to select the next page.
Back to top
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 5336
Location: San Diego, California

PostPosted: Mon Feb 08, 2010 6:31 pm    Post subject: Reply with quote

Hi john tuomi,

I had the same problem, not quite understanding when to use the %%

http://www.autohotkey.com/docs/commands/MouseMove.htm

"X/Y The x/y coordinates to move the mouse to, which can be expressions. "
Code:

F1::
Mousemove,%mx%,%mY%
mouseclick,l,%mX%,%mY%
mousemove,mx+1,my            ; <-------- see the correction here
return


Please read up on how Ahk evaluates expressions.
http://www.autohotkey.com/docs/Variables.htm

Edit: oops, missed the 'lower' statement
The above line should be
Code:
mousemove,mx,my+1            ; <-------- see the correction here
Back to top
View user's profile Send private message
OceanMachine



Joined: 15 Oct 2007
Posts: 780
Location: England

PostPosted: Mon Feb 08, 2010 6:46 pm    Post subject: Reply with quote

Ah of course, you don't actually need the % around the var in this one as it is a "can be expressions" command, although my code works too Smile
Back to top
View user's profile Send private message
R3TR0



Joined: 26 Aug 2009
Posts: 38
Location: Canada

PostPosted: Mon Feb 08, 2010 11:40 pm    Post subject: Reply with quote

Code:


#InstallMouseHook
x = 20
y = 20
f = 10
z::Reload
~Mbutton::
While GetKeyState("MButton")
{
x := x+y
mouseclickdrag,left,,,x,0,f,r
mouseclickdrag,left,,,0,x,f,r
x := x+y
mouseclickdrag,left,,,-x,0,f,r
mouseclickdrag,left,,,0,-x,f,r
}


change x or y's value at the top of the script to make larger or smaller squares change f to increase or decrese speed.
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
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