AutoHotkey Community

It is currently May 27th, 2012, 2:23 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: February 8th, 2010, 6:53 pm 
Offline

Joined: May 22nd, 2006, 2:12 pm
Posts: 150
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?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 8th, 2010, 7:21 pm 
Offline

Joined: October 15th, 2007, 3:10 pm
Posts: 790
Location: England
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 7:29 pm 
Offline

Joined: May 22nd, 2006, 2:12 pm
Posts: 150
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 7:31 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 7:46 pm 
Offline

Joined: October 15th, 2007, 3:10 pm
Posts: 790
Location: England
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 :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 12:40 am 
Offline

Joined: August 26th, 2009, 11:15 pm
Posts: 38
Location: Canada
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.

_________________
Image


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, Bing [Bot], Google [Bot], LazyMan, rbrtryn and 23 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