AutoHotkey Community

It is currently May 27th, 2012, 3:26 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Mouse Jog buttons
PostPosted: October 25th, 2005, 9:14 pm 
Offline

Joined: February 9th, 2005, 9:18 pm
Posts: 17
Location: United States
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Solved one problem
PostPosted: October 25th, 2005, 9:16 pm 
Offline

Joined: February 9th, 2005, 9:18 pm
Posts: 17
Location: United States
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject: The finished script
PostPosted: October 25th, 2005, 9:50 pm 
Offline

Joined: February 9th, 2005, 9:18 pm
Posts: 17
Location: United States
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2005, 10:21 pm 
Offline

Joined: September 25th, 2005, 4:31 pm
Posts: 610
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


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Stigg, xXDarknessXx and 13 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