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 

Arrow Keys Control Mouse

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



Joined: 01 Nov 2007
Posts: 689

PostPosted: Sun Nov 11, 2007 2:24 am    Post subject: Arrow Keys Control Mouse Reply with quote

im making an autohotkey script to make the Arrow keys move the mouse

(UP=Move Mouse up ect etc)

how would i go about doing this?
a hotkey to move the mouse up?

thanks in advance
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1249
Location: USA

PostPosted: Sun Nov 11, 2007 2:26 am    Post subject: Reply with quote

combination of
SetTimer
getkeystate
mousemove

actually, look at the joystick to mouse script in the help file, it should be able to be modified.
_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1249
Location: USA

PostPosted: Sun Nov 11, 2007 2:27 am    Post subject: Reply with quote

there is also a numpad mouse script (forum or help....don't remember)that would be even better for you.
_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
Fry



Joined: 01 Nov 2007
Posts: 689

PostPosted: Sun Nov 11, 2007 2:33 am    Post subject: Reply with quote

i figured it out but the maximum setting of how fast it goes is 100
and thats REALLY slow is there any other way to move it faster
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1249
Location: USA

PostPosted: Sun Nov 11, 2007 2:37 am    Post subject: Reply with quote

please give example of what you mean
_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
Fry



Joined: 01 Nov 2007
Posts: 689

PostPosted: Sun Nov 11, 2007 2:41 am    Post subject: Reply with quote

this is what i mean its really slow

Left:: MouseMove, 0, 30,100,R
Back to top
View user's profile Send private message
Fry



Joined: 01 Nov 2007
Posts: 689

PostPosted: Sun Nov 11, 2007 2:53 am    Post subject: Reply with quote

Ok its working ....sorta

i press one hotkey and the other will somehow be pressed too
even return didnt work

Code:
#SingleInstance Force
Up:: MouseMove, 0, -350,67,R
return
Down:: MouseMove, 0, 350,67,R
return
Left:: MouseMove, -350, 0,67,R
return
Right:: MouseMove, 350, 0,67,R
return
Back to top
View user's profile Send private message
Fry



Joined: 01 Nov 2007
Posts: 689

PostPosted: Sun Nov 11, 2007 2:57 am    Post subject: Reply with quote

also it doesnt work like a mouse i want it to be able to move around like a real mouse

not just up down right left
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1249
Location: USA

PostPosted: Sun Nov 11, 2007 3:01 am    Post subject: Reply with quote

Code:
SetBatchLines -1
IncrementValue = 5
MouseDelay = 0
Left::
Right::
Up::
Down::
Loop,
{
If (A_ThisHotkey = "Down")
   xVal := 0, yVal := IncrementValue
If (A_ThisHotkey = "Up")
   xVal := 0, yVal = -IncrementValue
If (A_ThisHotkey = "Left")
   xVal := -IncrementValue, yVal = 0
If (A_ThisHotkey = "Right")
   xVal := IncrementValue, yVal = 0
If GetKeyState(A_ThisHotKey, "P")
   MouseMove, %xVal%, %yVal%,%MouseDelay%,R
Else
   Break
}
return



Esc::ExitApp

_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
Fry



Joined: 01 Nov 2007
Posts: 689

PostPosted: Sun Nov 11, 2007 3:04 am    Post subject: Reply with quote

THX!

alot
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1249
Location: USA

PostPosted: Sun Nov 11, 2007 4:19 am    Post subject: Reply with quote

This is a little bit better, it moves faster the longer you hold down the key.
Edit:
-Toggle On/Off via capslock.
-can move diagonally by pressing 2 keys.

Code:
SetBatchLines -1
#UseHook
Increment = 1 ; number of pixels to move mouse....gets multiplied depending on keypress length
MouseDelay = 0

Left::
Right::
Up::
Down::
xVal=
yVal=
If GetKeyState("CapsLock","T")
   {
      IncrementValue := Increment ; Set the Increment value (we change it)
      ; Infinite loop....breaks when key not pressed anymore
      Loop,
      {
      If (A_Index > IncrementValue * 15) and (IncrementValue < Increment * 5) ; Increase the Increment value depending on how long we held down the key
         IncrementValue := IncrementValue * 2
      If GetKeyState("Down", "P")
         yVal := IncrementValue
      Else If GetKeyState("Up", "P")
         yVal := -IncrementValue
      If !yVal
         yVal := 0
      If GetKeyState("Left", "P")
         xVal := -IncrementValue
      Else If GetKeyState("Right", "P")
         xVal := IncrementValue
      If !xVal
         xVal := 0
      If GetKeyState(A_ThisHotKey, "P") ; Make sure we are still pressing the key
         MouseMove, %xVal%, %yVal%,%MouseDelay%,R
      Else ; we're not pressing the key...break the loop
         Break
      }
   }
Else
   Send % "{" . A_ThisHotKey . "}"
return

Esc::ExitApp


_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
HuBa



Joined: 24 Feb 2007
Posts: 172
Location: Budapest, Hungary

PostPosted: Sun Dec 16, 2007 5:37 pm    Post subject: Reply with quote

Nice script.

Just a little optimization: I think you can remove the xVal= and yVal= lines from the beginning of the script.
Back to top
View user's profile Send private message Visit poster's website
me123
Guest





PostPosted: Wed Sep 24, 2008 3:17 am    Post subject: why wont this script work if im using the send command Reply with quote

im running a wirnlirc script and i want to use the remote keys to move the mouse

i love your script but it only works when using my keyboard but a send command doesn't

any help is greatly appreciated
Back to top
Bigrob55



Joined: 24 Sep 2007
Posts: 37

PostPosted: Sat Nov 29, 2008 10:23 pm    Post subject: Reply with quote

VERY NICE!!!!!

Gotta love the diagonal move movement! Very Happy
_________________
Bigrob

L337 Speak - A Ventrilo Client Side program

Winamp Sound Changer - Change Audio Output on the Fly!
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
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