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 

Mouse Jog buttons

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
RG



Joined: 09 Feb 2005
Posts: 17
Location: United States

PostPosted: Tue Oct 25, 2005 8:14 pm    Post subject: Mouse Jog buttons Reply with quote

I wrote this script to allow me to 'jog' the mouse pointer by 1 or 10 pixels in any of the 4 directions. This makes minute selecting much easier (my mouse is so touchy that it jumps between pixels sometimes.

However, I have a problem: if the mouse button is held down, the script doesn't work properly. The Left keyboard key has no effect, and the right, down, and up keys cause the mouse to move in both the X and Y directions.

Please make suggestions and improvements.

It would also be nice to have the Left or Right mouse button activate this hotkey, rather than having to hold down the Ctrl and Alt buttons. That way, any time the button is held down, these keys are active.

Here's the script:

Code:

;Mouse Jog buttons

;While holding ctrl and alt, press the arrow keys to move the mouse
^!Left::MouseMove,-1,0,0,R
^!Right:: MouseMove,1,0,0,R
^!Up:: MouseMove,0,-1,0,R
^!Down:: MouseMove,0,1,0,R

;Hold down SHIFT to move 10 pixels at a time.
+^!Left::MouseMove,-10,0,0,R
+^!Right:: MouseMove,10,0,0,R
+^!Up:: MouseMove,0,-10,0,R
+^!Down:: MouseMove,0,10,0,R     


Thanks to everyone!
_________________
RG
Back to top
View user's profile Send private message
RG



Joined: 09 Feb 2005
Posts: 17
Location: United States

PostPosted: Tue Oct 25, 2005 8:16 pm    Post subject: Solved one problem Reply with quote

OK. I solved the problem of the LEFT key not working. I added the ~ onto the beginning of each line, as follows:

Code:

;Mouse Jog buttons

;While holding ctrl and alt, press the arrow keys to move the mouse
~^!Left::MouseMove,-1,0,0,R
~^!Right:: MouseMove,1,0,0,R
~^!Up:: MouseMove,0,-1,0,R
~^!Down:: MouseMove,0,1,0,R

;Hold down SHIFT to move 10 pixels at a time.
~+^!Left::MouseMove,-10,0,0,R
~+^!Right:: MouseMove,10,0,0,R
~+^!Up:: MouseMove,0,-10,0,R
~+^!Down:: MouseMove,0,10,0,R     


Works great now, except I don't like to have to hold down CTRL and ALT to make the hotkeys work.... Gotta figure out a better hotkey...
_________________
RG
Back to top
View user's profile Send private message
RG



Joined: 09 Feb 2005
Posts: 17
Location: United States

PostPosted: Tue Oct 25, 2005 8:50 pm    Post subject: The finished script Reply with quote

OK everyone, here's the finished script.
I decided to use the ScrollLock button to activate/deactivate the mouse keys.

Press Scroll Lock to turn these keys on/off.

Hold down Alt, Ctrl, and/or Shift to change the amount of movement.

Use the Up/Down/Left/Right keys to move the mouse cursor.

Have fun!

Code:

;Mouse Jog buttons
;Turn on Scroll Lock to turn on mouse buttons.  Use Up, Down, Left, & Right keys to move
; mouse pointer.  Hold down CTRL, Alt, and/or Shift to affect the amount of movement per keypress.
;Script by RG/2005
;www.AutoHotkey.com forum member

;While holding ctrl and alt, press the arrow keys to move the mouse
$*Left::
{
   ;Abort if ScrollLock not on.
   if GetKeyState("Scrolllock", "T") = false
   {
      Send,{Left}
      return
   }

   ;Determine distance to move mouse
   
   move := -1   ;Initial distance to move.
   
   if GetKeyState("Shift", "P") = true
      move := move * 2   ;2x

   if GetKeyState("Alt", "P") = true
      move := move * 5   ;5x

   if GetKeyState("Ctrl", "P") = true
      move := move * 10   ;10x


   ;Send the mousemove event.   
   MouseMove,move,0,0,R

   return
}

$*Right::
{
   ;Abort if ScrollLock not on.
   if GetKeyState("Scrolllock", "T") = false
   {
      Send,{Right}
      return
   }

   ;Determine distance to move mouse
   
   move := 1   ;Initial distance to move.
   
   if GetKeyState("Shift", "P") = true
      move := move * 2   ;2x

   if GetKeyState("Alt", "P") = true
      move := move * 5   ;5x

   if GetKeyState("Ctrl", "P") = true
      move := move * 10   ;10x


   ;Send the mousemove event.   
   MouseMove,move,0,0,R

   return
}

$*Up::
{
   ;Abort if ScrollLock not on.
   if GetKeyState("Scrolllock", "T") = false
   {
      Send,{Up}
      return
   }

   ;Determine distance to move mouse
   
   move := -1   ;Initial distance to move.
   
   if GetKeyState("Shift", "P") = true
      move := move * 2   ;2x

   if GetKeyState("Alt", "P") = true
      move := move * 5   ;5x

   if GetKeyState("Ctrl", "P") = true
      move := move * 10   ;10x


   ;Send the mousemove event.   
   MouseMove,0,move,0,R

   return
}
$*Down::
{
   ;Abort if ScrollLock not on.
   if GetKeyState("Scrolllock", "T") = false
   {
      Send,{Down}
      return
   }

   ;Determine distance to move mouse
   
   move := 1   ;Initial distance to move.
   
   if GetKeyState("Shift", "P") = true
      move := move * 2   ;2x

   if GetKeyState("Alt", "P") = true
      move := move * 5   ;5x

   if GetKeyState("Ctrl", "P") = true
      move := move * 10   ;10x


   ;Send the mousemove event.   
   MouseMove,0,move,0,R

   return
}



SUGGESTIONS WELCOME!!!
_________________
RG
Back to top
View user's profile Send private message
shimanov



Joined: 25 Sep 2005
Posts: 610

PostPosted: Tue Oct 25, 2005 9:21 pm    Post subject: Reply with quote

Here is an alternative implementation. It uses the, mostly useless, Pause button to trigger state transitions.

Code:
mouse_jog_delta = 0

mouse_jog_delta[0] = 1
mouse_jog_delta[1] = 5
mouse_jog_delta[5] = 10
mouse_jog_delta[10] = 20
mouse_jog_delta[20] = 40
mouse_jog_delta[40] = 0

Gosub, Show_MouseJog_Status
return

Show_MouseJog_Status:
   if ( mouse_jog_delta = 0 )
      text = (inactive)
   else
      text = (active)

   TrayTip, Mouse Jogger, mouse_jog_delta = %mouse_jog_delta% %text%, 10, 1
return

Pause::
   if ( mouse_jog_delta = 0 )
   {
      mouse_jog_delta := mouse_jog_delta[%mouse_jog_delta%]

      Hotkey, Left, hk_mouse_jog_buttons, on
      Hotkey, Up, hk_mouse_jog_buttons, on
      Hotkey, Right, hk_mouse_jog_buttons, on
      Hotkey, Down, hk_mouse_jog_buttons, on
   }
   else
      mouse_jog_delta := mouse_jog_delta[%mouse_jog_delta%]
   
   if ( mouse_jog_delta = 0 )
   {
      Hotkey, Left, off
      Hotkey, Up, off
      Hotkey, Right, off
      Hotkey, Down, off
   }

   Gosub, Show_MouseJog_Status
return

hk_mouse_jog_buttons:
   x_delta = 0
   y_delta = 0

   if ( A_ThisHotkey = "Left" )
      x_delta := -1*mouse_jog_delta
   else if ( A_ThisHotkey = "Up" )
      y_delta := -1*mouse_jog_delta
   else if ( A_ThisHotkey = "Right" )
      x_delta := mouse_jog_delta
   else if ( A_ThisHotkey = "Down" )
      y_delta := mouse_jog_delta

   MouseMove, x_delta, y_delta, 0, R
return
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions 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