AutoHotkey Community

It is currently May 27th, 2012, 5:55 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 83 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject:
PostPosted: October 20th, 2008, 12:04 am 
Offline

Joined: June 25th, 2008, 2:31 pm
Posts: 25
I've tried several mouse scripts and always felt like something was missing for me to actually find it usable. I think I finally figured out what I wanted.

I haven't tried putting it together with this thread's script yet, but below is a mouse jumping feature.

I see using this to jump to the general area (which I'll get better at approximating over time) then use a little numpad mouse moving to get to my destination.

Code:
NumpadMult & NumpadSub:: ;QuickMouse Absolute
   CoordMode Mouse, Screen
   MouseGetPos OutputVarX, OutputVarY
   ToolTip QuickMouse Absolute - Enter X Coord
   Input, Xcoord, L2
   Xcoord:=Xcoord*10
   MouseMove %Xcoord%, %OutputVarY%
   ToolTip %Xcoord% - Enter Y Coord
   Input, Ycoord, L2
   Ycoord:=Ycoord*10
   MouseMove %Xcoord%,%Ycoord%
   
   ToolTip
   CoordMode Mouse, Relative
   
return

Code:
NumpadMult & NumpadDiv:: ;QuickMouse Relative
   CoordMode Mouse, Relative
...
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2008, 3:20 pm 
Offline

Joined: March 12th, 2008, 9:28 pm
Posts: 56
I've been using this one for months, no problems.
Now, problems.

I put this @ the top of the script:
Code:
#notrayicon
LWIN::
GetKeyState, ScrollLockState, ScrollLock, T
If ScrollLockState = D
{
SETSCROLLLOCKSTATE, OFF
}
else
{
SETSCROLLLOCKSTATE, ON
}

GetKeyState, NUMLockState, NUMLock, T
If NUMLockState = D
{
SETNUMLOCKSTATE, OFF
}
else
{
SETNUMLOCKSTATE, ON
}


Now I'm getting this error every time I use the 4 key:
Image

This was working, before, but I wanted to adjust the mouse speed.
Now I can't figure out what in the crap is goin' on.
Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2008, 12:59 pm 
Offline

Joined: March 12th, 2008, 9:28 pm
Posts: 56
Somehow....I got it working.
I just downloaded the script again, and used whole numbers here:
Code:
; Using the keyboard hook to implement the Numpad hotkeys prevents
; them from interfering with the generation of ANSI characters such
; as à.  This is because AutoHotkey generates such characters
; by holding down ALT and sending a series of Numpad keystrokes.
; Hook hotkeys are smart enough to ignore such keystrokes.
#UseHook

MouseSpeed = 2
MouseAccelerationSpeed = 140
MouseMaxSpeed = 70


Obviously, that was the problem.
But, even after reloading the script with whole numbers, it wouldn't work.
As I said, I actually had to re-download the script.
I guess it just made the variable bad somehow?
I don't understand, so if you can shed light, please do.
Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 23rd, 2008, 9:33 am 
Offline

Joined: December 23rd, 2008, 9:13 am
Posts: 12
Could somebody help me please.

What I really need is far more simpler than this, but I just have no clue how to remap the keys. This is what I need:

Left Arrow = Hold RightClick + Move Mouse cursor Left until released
Right Arrow = Hold RightClick + MoveMouse cursor Right until released

That's all, I can't figure out how to do that :(

Oh, and cursor speed control needs to stay.

Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 20th, 2009, 7:47 pm 
Offline

Joined: August 26th, 2004, 3:11 pm
Posts: 80
Location: Chelsea - MA, USA
An update to the script after many years is refreshing...:
- Mouse wheel movements are now used when NumLock is on, including the new WheelLeft/Right buttons (available on Vista). I didn't try that though because I don't use Vista yet.
- NumPadEnter is the speed adjustment modifier key now. Hold it then press a number to make speed adjustments to either mouse movement or mouse wheel movement.
- Movement keys are much smoother than before. You can use many keys at once to produce the combined effect. Holding 2 oppositely directional keys produce no movement. Pressing 2 keys with the same axis component speed will yield double speed. 3 buttons even better.... Pressing 2 buttons which original movements are 45 degrees apart, you get 22.5 degree angle apart movement. Same thing will happen to mouse wheel movements.
- No more click buttons holding forever whenever another is pressed.
- No buttons are hard-coded into the script anymore. Try messing with the script to find your perfect fit.
- Made smaller changes to suit my needs (like different speed, some added config values).

The To Do's Not Done's (And Not To Be Done's):
- I didn't make a GUI, because it would be quite pointless with the current speed adjustments key combinations.
- Make this into a function, because it's a script... not much sense... lol
- Add presets, because... you guys can change the hotkey lines, can't you? 4 directional buttons idea goes along with this (principally because of the smoother movement system, you can do that now if you want, but I dislike it myself).

Oh, and the script:

Code:
;; Using Keyboard NumPad as a Mouse -- by deguix
; http://www.autohotkey.com
; This script makes mousing with your keyboard almost as easy
; as using a real mouse (maybe even easier for some tasks).
; It supports up to five mouse buttons and the turning of the
; mouse wheel.  It also features customizable movement speed,
; acceleration, and "axis inversion".

/*
o------------------------------------------------------------o
|Using Keyboard NumPad as a Mouse                            |
(------------------------------------------------------------)
| By deguix           / A Script file for AutoHotkey 1.0.48+ |
|                    ----------------------------------------|
|                                                            |
|    This script is an example of use of AutoHotkey. It uses |
| the remapping of NumPad keys of a keyboard to transform it |
| into a mouse. Some features are the acceleration which     |
| enables you to increase the mouse movement when holding    |
| a key for a long time, and the rotation which makes the    |
| NumPad mouse to "turn". I.e. NumPadDown as NumPadUp        |
| and vice-versa. See the list of keys used below:           |
|------------------------------------------------------------|
| Keys                  | Description                        |
|------------------------------------------------------------|
| ScrollLock (toggle on)| Activates NumPad mouse mode.       |
|-----------------------|------------------------------------|
| NumPad0               | Left mouse button click.           |
| NumPad5               | Middle mouse button click.         |
| NumPadDot             | Right mouse button click.          |
| NumPadDiv/NumPadMult  | X1/X2 mouse button click. (Win 2k+)|
| NumPadSub/NumPadAdd   | Moves up/down the mouse wheel.     |
| NumPadEnter           | Mouse movement speed modifier key. |
|-----------------------|------------------------------------|
| NumLock (toggled off) | Activates mouse movement mode.     |
|-----------------------|------------------------------------|
| NumPadEnd/Down/PgDn/  | Mouse movement.                    |
| /Left/Right/Home/Up/  |                                    |
| /PgUp                 |                                    |
| NumPadEnter           | Mouse movement speed modifier key. |
|-----------------------|------------------------------------|
| NumLock (toggled on)  | Activates mousewheel movement mode |
|-----------------------|------------------------------------|
| NumPad1-9 (except 5)  | Mouse wheel movement.*             |
| NumPadEnter           | Mouse wheel mov. speed mod. key.** |
|------------------------------------------------------------|
| NumPadEnter (pressed) | Activates mouse speed adj. mode.   |
|-----------------------|------------------------------------|
| NumPadHome/NumPadEnd/ | +/- acceleration (pixels/cycles).  |
| NumPad7/NumPad1       |                                    |
| NumPadUp/NumPadDown   | +/- initial speed (pixels).        |
| NumPad8/NumPad2       |                                    |
| NumPadPgUp/NumPadPgDn | +/- maximum speed (pixels).        |
| NumPad9/NumPad3       |                                    |
| NumPadLeft/NumPadRight| +/- clockwise rotation (45° degree)|
| NumPad4/NumPad6       |                                    |
|------------------------------------------------------------|
| * = Left/Right movements are only supported in Vista+.     |
| ** = These options are affected by the mouse wheel speed   |
| adjusted on Control Panel as well. If you don't have a     |
| mouse with wheel, the default is 3 +/- lines per option    |
| button press.                                              |
o------------------------------------------------------------o
*/

;START OF CONFIG SECTION

#SingleInstance force
#MaxHotkeysPerInterval 500

; Using the keyboard hook to implement the NumPad hotkeys prevents
; them from interfering with the generation of ANSI characters such
; as à.  This is because AutoHotkey generates such characters
; by holding down ALT and sending a series of NumPad keystrokes.
; Hook hotkeys are smart enough to ignore such keystrokes.
#UseHook

MouseSpeed:=5
MouseAccelerationSpeed:=5 ;in pixels/MouseAccelerationCycles
MouseAccelerationCycles:=50 ;interval of timer executions to increase speed by the variable above
MouseAccelerationTimerInterval:=10 ;in milliseconds (this ends up to being approximate depending on computer performance)
MouseMaxSpeed:=10
MouseRotationAngle:=0

;Mouse wheel speed is also set on Control Panel. As that
;will affect the normal mouse behavior, the real speed of
;these three below are times the normal mouse wheel speed.
MouseWheelSpeed:=2
MouseWheelAccelerationSpeed:=1 ;in pixels/MouseAccelerationCycles
MouseWheelAccelerationCycles:=50 ;interval of timer executions to increase speed by the variable above
MouseWheelAccelerationTimerInterval:=35 ;in milliseconds (this ends up to being approximate depending on computer performance)
MouseWheelMaxSpeed:=5
MouseWheelRotationAngle:=0

MouseButtonPressCheckTimerInterval:=10

;END OF CONFIG SECTION

PI:= 4*ATan(1)

;This is needed or key presses would faulty send their natural
;actions. Like NumPadDiv would send sometimes "/" to the
;screen.
#InstallKeybdHook

Temp = 0
Temp2 = 0

MouseRotationAnglePart = %MouseRotationAngle%
;Divide by 45° because MouseMove only supports whole numbers,
;and changing the mouse rotation to a number lesser than 45°
;could make strange movements.
;
;For example: 22.5° when pressing NumPadUp:
;  First it would move upwards until the speed
;  to the side reaches 1.
MouseRotationAnglePart /= 45
MouseWheelRotationAnglePart = %MouseRotationAngle%
MouseWheelRotationAnglePart /= 45

MovementVectorMagnitude:=0
MovementVectorDirection:=0
MovementVectors:=0
MovementVectorDefaultMagnitude:=MouseSpeed

MovementWheelVectorMagnitude:=0
MovementWheelVectorDirection:=0
MovementWheelVectors:=0
MovementWheelVectorDefaultMagnitude:=MouseWheelSpeed

Buttons:=0

SetKeyDelay, -1
SetMouseDelay, -1

Hotkey, *NumPad0, ButtonLeftClick
Hotkey, *NumPadIns, ButtonLeftClickIns
Hotkey, *NumPad5, ButtonMiddleClick
Hotkey, *NumPadClear, ButtonMiddleClickClear
Hotkey, *NumPadDot, ButtonRightClick
Hotkey, *NumPadDel, ButtonRightClickDel
Hotkey, *NumPadDiv, ButtonX1Click
Hotkey, *NumPadMult, ButtonX2Click

Hotkey, *NumPadSub, ButtonWheelUp
Hotkey, *NumPadAdd, ButtonWheelDown

Hotkey, *NumPadRight, ButtonRight
Hotkey, *NumPadPgUp, ButtonUpRight
Hotkey, *NumPadUp, ButtonUp
Hotkey, *NumPadHome, ButtonUpLeft
Hotkey, *NumPadLeft, ButtonLeft
Hotkey, *NumPadEnd, ButtonDownLeft
Hotkey, *NumPadDown, ButtonDown
Hotkey, *NumPadPgDn, ButtonDownRight

Hotkey, *NumPad6, ButtonWheelRight
Hotkey, *NumPad9, ButtonWheelUpRight
Hotkey, *NumPad8, ButtonWheelUp
Hotkey, *NumPad7, ButtonWheelUpLeft
Hotkey, *NumPad4, ButtonWheelLeft
Hotkey, *NumPad1, ButtonWheelDownLeft
Hotkey, *NumPad2, ButtonWheelDown
Hotkey, *NumPad3, ButtonWheelDownRight

Hotkey, NumPadEnter & NumPadUp, ButtonSpeedUp
Hotkey, NumPadEnter & NumPadDown, ButtonSpeedDown
Hotkey, NumPadEnter & NumPadHome, ButtonAccelerationSpeedUp
Hotkey, NumPadEnter & NumPadEnd, ButtonAccelerationSpeedDown
Hotkey, NumPadEnter & NumPadPgUp, ButtonMaxSpeedUp
Hotkey, NumPadEnter & NumPadPgDn, ButtonMaxSpeedDown
Hotkey, NumPadEnter & NumPadLeft, ButtonRotationAngleUp
Hotkey, NumPadEnter & NumPadRight, ButtonRotationAngleDown

Hotkey, NumPadEnter & NumPad8, ButtonWheelSpeedUp
Hotkey, NumPadEnter & NumPad2, ButtonWheelSpeedDown
Hotkey, NumPadEnter & NumPad7, ButtonWheelAccelerationSpeedUp
Hotkey, NumPadEnter & NumPad1, ButtonWheelAccelerationSpeedDown
Hotkey, NumPadEnter & NumPad9, ButtonWheelMaxSpeedUp
Hotkey, NumPadEnter & NumPad3, ButtonWheelMaxSpeedDown
Hotkey, NumPadEnter & NumPad4, ButtonWheelRotationAngleUp
Hotkey, NumPadEnter & NumPad6, ButtonWheelRotationAngleDown

Hotkey, NumPadEnter, ButtonEnter

Gosub, ~ScrollLock  ; Initialize based on current ScrollLock state.
return

;Key activation support

~ScrollLock::
; Wait for it to be released because otherwise the hook state gets reset
; while the key is down, which causes the up-event to get suppressed,
; which in turn prevents toggling of the ScrollLock state/light:
KeyWait, ScrollLock
GetKeyState, ScrollLockState, ScrollLock, T
If ScrollLockState = D
{
  Hotkey, *NumPad0, on
  Hotkey, *NumPadIns, on
  Hotkey, *NumPad5, on
  Hotkey, *NumPadDot, on
  Hotkey, *NumPadDel, on
  Hotkey, *NumPadDiv, on
  Hotkey, *NumPadMult, on

  Hotkey, *NumPadSub, on
  Hotkey, *NumPadAdd, on

  Hotkey, *NumPadUp, on
  Hotkey, *NumPadDown, on
  Hotkey, *NumPadLeft, on
  Hotkey, *NumPadRight, on
  Hotkey, *NumPadHome, on
  Hotkey, *NumPadEnd, on
  Hotkey, *NumPadPgUp, on
  Hotkey, *NumPadPgDn, on

  Hotkey, *NumPad6, on
  Hotkey, *NumPad9, on
  Hotkey, *NumPad8, on
  Hotkey, *NumPad7, on
  Hotkey, *NumPad4, on
  Hotkey, *NumPad1, on
  Hotkey, *NumPad2, on
  Hotkey, *NumPad3, on

  Hotkey, NumPadEnter & NumPadUp, on
  Hotkey, NumPadEnter & NumPadDown, on
  Hotkey, NumPadEnter & NumPadHome, on
  Hotkey, NumPadEnter & NumPadEnd, on
  Hotkey, NumPadEnter & NumPadPgUp, on
  Hotkey, NumPadEnter & NumPadPgDn, on
  Hotkey, NumPadEnter & NumPadLeft, on
  Hotkey, NumPadEnter & NumPadRight, on

  Hotkey, NumPadEnter & NumPad8, on
  Hotkey, NumPadEnter & NumPad2, on
  Hotkey, NumPadEnter & NumPad7, on
  Hotkey, NumPadEnter & NumPad1, on
  Hotkey, NumPadEnter & NumPad9, on
  Hotkey, NumPadEnter & NumPad3, on
 
  Hotkey, NumPadEnter, on
}
else
{
  Hotkey, *NumPad0, off
  Hotkey, *NumPadIns, off
  Hotkey, *NumPad5, off
  Hotkey, *NumPadDot, off
  Hotkey, *NumPadDel, off
  Hotkey, *NumPadDiv, off
  Hotkey, *NumPadMult, off

  Hotkey, *NumPadSub, off
  Hotkey, *NumPadAdd, off

  Hotkey, *NumPadUp, off
  Hotkey, *NumPadDown, off
  Hotkey, *NumPadLeft, off
  Hotkey, *NumPadRight, off
  Hotkey, *NumPadHome, off
  Hotkey, *NumPadEnd, off
  Hotkey, *NumPadPgUp, off
  Hotkey, *NumPadPgDn, off

  Hotkey, *NumPad6, off
  Hotkey, *NumPad9, off
  Hotkey, *NumPad8, off
  Hotkey, *NumPad7, off
  Hotkey, *NumPad4, off
  Hotkey, *NumPad1, off
  Hotkey, *NumPad2, off
  Hotkey, *NumPad3, off

  Hotkey, NumPadEnter & NumPadUp, off
  Hotkey, NumPadEnter & NumPadDown, off
  Hotkey, NumPadEnter & NumPadHome, off
  Hotkey, NumPadEnter & NumPadEnd, off
  Hotkey, NumPadEnter & NumPadPgUp, off
  Hotkey, NumPadEnter & NumPadPgDn, off
  Hotkey, NumPadEnter & NumPadLeft, off
  Hotkey, NumPadEnter & NumPadRight, off

  Hotkey, NumPadEnter & NumPad8, off
  Hotkey, NumPadEnter & NumPad2, off
  Hotkey, NumPadEnter & NumPad7, off
  Hotkey, NumPadEnter & NumPad1, off
  Hotkey, NumPadEnter & NumPad9, off
  Hotkey, NumPadEnter & NumPad3, off
 
  Hotkey, NumPadEnter, off
}
return

ButtonEnter:
Send, {NumPadEnter}
Return

;Mouse click support
ButtonLeftClick:
ButtonLeftClickIns:
ButtonClickType:="Left"
MouseButtonName:="LButton"
Goto ButtonClickStart
ButtonMiddleClick:
ButtonMiddleClickClear:
ButtonClickType:="Middle"
MouseButtonName:="MButton"
Goto ButtonClickStart
ButtonRightClick:
ButtonRightClickDel:
ButtonClickType:="Right"
MouseButtonName:="RButton"
Goto ButtonClickStart
ButtonX1Click:
ButtonClickType:="X1"
MouseButtonName:="XButton1"
Goto ButtonClickStart
ButtonX2Click:
ButtonClickType:="X2"
MouseButtonName:="XButton2"
ButtonClickStart:
StringReplace, ButtonName, A_ThisHotkey, *
If (ButtonDown_%ButtonName%!=1)
{
  ButtonDown_%ButtonName%:=1
  Buttons:=Buttons+1
  Button%Buttons%Name:=ButtonName
  Button%Buttons%ClickType:=ButtonClickType
  Button%Buttons%MouseButtonName:=MouseButtonName
  Button%Buttons%Initialized:=0
  If (Buttons = 1)
    SetTimer, MouseButtonPressCheck, % MouseButtonPressCheckTimerInterval
}
Return

MouseButtonPressCheck:
If (Buttons=0)
{
  SetTimer, MouseButtonPressCheck, off
  Return
}

Button:=0
Loop
{
  Button:=Button+1
  If (Button%Buttons%Initialized=0)
  {
    GetKeyState, MouseButtonState, % Button%Button%MouseButtonName
    If (MouseButtonState="D")
      Continue
    MouseClick, % Button%Button%ClickType,,, 1, 0, D
    Button%Buttons%Initialized:=1
  }
 
  GetKeyState, ButtonState, % Button%Button%Name, P
  If (ButtonState="U")
  {
    ButtonName:=Button%Buttons%Name
    ButtonDown_%ButtonName%:=0
    MouseClick, % Button%Button%ClickType,,, 1, 0, U
   
    ButtonTemp:=Button
    ButtonTempPrev:=ButtonTemp-1

    Loop
    {
      ButtonTemp:=ButtonTemp+1
      ButtonTempPrev:=ButtonTempPrev+1
     
      If (Buttons<ButtonTemp)
      {
        Button%ButtonTempPrev%Name:=""
        Button%ButtonTempPrev%ClickType:=""
        Button%ButtonTempPrev%MouseButtonName:=""
        Button%ButtonTempPrev%Initialized:=0
        Break
      }
      Button%ButtonTempPrev%Name:=Button%ButtonTemp%Name
      Button%ButtonTempPrev%ClickType:=Button%ButtonTemp%ClickType
      Button%ButtonTempPrev%MouseButtonName:=Button%ButtonTemp%MouseButtonName
      Button%ButtonTempPrev%Initialized:=Button%ButtonTemp%Initialized
    }
    Buttons:=Buttons-1
  }
  If (Buttons<=Button)
    Break
}
Return

;Mouse movement support
ButtonDownRight:
MovementVectorDirectionTemp+=1
ButtonDown:
MovementVectorDirectionTemp+=1
ButtonDownLeft:
MovementVectorDirectionTemp+=1
ButtonLeft:
MovementVectorDirectionTemp+=1
ButtonUpLeft:
MovementVectorDirectionTemp+=1
ButtonUp:
MovementVectorDirectionTemp+=1
ButtonUpRight:
MovementVectorDirectionTemp+=1
ButtonRight:
StringReplace, MovementButtonName, A_ThisHotkey, *
If (MovementButtonDown_%MovementButtonName%!=1)
{
  MovementButtonDown_%MovementButtonName%:=1
  MovementVectors:=MovementVectors+1
  MovementVector%MovementVectors%Name:=MovementButtonName
  MovementVector%MovementVectors%Direction:=(MovementVectorDirectionTemp*PI/4)+(MouseRotationAngle*PI/180)
  MovementVector%MovementVectors%Magnitude:=MouseSpeed
  MovementVector%MovementVectors%Initialized:=0
  If (MovementVectors = 1)
  {
    MouseCurrentAccelerationSpeed:=MouseSpeed
    SetTimer, MovementVectorAcceleration, % MouseAccelerationTimerInterval
  }
}
MovementVectorDirectionTemp:=0
Return

MovementVectorAddition:
;Add 2 vectors
MovementVectorX:=MovementVectorMagnitude*Cos(MovementVectorDirection)+MovementVector%MovementVector%Magnitude*Cos(MovementVector%MovementVector%Direction)
MovementVectorY:=MovementVectorMagnitude*Sin(MovementVectorDirection)+MovementVector%MovementVector%Magnitude*Sin(MovementVector%MovementVector%Direction)
MovementVectorMagnitude:=Sqrt(MovementVectorX**2+MovementVectorY**2)
MovementVectorDirection:=ATan(MovementVectorY/MovementVectorX)
If (MovementVectorX<0)
{
  If (MovementVectorY>0)
    MovementVectorDirection:=MovementVectorDirection-PI
  Else
    MovementVectorDirection:=PI+MovementVectorDirection
}
MovementVectorMagnitudeRatio:=MovementVectorMagnitude/MouseSpeed
Return

MovementVectorAcceleration:
If (MovementVectors=0)
{
  MovementVectorX:=0.000000
  MovementVectorY:=0.000000
  MovementVectorMagnitude:=0.000000
  MovementVectorDirection:=0.000000
  MovementVectorMagnitudeRatio:=0.000000
  MovementResultantVectorMagnitude:=0.000000
  MovementResultantVectorDirection:=0.000000
  MovementResultantVectorX:=0.000000
  MovementResultantVectorY:=0.000000
  ;TrayTip,,% "(" . MovementResultantVectorMagnitude . "," . MovementResultantVectorDirection . ") - <" . MovementResultantVectorX . "," . MovementResultantVectorY . ">"
  SetTimer, MovementVectorAcceleration, off
  Return
}
MovementVector:=0
Loop
{
  MovementVector:=MovementVector+1
  If (MovementVector%MovementVector%Initialized=0)
  {
    Gosub, MovementVectorAddition
    MovementVector%MovementVector%Initialized:=1
  }
  GetKeyState, MovementButtonState, % MovementVector%MovementVector%Name, P
  If (MovementButtonState="U")
  {
    MovementButtonName:=MovementVector%MovementVector%Name
    MovementButtonDown_%MovementButtonName%:=0
    MovementVector%MovementVector%Magnitude:=-MovementVector%MovementVector%Magnitude
    Gosub, MovementVectorAddition
    MovementVectorTemp:=MovementVector
    MovementVectorTempPrev:=MovementVector-1
    Loop
    {
      MovementVectorTemp:=MovementVectorTemp+1
      MovementVectorTempPrev:=MovementVectorTempPrev+1
      If (MovementVectors<MovementVectorTemp)
      {
        MovementVector%MovementVectorTempPrev%Name:=""
        MovementVector%MovementVectorTempPrev%Direction:=0
        MovementVector%MovementVectorTempPrev%Magnitude:=0
        MovementVector%MovementVectorTempPrev%Initialized:=0
        Break
      }
      MovementVector%MovementVectorTempPrev%Name:=MovementVector%MovementVectorTemp%Name
      MovementVector%MovementVectorTempPrev%Direction:=MovementVector%MovementVectorTemp%Direction
      MovementVector%MovementVectorTempPrev%Magnitude:=MovementVector%MovementVectorTemp%Magnitude
      MovementVector%MovementVectorTempPrev%Initialized:=MovementVector%MovementVectorTemp%Initialized
    }
    MovementVectors:=MovementVectors-1
  }
  If (MovementVectors<=MovementVector)
    Break
}
If (MouseCurrentAccelerationSpeed<MouseMaxSpeed)
  MouseCurrentAccelerationSpeed:=MouseCurrentAccelerationSpeed+(MouseAccelerationSpeed/MouseAccelerationCycles)
MovementResultantVectorMagnitude:=MouseCurrentAccelerationSpeed*MovementVectorMagnitudeRatio
MovementResultantVectorDirection:=MovementVectorDirection
MovementResultantVectorX:=MovementResultantVectorMagnitude*Cos(MovementResultantVectorDirection)
MovementResultantVectorY:=MovementResultantVectorMagnitude*Sin(MovementResultantVectorDirection)
;TrayTip,,% "(" . MovementResultantVectorMagnitude . "," . MovementResultantVectorDirection . ") - <" . MovementResultantVectorX . "," . MovementResultantVectorY . ">"
MouseMove, % MovementResultantVectorX, % -MovementResultantVectorY, 0, R
Return

;Mouse wheel movement support
ButtonWheelDownRight:
MovementWheelVectorDirectionTemp+=1
ButtonWheelDown:
MovementWheelVectorDirectionTemp+=1
ButtonWheelDownLeft:
MovementWheelVectorDirectionTemp+=1
ButtonWheelLeft:
MovementWheelVectorDirectionTemp+=1
ButtonWheelUpLeft:
MovementWheelVectorDirectionTemp+=1
ButtonWheelUp:
MovementWheelVectorDirectionTemp+=1
ButtonWheelUpRight:
MovementWheelVectorDirectionTemp+=1
ButtonWheelRight:
StringReplace, MovementWheelButtonName, A_ThisHotkey, *
If (MovementWheelButtonDown_%MovementWheelButtonName%!=1)
{
  MovementWheelButtonDown_%MovementWheelButtonName%:=1
  MovementWheelVectors:=MovementWheelVectors+1
  MovementWheelVector%MovementWheelVectors%Name:=MovementWheelButtonName
  MovementWheelVector%MovementWheelVectors%Direction:=(MovementWheelVectorDirectionTemp*PI/4)+(MouseWheelRotationAngle*PI/180)
  MovementWheelVector%MovementWheelVectors%Magnitude:=MouseWheelSpeed
  MovementWheelVector%MovementWheelVectors%Initialized:=0
 
  If (MovementWheelVectors = 1)
  {
    MouseWheelCurrentAccelerationSpeed:=MouseWheelSpeed
    SetTimer, MovementWheelVectorAcceleration, % MouseWheelAccelerationTimerInterval
  }
}
MovementWheelVectorDirectionTemp:=0
Return

MovementWheelVectorAddition:
;Add 2 vectors
MovementWheelVectorX:=MovementWheelVectorMagnitude*Cos(MovementWheelVectorDirection)+MovementWheelVector%MovementWheelVector%Magnitude*Cos(MovementWheelVector%MovementWheelVector%Direction)
MovementWheelVectorY:=MovementWheelVectorMagnitude*Sin(MovementWheelVectorDirection)+MovementWheelVector%MovementWheelVector%Magnitude*Sin(MovementWheelVector%MovementWheelVector%Direction)
MovementWheelVectorMagnitude:=Sqrt(MovementWheelVectorX**2+MovementWheelVectorY**2)
MovementWheelVectorDirection:=ATan(MovementWheelVectorY/MovementWheelVectorX)
If (MovementWheelVectorX<0)
{
  If (MovementWheelVectorY>0)
    MovementWheelVectorDirection:=MovementWheelVectorDirection-PI
  Else
    MovementWheelVectorDirection:=PI+MovementWheelVectorDirection
}
MovementWheelVectorMagnitudeRatio:=MovementWheelVectorMagnitude/MouseWheelSpeed
Return

MovementWheelVectorAcceleration:
If (MovementWheelVectors=0)
{
  MovementWheelVectorX:=0.000000
  MovementWheelVectorY:=0.000000
  MovementWheelVectorMagnitude:=0.000000
  MovementWheelVectorDirection:=0.000000
  MovementWheelVectorMagnitudeRatio:=0.000000

  MovementWheelResultantVectorMagnitude:=0.000000
  MovementWheelResultantVectorDirection:=0.000000
  MovementWheelResultantVectorX:=0.000000
  MovementWheelResultantVectorY:=0.000000
 
  ;TrayTip,,% "(" . MovementResultantVectorMagnitude . "," . MovementResultantVectorDirection . ") - <" . MovementResultantVectorX . "," . MovementResultantVectorY . ">"
  SetTimer, MovementWheelVectorAcceleration, off
  Return
}

MovementWheelVector:=0
Loop
{
  MovementWheelVector:=MovementWheelVector+1
  If (MovementWheelVector%MovementWheelVector%Initialized=0)
  {
    Gosub, MovementWheelVectorAddition
    MovementWheelVector%MovementWheelVector%Initialized:=1
  }
 
  GetKeyState, MovementWheelButtonState, % MovementWheelVector%MovementWheelVector%Name, P
  If (MovementWheelButtonState="U")
  {
    MovementWheelButtonName:=MovementWheelVector%MovementWheelVector%Name
    MovementWheelButtonDown_%MovementWheelButtonName%:=0
    MovementWheelVector%MovementWheelVector%Magnitude:=-MovementWheelVector%MovementWheelVector%Magnitude
    Gosub, MovementWheelVectorAddition
   
    MovementWheelVectorTemp:=MovementWheelVector
    MovementWheelVectorTempPrev:=MovementWheelVector-1
    Loop
    {
      MovementWheelVectorTemp:=MovementWheelVectorTemp+1
      MovementWheelVectorTempPrev:=MovementWheelVectorTempPrev+1
     
      If (MovementWheelVectors<MovementWheelVectorTemp)
      {
        MovementWheelVector%MovementWheelVectorTempPrev%Name:=""
        MovementWheelVector%MovementWheelVectorTempPrev%Direction:=0
        MovementWheelVector%MovementWheelVectorTempPrev%Magnitude:=0
        MovementWheelVector%MovementWheelVectorTempPrev%Initialized:=0
        Break
      }
     
      MovementWheelVector%MovementWheelVectorTempPrev%Name:=MovementWheelVector%MovementWheelVectorTemp%Name
      MovementWheelVector%MovementWheelVectorTempPrev%Direction:=MovementWheelVector%MovementWheelVectorTemp%Direction
      MovementWheelVector%MovementWheelVectorTempPrev%Magnitude:=MovementWheelVector%MovementWheelVectorTemp%Magnitude
      MovementWheelVector%MovementWheelVectorTempPrev%Initialized:=MovementWheelVector%MovementWheelVectorTemp%Initialized
    }
    MovementWheelVectors:=MovementWheelVectors-1
  }
  If (MovementWheelVectors<=MovementWheelVector)
    Break
}

If (MouseWheelCurrentAccelerationSpeed<MouseWheelMaxSpeed)
  MouseWheelCurrentAccelerationSpeed:=MouseWheelCurrentAccelerationSpeed+(MouseWheelAccelerationSpeed/MouseWheelAccelerationCycles)

MovementWheelResultantVectorMagnitude:=MouseWheelCurrentAccelerationSpeed*MovementWheelVectorMagnitudeRatio
MovementWheelResultantVectorDirection:=MovementWheelVectorDirection
MovementWheelResultantVectorX:=MovementWheelResultantVectorMagnitude*Cos(MovementWheelResultantVectorDirection)
MovementWheelResultantVectorY:=MovementWheelResultantVectorMagnitude*Sin(MovementWheelResultantVectorDirection)
;TrayTip,,% "(" . MovementResultantVectorMagnitude . "," . MovementResultantVectorDirection . ") - <" . MovementResultantVectorX . "," . MovementResultantVectorY . ">"

If (MovementWheelResultantVectorX>=0)
  MouseClick, wheelright,,, % MovementWheelResultantVectorX, 0, D
Else
  MouseClick, wheelleft,,, % -MovementWheelResultantVectorX, 0, D

If (MovementWheelResultantVectorY>=0)
  MouseClick, wheelup,,, % MovementWheelResultantVectorY, 0, D
Else
  MouseClick, wheeldown,,, % -MovementWheelResultantVectorY, 0, D
Return


;Speed/rotation configuration support
;Movement
ButtonSpeedUp:
MouseSpeed:=MouseSpeed+2
ButtonSpeedDown:
MouseSpeed--
If (MouseSpeed>MouseMaxSpeed)
  MouseSpeed:=MouseMaxSpeed
If (MouseSpeed<=1)
{
  MouseSpeed:=1
  ToolTip, Mouse speed: %MouseSpeed% pixel
}
Else
  ToolTip, Mouse speed: %MouseSpeed% pixels
SetTimer, RemoveToolTip, 1000
Return

ButtonAccelerationSpeedUp:
MouseAccelerationSpeed:=MouseAccelerationSpeed+2
ButtonAccelerationSpeedDown:
MouseAccelerationSpeed--
If (MouseAccelerationSpeed<=1)
{
  MouseAccelerationSpeed:=1
  ToolTip, Mouse acceleration speed: %MouseAccelerationSpeed% pixel/cycle
}
Else
  ToolTip, Mouse acceleration speed: %MouseAccelerationSpeed% pixels/cycle
SetTimer, RemoveToolTip, 1000
Return

ButtonMaxSpeedUp:
MouseMaxSpeed:=MouseMaxSpeed+2
ButtonMaxSpeedDown:
MouseMaxSpeed--
If (MouseSpeed>MouseMaxSpeed)
  MouseSpeed:=MouseMaxSpeed
If (MouseMaxSpeed<=1)
{
  MouseMaxSpeed:=1
  ToolTip, Mouse maximum speed: %MouseMaxSpeed% pixel
}
Else
  ToolTip, Mouse maximum speed: %MouseMaxSpeed% pixels
SetTimer, RemoveToolTip, 1000
Return

ButtonRotationAngleUp:
MouseRotationAnglePart:=MouseRotationAnglePart+2
ButtonRotationAngleDown:
MouseRotationAnglePart--
If(MouseRotationAnglePart>=8)
  MouseRotationAnglePart:=0
If(MouseRotationAnglePart<0)
  MouseRotationAnglePart:=7
MouseRotationAngle = %MouseRotationAnglePart%
MouseRotationAngle *= 45
ToolTip, Mouse rotation angle: %MouseRotationAngle%°
SetTimer, RemoveToolTip, 1000
Return

;Wheel
ButtonWheelSpeedUp:
MouseWheelSpeed:=MouseWheelSpeed+2
ButtonWheelSpeedDown:
MouseWheelSpeed--
If (MouseWheelSpeed>MouseWheelMaxSpeed)
  MouseWheelSpeed:=MouseWheelMaxSpeed
If (MouseWheelSpeed<=1)
  MouseWheelSpeed:=1
RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
MouseWheelSpeedTemp:=MouseWheelSpeed*MouseWheelSpeedMultiplier
If (MouseWheelSpeedTemp=1)
  ToolTip, Mouse wheel speed: %MouseWheelSpeedTemp% line
Else
  ToolTip, Mouse wheel speed: %MouseWheelSpeedTemp% lines
SetTimer, RemoveToolTip, 1000
Return

ButtonWheelAccelerationSpeedUp:
MouseWheelAccelerationSpeed:=MouseWheelAccelerationSpeed+2
ButtonWheelAccelerationSpeedDown:
MouseWheelAccelerationSpeed--
If (MouseWheelAccelerationSpeed<=1)
  MouseWheelAccelerationSpeed:=1
RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
MouseWheelAccelerationSpeedTemp:=MouseWheelAccelerationSpeed*MouseWheelSpeedMultiplier
If (MouseWheelAccelerationSpeedTemp=1)
  ToolTip, Mouse wheel acceleration speed: %MouseWheelAccelerationSpeedTemp% line/cycle
Else
  ToolTip, Mouse wheel acceleration speed: %MouseWheelAccelerationSpeedTemp% lines/cycle
SetTimer, RemoveToolTip, 1000
Return

ButtonWheelMaxSpeedUp:
MouseWheelMaxSpeed:=MouseWheelMaxSpeed+2
ButtonWheelMaxSpeedDown:
MouseWheelMaxSpeed--
If (MouseWheelSpeed>MouseWheelMaxSpeed)
  MouseWheelSpeed:=MouseWheelMaxSpeed
If (MouseWheelMaxSpeed<=1)
  MouseWheelMaxSpeed:=1
RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
MouseWheelMaxSpeedTemp:=MouseWheelMaxSpeed*MouseWheelSpeedMultiplier
If (MouseWheelMaxSpeedTemp=1)
  ToolTip, Mouse wheel max speed: %MouseWheelMaxSpeedTemp% line
Else
  ToolTip, Mouse wheel max speed: %MouseWheelMaxSpeedTemp% lines
SetTimer, RemoveToolTip, 1000
Return

ButtonWheelRotationAngleUp:
MouseWheelRotationAnglePart:=MouseWheelRotationAnglePart+2
ButtonWheelRotationAngleDown:
MouseWheelRotationAnglePart--
If(MouseWheelRotationAnglePart>=8)
  MouseWheelRotationAnglePart:=0
If(MouseWheelRotationAnglePart<0)
  MouseWheelRotationAnglePart:=7
MouseWheelRotationAngle = %MouseWheelRotationAnglePart%
MouseWheelRotationAngle *= 45
ToolTip, Mouse wheel rotation angle: %MouseWheelRotationAngle%°
SetTimer, RemoveToolTip, 1000
Return

RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
Return


That's it for now.

_________________
Working now on:
NumpadMouse v2 (Draw)
top-recode project (private server script) (pkodev)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 19th, 2009, 12:15 am 
Offline

Joined: August 18th, 2009, 11:11 pm
Posts: 7
Would it be possible to modify the script to support d-pads (joystick/digital pads)? There is a script for analog joysticks already but its not much of help regarding digital inputs. Some d-pad drivers send x/y-axis commands and others use button outputs.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2009, 12:03 am 
Offline

Joined: October 27th, 2006, 10:12 am
Posts: 649
Why not using the entire keyboard instead of just the Numpad section? At least in the case of laptops where you have no extra Numpad section. I do not like the mousepad of my laptop as it is not fast enough for my needs for controlling the cursor coordinate on the screen.

I thought maybe using a mouse movement special key as e.g. space, we could split the entire screen into 5 vertical and 10 horizontal ranges, meaning we would map in the first commanding key the whole screen to those possible 50 sections or grids. Pressing the space key and holding it for longer than time x would show a light and transparent grid on the screen with numbers 1..50 in it which you could select then as follows.
Code:
1. row = 1..10 = keys F1..F10
2. row = 11..20 = keys 1..0
3. row = 21..30 = keys q..p
4. row = 31..40 = keys a..;
5. row = 41..50 = keys z../

Then when selecting that section, the mouse cursor range would be zoomed only into that range and the 50 keys would work on that area, until we reach the coordinate we wanted. I think with some exercise such end points could be reached quite fastly, especially if the code would even align to certain objects which are available on the top level screen, like visible menues, button, fields, controls.

Replacing mouse movements with any solution needing only the normal pc keys on laptops without any numpad section would be just great. Or should we use instead camera based hand tracking for the mouse cursor control on screen?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2009, 12:46 pm 
Offline

Joined: October 27th, 2006, 10:12 am
Posts: 649
GridMove comes quite close to the above idea,
http://jgpaiva.dcmembers.com/gridmove.html


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2009, 5:57 pm 
Hi,

I've just started using this script, and I like it a lot.

One question I have though: how do you set the mouse wheel speed to a minimum. I've set my control panel mouse wheel speed to 1, and with the numpad enter set all the speeds to 1 as well, but this script still seems to scrolls about 3 times as fast as my regular mouse...


Report this post
Top
  
Reply with quote  
PostPosted: October 20th, 2009, 5:34 pm 
Offline

Joined: October 20th, 2009, 5:29 pm
Posts: 4
Location: Waukesha
I love this script. Is there any suggestions/thoughts how I can increase the speed, if I hold the control key, like in windows MouseKey.
For instance, Normal mouse speed is 10, it should be Normal Mouse Speed + Control Key Acceleration i.e 10+7.

Any input is appreciated.

Thanks,
--Se


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2009, 9:15 pm 
Offline

Joined: August 26th, 2004, 3:11 pm
Posts: 80
Location: Chelsea - MA, USA
Quote:
Would it be possible to modify the script to support d-pads (joystick/digital pads)? There is a script for analog joysticks already but its not much of help regarding digital inputs. Some d-pad drivers send x/y-axis commands and others use button outputs.
Not with autohotkey alone, I'm afraid... if anyone has any suggestions on drivers and whatnot maybe I could give it a try.

Quote:
One question I have though: how do you set the mouse wheel speed to a minimum. I've set my control panel mouse wheel speed to 1, and with the numpad enter set all the speeds to 1 as well, but this script still seems to scrolls about 3 times as fast as my regular mouse...
Maybe the registry key is different for your mouse... the script uses HKCU\Control Panel\Desktop - Key: WheelScrollLines... use regedit and check that in your comp. If that's 1, try to adjust the script speed settings inside the script file (there are extra settings that might produce different performance on different computers). If that doesn't solve the problem, say it here.

Quote:
I love this script. Is there any suggestions/thoughts how I can increase the speed, if I hold the control key, like in windows MouseKey.
For instance, Normal mouse speed is 10, it should be Normal Mouse Speed + Control Key Acceleration i.e 10+7.
Hold 2 keys going to the general direction to have the speed towards that direction doubled. For example, UpLeft + UpRight = 2*Up. You can even make 3x by using UpLeft, Up and UpRight together. This is much better than using ctrl in my opinion.

_________________
Working now on:
NumpadMouse v2 (Draw)
top-recode project (private server script) (pkodev)


Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 30th, 2009, 4:08 am 
First of all, thank you immensely for this script. Extremely helpful, especially as I am trying to become more ergonomic.

I have no coding experience, as will be evident when I ask my question. I find that it would be slightly more convenient to have NumPad5 serve as the left click, with NumPad0 taking the middle click role instead. I've tried to switch all the references in the script, but when I run it, their original roles persist. Any idea how to solve this?

Thanks again and apologies for the simple question.


Report this post
Top
  
Reply with quote  
 Post subject: License
PostPosted: November 23rd, 2009, 11:44 am 
Hey, what license is this code under? thanks.


Report this post
Top
  
Reply with quote  
PostPosted: May 12th, 2010, 11:37 pm 
I got an iogear wireless keyboard for my HTPC which has a trackball on the right with the mouse buttons on the left which meant I had to use two hands to do most things. Now I can control everything with one hand thanks to this utility. I picked AutoHotKey over AutoIT mainly due to the fact that its a portable application and expected to write some quick and dirty mouse click replacement code. Then I found this truly elegant solution. Thanks to all who have contributed to this code, especially deguix.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2010, 10:48 pm 
Offline

Joined: August 26th, 2004, 3:11 pm
Posts: 80
Location: Chelsea - MA, USA
Btw, another update. Added 2 options in the config called "MouseButtonClickLockDownState" and "MouseButtonMovementLockDownState". It locks the down state on button on press, and unlocks in the second press. By default, they are disabled.

Those might help the people who can't hold buttons too long. Just watch out on the movement, sometimes you might get null vectors (because they can be combined), and pressing another key might make it go the other way around. Also, for clicks, it doesn't work well if you are also clicking with the regular mouse (well, same problem as on regular mode, except it might happen more regularly).

Code:
;; Using Keyboard NumPad as a Mouse -- by deguix
; http://www.autohotkey.com
; This script makes mousing with your keyboard almost as easy
; as using a real mouse (maybe even easier for some tasks).
; It supports up to five mouse buttons and the turning of the
; mouse wheel.  It also features customizable movement speed,
; acceleration, and "axis inversion".

/*
o------------------------------------------------------------o
|Using Keyboard NumPad as a Mouse                            |
(------------------------------------------------------------)
| By deguix           / A Script file for AutoHotkey 1.0.48+ |
|                    ----------------------------------------|
|                                                            |
|    This script is an example of use of AutoHotkey. It uses |
| the remapping of NumPad keys of a keyboard to transform it |
| into a mouse. Some features are the acceleration which     |
| enables you to increase the mouse movement when holding    |
| a key for a long time, and the rotation which makes the    |
| NumPad mouse to "turn". I.e. NumPadDown as NumPadUp        |
| and vice-versa. See the list of keys used below:           |
|------------------------------------------------------------|
| Keys                  | Description                        |
|------------------------------------------------------------|
| ScrollLock (toggle on)| Activates NumPad mouse mode.       |
|-----------------------|------------------------------------|
| NumPad0               | Left mouse button click.           |
| NumPad5               | Middle mouse button click.         |
| NumPadDot             | Right mouse button click.          |
| NumPadDiv/NumPadMult  | X1/X2 mouse button click. (Win 2k+)|
| NumPadSub/NumPadAdd   | Moves up/down the mouse wheel.     |
| NumPadEnter           | Mouse movement speed modifier key. |
|-----------------------|------------------------------------|
| NumLock (toggled off) | Activates mouse movement mode.     |
|-----------------------|------------------------------------|
| NumPadEnd/Down/PgDn/  | Mouse movement.                    |
| /Left/Right/Home/Up/  |                                    |
| /PgUp                 |                                    |
| NumPadEnter           | Mouse movement speed modifier key. |
|-----------------------|------------------------------------|
| NumLock (toggled on)  | Activates mousewheel movement mode |
|-----------------------|------------------------------------|
| NumPad1-9 (except 5)  | Mouse wheel movement.*             |
| NumPadEnter           | Mouse wheel mov. speed mod. key.** |
|------------------------------------------------------------|
| NumPadEnter (pressed) | Activates mouse speed adj. mode.   |
|-----------------------|------------------------------------|
| NumPadHome/NumPadEnd/ | +/- acceleration (pixels/cycles).  |
| NumPad7/NumPad1       |                                    |
| NumPadUp/NumPadDown   | +/- initial speed (pixels).        |
| NumPad8/NumPad2       |                                    |
| NumPadPgUp/NumPadPgDn | +/- maximum speed (pixels).        |
| NumPad9/NumPad3       |                                    |
| NumPadLeft/NumPadRight| +/- clockwise rotation (45° degree)|
| NumPad4/NumPad6       |                                    |
|------------------------------------------------------------|
| * = Left/Right movements are only supported in Vista+.     |
| ** = These options are affected by the mouse wheel speed   |
| adjusted on Control Panel as well. If you don't have a     |
| mouse with wheel, the default is 3 +/- lines per option    |
| button press.                                              |
o------------------------------------------------------------o
*/

;START OF CONFIG SECTION

#SingleInstance force
#MaxHotkeysPerInterval 500

; Using the keyboard hook to implement the NumPad hotkeys prevents
; them from interfering with the generation of ANSI characters such
; as à.  This is because AutoHotkey generates such characters
; by holding down ALT and sending a series of NumPad keystrokes.
; Hook hotkeys are smart enough to ignore such keystrokes.
#UseHook

MouseSpeed:=5
MouseAccelerationSpeed:=5 ;in pixels/MouseAccelerationCycles
MouseAccelerationCycles:=50 ;interval of timer executions to increase speed by the variable above
MouseAccelerationTimerInterval:=10 ;in milliseconds (this ends up to being approximate depending on computer performance)
MouseMaxSpeed:=10
MouseRotationAngle:=0

;Mouse wheel speed is also set on Control Panel. As that
;will affect the normal mouse behavior, the real speed of
;these three below are times the normal mouse wheel speed.
MouseWheelSpeed:=2
MouseWheelAccelerationSpeed:=1 ;in pixels/MouseAccelerationCycles
MouseWheelAccelerationCycles:=50 ;interval of timer executions to increase speed by the variable above
MouseWheelAccelerationTimerInterval:=35 ;in milliseconds (this ends up to being approximate depending on computer performance)
MouseWheelMaxSpeed:=5
MouseWheelRotationAngle:=0

MouseButtonPressCheckTimerInterval:=10

;0=Pressing a button and releasing = down + up events. 1=First time pressing/releasing = down, second time = up.
MouseButtonClickLockDownState:=0
MouseButtonMovementLockDownState:=0

;END OF CONFIG SECTION

PI:= 4*ATan(1)

;This is needed or key presses would faulty send their natural
;actions. Like NumPadDiv would send sometimes "/" to the
;screen.
#InstallKeybdHook

Temp = 0
Temp2 = 0

MouseRotationAnglePart = %MouseRotationAngle%
;Divide by 45° because MouseMove only supports whole numbers,
;and changing the mouse rotation to a number lesser than 45°
;could make strange movements.
;
;For example: 22.5° when pressing NumPadUp:
;  First it would move upwards until the speed
;  to the side reaches 1.
MouseRotationAnglePart /= 45
MouseWheelRotationAnglePart = %MouseRotationAngle%
MouseWheelRotationAnglePart /= 45

MovementVectorMagnitude:=0
MovementVectorDirection:=0
MovementVectors:=0
MovementVectorDefaultMagnitude:=MouseSpeed

MovementWheelVectorMagnitude:=0
MovementWheelVectorDirection:=0
MovementWheelVectors:=0
MovementWheelVectorDefaultMagnitude:=MouseWheelSpeed

Buttons:=0

SetKeyDelay, -1
SetMouseDelay, -1

Hotkey, *NumPad0, ButtonLeftClick
Hotkey, *NumPadIns, ButtonLeftClickIns
Hotkey, *NumPad5, ButtonMiddleClick
Hotkey, *NumPadClear, ButtonMiddleClickClear
Hotkey, *NumPadDot, ButtonRightClick
Hotkey, *NumPadDel, ButtonRightClickDel
Hotkey, *NumPadDiv, ButtonX1Click
Hotkey, *NumPadMult, ButtonX2Click

Hotkey, *NumPadSub, ButtonWheelUp
Hotkey, *NumPadAdd, ButtonWheelDown

Hotkey, *NumPadRight, ButtonRight
Hotkey, *NumPadPgUp, ButtonUpRight
Hotkey, *NumPadUp, ButtonUp
Hotkey, *NumPadHome, ButtonUpLeft
Hotkey, *NumPadLeft, ButtonLeft
Hotkey, *NumPadEnd, ButtonDownLeft
Hotkey, *NumPadDown, ButtonDown
Hotkey, *NumPadPgDn, ButtonDownRight

Hotkey, *NumPad6, ButtonWheelRight
Hotkey, *NumPad9, ButtonWheelUpRight
Hotkey, *NumPad8, ButtonWheelUp
Hotkey, *NumPad7, ButtonWheelUpLeft
Hotkey, *NumPad4, ButtonWheelLeft
Hotkey, *NumPad1, ButtonWheelDownLeft
Hotkey, *NumPad2, ButtonWheelDown
Hotkey, *NumPad3, ButtonWheelDownRight

Hotkey, NumPadEnter & NumPadUp, ButtonSpeedUp
Hotkey, NumPadEnter & NumPadDown, ButtonSpeedDown
Hotkey, NumPadEnter & NumPadHome, ButtonAccelerationSpeedUp
Hotkey, NumPadEnter & NumPadEnd, ButtonAccelerationSpeedDown
Hotkey, NumPadEnter & NumPadPgUp, ButtonMaxSpeedUp
Hotkey, NumPadEnter & NumPadPgDn, ButtonMaxSpeedDown
Hotkey, NumPadEnter & NumPadLeft, ButtonRotationAngleUp
Hotkey, NumPadEnter & NumPadRight, ButtonRotationAngleDown

Hotkey, NumPadEnter & NumPad8, ButtonWheelSpeedUp
Hotkey, NumPadEnter & NumPad2, ButtonWheelSpeedDown
Hotkey, NumPadEnter & NumPad7, ButtonWheelAccelerationSpeedUp
Hotkey, NumPadEnter & NumPad1, ButtonWheelAccelerationSpeedDown
Hotkey, NumPadEnter & NumPad9, ButtonWheelMaxSpeedUp
Hotkey, NumPadEnter & NumPad3, ButtonWheelMaxSpeedDown
Hotkey, NumPadEnter & NumPad4, ButtonWheelRotationAngleUp
Hotkey, NumPadEnter & NumPad6, ButtonWheelRotationAngleDown

Hotkey, NumPadEnter, ButtonEnter

Gosub, ~ScrollLock  ; Initialize based on current ScrollLock state.
return

;Key activation support

~ScrollLock::
; Wait for it to be released because otherwise the hook state gets reset
; while the key is down, which causes the up-event to get suppressed,
; which in turn prevents toggling of the ScrollLock state/light:
KeyWait, ScrollLock
GetKeyState, ScrollLockState, ScrollLock, T
If ScrollLockState = D
{
  Hotkey, *NumPad0, on
  Hotkey, *NumPadIns, on
  Hotkey, *NumPad5, on
  Hotkey, *NumPadDot, on
  Hotkey, *NumPadDel, on
  Hotkey, *NumPadDiv, on
  Hotkey, *NumPadMult, on

  Hotkey, *NumPadSub, on
  Hotkey, *NumPadAdd, on

  Hotkey, *NumPadUp, on
  Hotkey, *NumPadDown, on
  Hotkey, *NumPadLeft, on
  Hotkey, *NumPadRight, on
  Hotkey, *NumPadHome, on
  Hotkey, *NumPadEnd, on
  Hotkey, *NumPadPgUp, on
  Hotkey, *NumPadPgDn, on

  Hotkey, *NumPad6, on
  Hotkey, *NumPad9, on
  Hotkey, *NumPad8, on
  Hotkey, *NumPad7, on
  Hotkey, *NumPad4, on
  Hotkey, *NumPad1, on
  Hotkey, *NumPad2, on
  Hotkey, *NumPad3, on

  Hotkey, NumPadEnter & NumPadUp, on
  Hotkey, NumPadEnter & NumPadDown, on
  Hotkey, NumPadEnter & NumPadHome, on
  Hotkey, NumPadEnter & NumPadEnd, on
  Hotkey, NumPadEnter & NumPadPgUp, on
  Hotkey, NumPadEnter & NumPadPgDn, on
  Hotkey, NumPadEnter & NumPadLeft, on
  Hotkey, NumPadEnter & NumPadRight, on

  Hotkey, NumPadEnter & NumPad8, on
  Hotkey, NumPadEnter & NumPad2, on
  Hotkey, NumPadEnter & NumPad7, on
  Hotkey, NumPadEnter & NumPad1, on
  Hotkey, NumPadEnter & NumPad9, on
  Hotkey, NumPadEnter & NumPad3, on
 
  Hotkey, NumPadEnter, on
}
else
{
  Hotkey, *NumPad0, off
  Hotkey, *NumPadIns, off
  Hotkey, *NumPad5, off
  Hotkey, *NumPadDot, off
  Hotkey, *NumPadDel, off
  Hotkey, *NumPadDiv, off
  Hotkey, *NumPadMult, off

  Hotkey, *NumPadSub, off
  Hotkey, *NumPadAdd, off

  Hotkey, *NumPadUp, off
  Hotkey, *NumPadDown, off
  Hotkey, *NumPadLeft, off
  Hotkey, *NumPadRight, off
  Hotkey, *NumPadHome, off
  Hotkey, *NumPadEnd, off
  Hotkey, *NumPadPgUp, off
  Hotkey, *NumPadPgDn, off

  Hotkey, *NumPad6, off
  Hotkey, *NumPad9, off
  Hotkey, *NumPad8, off
  Hotkey, *NumPad7, off
  Hotkey, *NumPad4, off
  Hotkey, *NumPad1, off
  Hotkey, *NumPad2, off
  Hotkey, *NumPad3, off

  Hotkey, NumPadEnter & NumPadUp, off
  Hotkey, NumPadEnter & NumPadDown, off
  Hotkey, NumPadEnter & NumPadHome, off
  Hotkey, NumPadEnter & NumPadEnd, off
  Hotkey, NumPadEnter & NumPadPgUp, off
  Hotkey, NumPadEnter & NumPadPgDn, off
  Hotkey, NumPadEnter & NumPadLeft, off
  Hotkey, NumPadEnter & NumPadRight, off

  Hotkey, NumPadEnter & NumPad8, off
  Hotkey, NumPadEnter & NumPad2, off
  Hotkey, NumPadEnter & NumPad7, off
  Hotkey, NumPadEnter & NumPad1, off
  Hotkey, NumPadEnter & NumPad9, off
  Hotkey, NumPadEnter & NumPad3, off
 
  Hotkey, NumPadEnter, off
}
return

ButtonEnter:
Send, {NumPadEnter}
Return

;Mouse click support
ButtonLeftClick:
ButtonLeftClickIns:
ButtonClickType:="Left"
MouseButtonName:="LButton"
Goto ButtonClickStart
ButtonMiddleClick:
ButtonMiddleClickClear:
ButtonClickType:="Middle"
MouseButtonName:="MButton"
Goto ButtonClickStart
ButtonRightClick:
ButtonRightClickDel:
ButtonClickType:="Right"
MouseButtonName:="RButton"
Goto ButtonClickStart
ButtonX1Click:
ButtonClickType:="X1"
MouseButtonName:="XButton1"
Goto ButtonClickStart
ButtonX2Click:
ButtonClickType:="X2"
MouseButtonName:="XButton2"
ButtonClickStart:
StringReplace, ButtonName, A_ThisHotkey, *
If (ButtonDown_%ButtonName%!=1)
{
  ButtonDown_%ButtonName%:=1
  Buttons:=Buttons+1
  Button%Buttons%Name:=ButtonName
  Button%Buttons%ClickType:=ButtonClickType
  Button%Buttons%MouseButtonName:=MouseButtonName
  Button%Buttons%Initialized:=0
  Button%Buttons%UnHoldStep:=0
  If (Buttons = 1)
    SetTimer, MouseButtonPressCheck, % MouseButtonPressCheckTimerInterval
}
Return

MouseButtonPressCheck:
If (Buttons=0)
{
  SetTimer, MouseButtonPressCheck, off
  Return
}

Button:=0
Loop
{
  Button:=Button+1
  If (Button%Buttons%Initialized=0)
  {
    GetKeyState, MouseButtonState, % Button%Button%MouseButtonName
    If (MouseButtonState="D")
      Continue
    MouseClick, % Button%Button%ClickType,,, 1, 0, D
    Button%Buttons%Initialized:=1
  }
 
  GetKeyState, ButtonState, % Button%Button%Name, P
  If (ButtonState="U" and (MouseButtonClickLockDownState=0 or (MouseButtonClickLockDownState=1 and Button%Buttons%UnHoldStep=2)))
  {
    ButtonName:=Button%Buttons%Name
    ButtonDown_%ButtonName%:=0
    MouseClick, % Button%Button%ClickType,,, 1, 0, U
   
    ButtonTemp:=Button
    ButtonTempPrev:=ButtonTemp-1

    Loop
    {
      ButtonTemp:=ButtonTemp+1
      ButtonTempPrev:=ButtonTempPrev+1
     
      If (Buttons<ButtonTemp)
      {
        Button%ButtonTempPrev%Name:=""
        Button%ButtonTempPrev%ClickType:=""
        Button%ButtonTempPrev%MouseButtonName:=""
        Button%ButtonTempPrev%Initialized:=0
        Break
      }
      Button%ButtonTempPrev%Name:=Button%ButtonTemp%Name
      Button%ButtonTempPrev%ClickType:=Button%ButtonTemp%ClickType
      Button%ButtonTempPrev%MouseButtonName:=Button%ButtonTemp%MouseButtonName
      Button%ButtonTempPrev%Initialized:=Button%ButtonTemp%Initialized
    }
    Buttons:=Buttons-1
  }
 
  If(ButtonState="U" and MouseButtonClickLockDownState=1 and Button%Buttons%UnHoldStep=0)
    Button%Buttons%UnHoldStep:=1
  If(ButtonState="D" and MouseButtonClickLockDownState=1 and Button%Buttons%UnHoldStep=1)
    Button%Buttons%UnHoldStep:=2
 
  If (Buttons<=Button)
    Break
}
Return

;Mouse movement support
ButtonDownRight:
MovementVectorDirectionTemp+=1
ButtonDown:
MovementVectorDirectionTemp+=1
ButtonDownLeft:
MovementVectorDirectionTemp+=1
ButtonLeft:
MovementVectorDirectionTemp+=1
ButtonUpLeft:
MovementVectorDirectionTemp+=1
ButtonUp:
MovementVectorDirectionTemp+=1
ButtonUpRight:
MovementVectorDirectionTemp+=1
ButtonRight:
StringReplace, MovementButtonName, A_ThisHotkey, *
If (MovementButtonDown_%MovementButtonName%!=1)
{
  MovementButtonDown_%MovementButtonName%:=1
  MovementVectors:=MovementVectors+1
  MovementVector%MovementVectors%Name:=MovementButtonName
  MovementVector%MovementVectors%Direction:=(MovementVectorDirectionTemp*PI/4)+(MouseRotationAngle*PI/180)
  MovementVector%MovementVectors%Magnitude:=MouseSpeed
  MovementVector%MovementVectors%Initialized:=0
  MovementVector%MovementVectors%UnHoldStep:=0
  If (MovementVectors = 1)
  {
    MouseCurrentAccelerationSpeed:=MouseSpeed
    SetTimer, MovementVectorAcceleration, % MouseAccelerationTimerInterval
  }
}
MovementVectorDirectionTemp:=0
Return

MovementVectorAddition:
;Add 2 vectors
MovementVectorX:=MovementVectorMagnitude*Cos(MovementVectorDirection)+MovementVector%MovementVector%Magnitude*Cos(MovementVector%MovementVector%Direction)
MovementVectorY:=MovementVectorMagnitude*Sin(MovementVectorDirection)+MovementVector%MovementVector%Magnitude*Sin(MovementVector%MovementVector%Direction)
MovementVectorMagnitude:=Sqrt(MovementVectorX**2+MovementVectorY**2)
MovementVectorDirection:=ATan(MovementVectorY/MovementVectorX)
If (MovementVectorX<0)
{
  If (MovementVectorY>0)
    MovementVectorDirection:=MovementVectorDirection-PI
  Else
    MovementVectorDirection:=PI+MovementVectorDirection
}
MovementVectorMagnitudeRatio:=MovementVectorMagnitude/MouseSpeed
Return

MovementVectorAcceleration:
If (MovementVectors=0)
{
  MovementVectorX:=0.000000
  MovementVectorY:=0.000000
  MovementVectorMagnitude:=0.000000
  MovementVectorDirection:=0.000000
  MovementVectorMagnitudeRatio:=0.000000
  MovementResultantVectorMagnitude:=0.000000
  MovementResultantVectorDirection:=0.000000
  MovementResultantVectorX:=0.000000
  MovementResultantVectorY:=0.000000
  ;TrayTip,,% "(" . MovementResultantVectorMagnitude . "," . MovementResultantVectorDirection . ") - <" . MovementResultantVectorX . "," . MovementResultantVectorY . ">"
  SetTimer, MovementVectorAcceleration, off
  Return
}
MovementVector:=0
Loop
{
  MovementVector:=MovementVector+1
  If (MovementVector%MovementVector%Initialized=0)
  {
    Gosub, MovementVectorAddition
    MovementVector%MovementVector%Initialized:=1
  }
  GetKeyState, MovementButtonState, % MovementVector%MovementVector%Name, P
  If (MovementButtonState="U" and (MouseButtonMovementLockDownState=0 or (MouseButtonMovementLockDownState=1 and MovementVector%MovementVector%UnHoldStep=2)))
  {
    MovementButtonName:=MovementVector%MovementVector%Name
    MovementButtonDown_%MovementButtonName%:=0
    MovementVector%MovementVector%Magnitude:=-MovementVector%MovementVector%Magnitude
    Gosub, MovementVectorAddition
    MovementVectorTemp:=MovementVector
    MovementVectorTempPrev:=MovementVector-1
    Loop
    {
      MovementVectorTemp:=MovementVectorTemp+1
      MovementVectorTempPrev:=MovementVectorTempPrev+1
      If (MovementVectors<MovementVectorTemp)
      {
        MovementVector%MovementVectorTempPrev%Name:=""
        MovementVector%MovementVectorTempPrev%Direction:=0
        MovementVector%MovementVectorTempPrev%Magnitude:=0
        MovementVector%MovementVectorTempPrev%Initialized:=0
        MovementVector%MovementVectorTempPrev%UnHoldStep:=0
        Break
      }
      MovementVector%MovementVectorTempPrev%Name:=MovementVector%MovementVectorTemp%Name
      MovementVector%MovementVectorTempPrev%Direction:=MovementVector%MovementVectorTemp%Direction
      MovementVector%MovementVectorTempPrev%Magnitude:=MovementVector%MovementVectorTemp%Magnitude
      MovementVector%MovementVectorTempPrev%Initialized:=MovementVector%MovementVectorTemp%Initialized
      MovementVector%MovementVectorTempPrev%UnHoldStep:=MovementVector%MovementVectorTemp%UnHoldStep
    }
    MovementVectors:=MovementVectors-1
  }
 
  If(MovementButtonState="U" and MouseButtonMovementLockDownState=1 and MovementVector%MovementVector%UnHoldStep=0)
    MovementVector%MovementVector%UnHoldStep:=1
  If(MovementButtonState="D" and MouseButtonMovementLockDownState=1 and MovementVector%MovementVector%UnHoldStep=1)
    MovementVector%MovementVector%UnHoldStep:=2
 
  If (MovementVectors<=MovementVector)
    Break
}
If (MouseCurrentAccelerationSpeed<MouseMaxSpeed)
  MouseCurrentAccelerationSpeed:=MouseCurrentAccelerationSpeed+(MouseAccelerationSpeed/MouseAccelerationCycles)
MovementResultantVectorMagnitude:=MouseCurrentAccelerationSpeed*MovementVectorMagnitudeRatio
MovementResultantVectorDirection:=MovementVectorDirection
MovementResultantVectorX:=MovementResultantVectorMagnitude*Cos(MovementResultantVectorDirection)
MovementResultantVectorY:=MovementResultantVectorMagnitude*Sin(MovementResultantVectorDirection)
;TrayTip,,% "(" . MovementResultantVectorMagnitude . "," . MovementResultantVectorDirection . ") - <" . MovementResultantVectorX . "," . MovementResultantVectorY . ">"
MouseMove, % MovementResultantVectorX, % -MovementResultantVectorY, 0, R
Return

;Mouse wheel movement support
ButtonWheelDownRight:
MovementWheelVectorDirectionTemp+=1
ButtonWheelDown:
MovementWheelVectorDirectionTemp+=1
ButtonWheelDownLeft:
MovementWheelVectorDirectionTemp+=1
ButtonWheelLeft:
MovementWheelVectorDirectionTemp+=1
ButtonWheelUpLeft:
MovementWheelVectorDirectionTemp+=1
ButtonWheelUp:
MovementWheelVectorDirectionTemp+=1
ButtonWheelUpRight:
MovementWheelVectorDirectionTemp+=1
ButtonWheelRight:
StringReplace, MovementWheelButtonName, A_ThisHotkey, *
If (MovementWheelButtonDown_%MovementWheelButtonName%!=1)
{
  MovementWheelButtonDown_%MovementWheelButtonName%:=1
  MovementWheelVectors:=MovementWheelVectors+1
  MovementWheelVector%MovementWheelVectors%Name:=MovementWheelButtonName
  MovementWheelVector%MovementWheelVectors%Direction:=(MovementWheelVectorDirectionTemp*PI/4)+(MouseWheelRotationAngle*PI/180)
  MovementWheelVector%MovementWheelVectors%Magnitude:=MouseWheelSpeed
  MovementWheelVector%MovementWheelVectors%Initialized:=0
  MovementWheelVector%MovementWheelVectors%UnHoldStep:=0
 
  If (MovementWheelVectors = 1)
  {
    MouseWheelCurrentAccelerationSpeed:=MouseWheelSpeed
    SetTimer, MovementWheelVectorAcceleration, % MouseWheelAccelerationTimerInterval
  }
}
MovementWheelVectorDirectionTemp:=0
Return

MovementWheelVectorAddition:
;Add 2 vectors
MovementWheelVectorX:=MovementWheelVectorMagnitude*Cos(MovementWheelVectorDirection)+MovementWheelVector%MovementWheelVector%Magnitude*Cos(MovementWheelVector%MovementWheelVector%Direction)
MovementWheelVectorY:=MovementWheelVectorMagnitude*Sin(MovementWheelVectorDirection)+MovementWheelVector%MovementWheelVector%Magnitude*Sin(MovementWheelVector%MovementWheelVector%Direction)
MovementWheelVectorMagnitude:=Sqrt(MovementWheelVectorX**2+MovementWheelVectorY**2)
MovementWheelVectorDirection:=ATan(MovementWheelVectorY/MovementWheelVectorX)
If (MovementWheelVectorX<0)
{
  If (MovementWheelVectorY>0)
    MovementWheelVectorDirection:=MovementWheelVectorDirection-PI
  Else
    MovementWheelVectorDirection:=PI+MovementWheelVectorDirection
}
MovementWheelVectorMagnitudeRatio:=MovementWheelVectorMagnitude/MouseWheelSpeed
Return

MovementWheelVectorAcceleration:
If (MovementWheelVectors=0)
{
  MovementWheelVectorX:=0.000000
  MovementWheelVectorY:=0.000000
  MovementWheelVectorMagnitude:=0.000000
  MovementWheelVectorDirection:=0.000000
  MovementWheelVectorMagnitudeRatio:=0.000000

  MovementWheelResultantVectorMagnitude:=0.000000
  MovementWheelResultantVectorDirection:=0.000000
  MovementWheelResultantVectorX:=0.000000
  MovementWheelResultantVectorY:=0.000000
 
  ;TrayTip,,% "(" . MovementResultantVectorMagnitude . "," . MovementResultantVectorDirection . ") - <" . MovementResultantVectorX . "," . MovementResultantVectorY . ">"
  SetTimer, MovementWheelVectorAcceleration, off
  Return
}

MovementWheelVector:=0
Loop
{
  MovementWheelVector:=MovementWheelVector+1
  If (MovementWheelVector%MovementWheelVector%Initialized=0)
  {
    Gosub, MovementWheelVectorAddition
    MovementWheelVector%MovementWheelVector%Initialized:=1
  }
 
  GetKeyState, MovementWheelButtonState, % MovementWheelVector%MovementWheelVector%Name, P
  If (MovementWheelButtonState="U" and (MouseButtonMovementLockDownState=0 or (MouseButtonMovementLockDownState=1 and MovementWheelVector%MovementWheelVector%UnHoldStep=2)))
  {
    MovementWheelButtonName:=MovementWheelVector%MovementWheelVector%Name
    MovementWheelButtonDown_%MovementWheelButtonName%:=0
    MovementWheelVector%MovementWheelVector%Magnitude:=-MovementWheelVector%MovementWheelVector%Magnitude
    Gosub, MovementWheelVectorAddition
   
    MovementWheelVectorTemp:=MovementWheelVector
    MovementWheelVectorTempPrev:=MovementWheelVector-1
    Loop
    {
      MovementWheelVectorTemp:=MovementWheelVectorTemp+1
      MovementWheelVectorTempPrev:=MovementWheelVectorTempPrev+1
     
      If (MovementWheelVectors<MovementWheelVectorTemp)
      {
        MovementWheelVector%MovementWheelVectorTempPrev%Name:=""
        MovementWheelVector%MovementWheelVectorTempPrev%Direction:=0
        MovementWheelVector%MovementWheelVectorTempPrev%Magnitude:=0
        MovementWheelVector%MovementWheelVectorTempPrev%Initialized:=0
        MovementWheelVector%MovementWheelVectorTempPrev%UnHoldStep:=0
        Break
      }
     
      MovementWheelVector%MovementWheelVectorTempPrev%Name:=MovementWheelVector%MovementWheelVectorTemp%Name
      MovementWheelVector%MovementWheelVectorTempPrev%Direction:=MovementWheelVector%MovementWheelVectorTemp%Direction
      MovementWheelVector%MovementWheelVectorTempPrev%Magnitude:=MovementWheelVector%MovementWheelVectorTemp%Magnitude
      MovementWheelVector%MovementWheelVectorTempPrev%Initialized:=MovementWheelVector%MovementWheelVectorTemp%Initialized
      MovementWheelVector%MovementWheelVectorTempPrev%UnHoldStep:=MovementWheelVector%MovementWheelVectorTemp%UnHoldStep
    }
    MovementWheelVectors:=MovementWheelVectors-1
  }
  If(MovementWheelButtonState="U" and MouseButtonMovementLockDownState=1 and MovementWheelVector%MovementWheelVector%UnHoldStep=0)
    MovementWheelVector%MovementWheelVector%UnHoldStep:=1
  If(MovementWheelButtonState="D" and MouseButtonMovementLockDownState=1 and MovementWheelVector%MovementWheelVector%UnHoldStep=1)
    MovementWheelVector%MovementWheelVector%UnHoldStep:=2

  If (MovementWheelVectors<=MovementWheelVector)
    Break
}

If (MouseWheelCurrentAccelerationSpeed<MouseWheelMaxSpeed)
  MouseWheelCurrentAccelerationSpeed:=MouseWheelCurrentAccelerationSpeed+(MouseWheelAccelerationSpeed/MouseWheelAccelerationCycles)

MovementWheelResultantVectorMagnitude:=MouseWheelCurrentAccelerationSpeed*MovementWheelVectorMagnitudeRatio
MovementWheelResultantVectorDirection:=MovementWheelVectorDirection
MovementWheelResultantVectorX:=MovementWheelResultantVectorMagnitude*Cos(MovementWheelResultantVectorDirection)
MovementWheelResultantVectorY:=MovementWheelResultantVectorMagnitude*Sin(MovementWheelResultantVectorDirection)
;TrayTip,,% "(" . MovementResultantVectorMagnitude . "," . MovementResultantVectorDirection . ") - <" . MovementResultantVectorX . "," . MovementResultantVectorY . ">"

If (MovementWheelResultantVectorX>=0)
  MouseClick, wheelright,,, % MovementWheelResultantVectorX, 0, D
Else
  MouseClick, wheelleft,,, % -MovementWheelResultantVectorX, 0, D

If (MovementWheelResultantVectorY>=0)
  MouseClick, wheelup,,, % MovementWheelResultantVectorY, 0, D
Else
  MouseClick, wheeldown,,, % -MovementWheelResultantVectorY, 0, D
Return


;Speed/rotation configuration support
;Movement
ButtonSpeedUp:
MouseSpeed:=MouseSpeed+2
ButtonSpeedDown:
MouseSpeed--
If (MouseSpeed>MouseMaxSpeed)
  MouseSpeed:=MouseMaxSpeed
If (MouseSpeed<=1)
{
  MouseSpeed:=1
  ToolTip, Mouse speed: %MouseSpeed% pixel
}
Else
  ToolTip, Mouse speed: %MouseSpeed% pixels
SetTimer, RemoveToolTip, 1000
Return

ButtonAccelerationSpeedUp:
MouseAccelerationSpeed:=MouseAccelerationSpeed+2
ButtonAccelerationSpeedDown:
MouseAccelerationSpeed--
If (MouseAccelerationSpeed<=1)
{
  MouseAccelerationSpeed:=1
  ToolTip, Mouse acceleration speed: %MouseAccelerationSpeed% pixel/cycle
}
Else
  ToolTip, Mouse acceleration speed: %MouseAccelerationSpeed% pixels/cycle
SetTimer, RemoveToolTip, 1000
Return

ButtonMaxSpeedUp:
MouseMaxSpeed:=MouseMaxSpeed+2
ButtonMaxSpeedDown:
MouseMaxSpeed--
If (MouseSpeed>MouseMaxSpeed)
  MouseSpeed:=MouseMaxSpeed
If (MouseMaxSpeed<=1)
{
  MouseMaxSpeed:=1
  ToolTip, Mouse maximum speed: %MouseMaxSpeed% pixel
}
Else
  ToolTip, Mouse maximum speed: %MouseMaxSpeed% pixels
SetTimer, RemoveToolTip, 1000
Return

ButtonRotationAngleUp:
MouseRotationAnglePart:=MouseRotationAnglePart+2
ButtonRotationAngleDown:
MouseRotationAnglePart--
If(MouseRotationAnglePart>=8)
  MouseRotationAnglePart:=0
If(MouseRotationAnglePart<0)
  MouseRotationAnglePart:=7
MouseRotationAngle = %MouseRotationAnglePart%
MouseRotationAngle *= 45
ToolTip, Mouse rotation angle: %MouseRotationAngle%°
SetTimer, RemoveToolTip, 1000
Return

;Wheel
ButtonWheelSpeedUp:
MouseWheelSpeed:=MouseWheelSpeed+2
ButtonWheelSpeedDown:
MouseWheelSpeed--
If (MouseWheelSpeed>MouseWheelMaxSpeed)
  MouseWheelSpeed:=MouseWheelMaxSpeed
If (MouseWheelSpeed<=1)
  MouseWheelSpeed:=1
RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
MouseWheelSpeedTemp:=MouseWheelSpeed*MouseWheelSpeedMultiplier
If (MouseWheelSpeedTemp=1)
  ToolTip, Mouse wheel speed: %MouseWheelSpeedTemp% line
Else
  ToolTip, Mouse wheel speed: %MouseWheelSpeedTemp% lines
SetTimer, RemoveToolTip, 1000
Return

ButtonWheelAccelerationSpeedUp:
MouseWheelAccelerationSpeed:=MouseWheelAccelerationSpeed+2
ButtonWheelAccelerationSpeedDown:
MouseWheelAccelerationSpeed--
If (MouseWheelAccelerationSpeed<=1)
  MouseWheelAccelerationSpeed:=1
RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
MouseWheelAccelerationSpeedTemp:=MouseWheelAccelerationSpeed*MouseWheelSpeedMultiplier
If (MouseWheelAccelerationSpeedTemp=1)
  ToolTip, Mouse wheel acceleration speed: %MouseWheelAccelerationSpeedTemp% line/cycle
Else
  ToolTip, Mouse wheel acceleration speed: %MouseWheelAccelerationSpeedTemp% lines/cycle
SetTimer, RemoveToolTip, 1000
Return

ButtonWheelMaxSpeedUp:
MouseWheelMaxSpeed:=MouseWheelMaxSpeed+2
ButtonWheelMaxSpeedDown:
MouseWheelMaxSpeed--
If (MouseWheelSpeed>MouseWheelMaxSpeed)
  MouseWheelSpeed:=MouseWheelMaxSpeed
If (MouseWheelMaxSpeed<=1)
  MouseWheelMaxSpeed:=1
RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
MouseWheelMaxSpeedTemp:=MouseWheelMaxSpeed*MouseWheelSpeedMultiplier
If (MouseWheelMaxSpeedTemp=1)
  ToolTip, Mouse wheel max speed: %MouseWheelMaxSpeedTemp% line
Else
  ToolTip, Mouse wheel max speed: %MouseWheelMaxSpeedTemp% lines
SetTimer, RemoveToolTip, 1000
Return

ButtonWheelRotationAngleUp:
MouseWheelRotationAnglePart:=MouseWheelRotationAnglePart+2
ButtonWheelRotationAngleDown:
MouseWheelRotationAnglePart--
If(MouseWheelRotationAnglePart>=8)
  MouseWheelRotationAnglePart:=0
If(MouseWheelRotationAnglePart<0)
  MouseWheelRotationAnglePart:=7
MouseWheelRotationAngle = %MouseWheelRotationAnglePart%
MouseWheelRotationAngle *= 45
ToolTip, Mouse wheel rotation angle: %MouseWheelRotationAngle%°
SetTimer, RemoveToolTip, 1000
Return

RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
Return

_________________
Working now on:
NumpadMouse v2 (Draw)
top-recode project (private server script) (pkodev)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 83 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Exabot [Bot], Google [Bot], Google Feedfetcher, JamixZol 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