Initial JKLmouse.ahk copied from NumpadMouse.ahk

; 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.22+ |
|                    ----------------------------------------|
|                                                            |
|    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.     |
|                       |                                    |
|-----------------------|------------------------------------|
| NumLock (toggled off) | Activates mouse movement mode.     |
|-----------------------|------------------------------------|
| NumPadEnd/Down/PgDn/  | Mouse movement.                    |
| /Left/Right/Home/Up/  |                                    |
| /PgUp                 |                                    |
|                       |                                    |
|-----------------------|------------------------------------|
| NumLock (toggled on)  | Activates mouse speed adj. mode.   |
|-----------------------|------------------------------------|
| NumPad7/NumPad1       | Inc./dec. acceleration per         |
|                       | button press.                      |
| NumPad8/NumPad2       | Inc./dec. initial speed per        |
|                       | button press.                      |
| NumPad9/NumPad3       | Inc./dec. maximum speed per        |
|                       | button press.                      |
| ^NumPad7/^NumPad1     | Inc./dec. wheel acceleration per   |
|                       | button press*.                     |
| ^NumPad8/^NumPad2     | Inc./dec. wheel initial speed per  |
|                       | button press*.                     |
| ^NumPad9/^NumPad3     | Inc./dec. wheel maximum speed per  |
|                       | button press*.                     |
| NumPad4/NumPad6       | Inc./dec. rotation angle to        |
|                       | right in degrees. (i.e. 180 =     |
|                       | = inversed controls).              |
|------------------------------------------------------------|
| * = These options are affected by the mouse wheel speed    |
| adjusted on Control Panel. 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 = 1
MouseAccelerationSpeed = 1
MouseMaxSpeed = 5

;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 = 1
MouseWheelAccelerationSpeed = 1
MouseWheelMaxSpeed = 5

MouseRotationAngle = 0

;END OF CONFIG SECTION

;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

MouseCurrentAccelerationSpeed = 0
MouseCurrentSpeed = %MouseSpeed%

MouseWheelCurrentAccelerationSpeed = 0
MouseWheelCurrentSpeed = %MouseSpeed%

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, *NumPadUp, ButtonUp
Hotkey, *NumPadDown, ButtonDown
Hotkey, *NumPadLeft, ButtonLeft
Hotkey, *NumPadRight, ButtonRight
Hotkey, *NumPadHome, ButtonUpLeft
Hotkey, *NumPadEnd, ButtonUpRight
Hotkey, *NumPadPgUp, ButtonDownLeft
Hotkey, *NumPadPgDn, ButtonDownRight

Hotkey, Numpad8, ButtonSpeedUp
Hotkey, Numpad2, ButtonSpeedDown
Hotkey, Numpad7, ButtonAccelerationSpeedUp
Hotkey, Numpad1, ButtonAccelerationSpeedDown
Hotkey, Numpad9, ButtonMaxSpeedUp
Hotkey, Numpad3, ButtonMaxSpeedDown

Hotkey, Numpad6, ButtonRotationAngleUp
Hotkey, Numpad4, ButtonRotationAngleDown

Hotkey, !Numpad8, ButtonWheelSpeedUp
Hotkey, !Numpad2, ButtonWheelSpeedDown
Hotkey, !Numpad7, ButtonWheelAccelerationSpeedUp
Hotkey, !Numpad1, ButtonWheelAccelerationSpeedDown
Hotkey, !Numpad9, ButtonWheelMaxSpeedUp
Hotkey, !Numpad3, ButtonWheelMaxSpeedDown

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, Numpad8, on
	Hotkey, Numpad2, on
	Hotkey, Numpad7, on
	Hotkey, Numpad1, on
	Hotkey, Numpad9, on
	Hotkey, Numpad3, on

	Hotkey, Numpad6, on
	Hotkey, Numpad4, on

	Hotkey, !Numpad8, on
	Hotkey, !Numpad2, on
	Hotkey, !Numpad7, on
	Hotkey, !Numpad1, on
	Hotkey, !Numpad9, on
	Hotkey, !Numpad3, 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, Numpad8, off
	Hotkey, Numpad2, off
	Hotkey, Numpad7, off
	Hotkey, Numpad1, off
	Hotkey, Numpad9, off
	Hotkey, Numpad3, off

	Hotkey, Numpad6, off
	Hotkey, Numpad4, off

	Hotkey, !Numpad8, off
	Hotkey, !Numpad2, off
	Hotkey, !Numpad7, off
	Hotkey, !Numpad1, off
	Hotkey, !Numpad9, off
	Hotkey, !Numpad3, off
}
return

;Mouse click support

ButtonLeftClick:
GetKeyState, already_down_state, LButton
If already_down_state = D
	return
Button2 = NumPad0
ButtonClick = Left
Goto ButtonClickStart
ButtonLeftClickIns:
GetKeyState, already_down_state, LButton
If already_down_state = D
	return
Button2 = NumPadIns
ButtonClick = Left
Goto ButtonClickStart

ButtonMiddleClick:
GetKeyState, already_down_state, MButton
If already_down_state = D
	return
Button2 = NumPad5
ButtonClick = Middle
Goto ButtonClickStart
ButtonMiddleClickClear:
GetKeyState, already_down_state, MButton
If already_down_state = D
	return
Button2 = NumPadClear
ButtonClick = Middle
Goto ButtonClickStart

ButtonRightClick:
GetKeyState, already_down_state, RButton
If already_down_state = D
	return
Button2 = NumPadDot
ButtonClick = Right
Goto ButtonClickStart
ButtonRightClickDel:
GetKeyState, already_down_state, RButton
If already_down_state = D
	return
Button2 = NumPadDel
ButtonClick = Right
Goto ButtonClickStart

ButtonX1Click:
GetKeyState, already_down_state, XButton1
If already_down_state = D
	return
Button2 = NumPadDiv
ButtonClick = X1
Goto ButtonClickStart

ButtonX2Click:
GetKeyState, already_down_state, XButton2
If already_down_state = D
	return
Button2 = NumPadMult
ButtonClick = X2
Goto ButtonClickStart

ButtonClickStart:
MouseClick, %ButtonClick%,,, 1, 0, D
SetTimer, ButtonClickEnd, 10
return

ButtonClickEnd:
GetKeyState, kclickstate, %Button2%, P
if kclickstate = D
	return

SetTimer, ButtonClickEnd, off
MouseClick, %ButtonClick%,,, 1, 0, U
return

;Mouse movement support

ButtonSpeedUp:
MouseSpeed++
ToolTip, Mouse speed: %MouseSpeed% pixels
SetTimer, RemoveToolTip, 1000
return
ButtonSpeedDown:
If MouseSpeed > 1
	MouseSpeed--
If MouseSpeed = 1
	ToolTip, Mouse speed: %MouseSpeed% pixel
else
	ToolTip, Mouse speed: %MouseSpeed% pixels
SetTimer, RemoveToolTip, 1000
return
ButtonAccelerationSpeedUp:
MouseAccelerationSpeed++
ToolTip, Mouse acceleration speed: %MouseAccelerationSpeed% pixels
SetTimer, RemoveToolTip, 1000
return
ButtonAccelerationSpeedDown:
If MouseAccelerationSpeed > 1
	MouseAccelerationSpeed--
If MouseAccelerationSpeed = 1
	ToolTip, Mouse acceleration speed: %MouseAccelerationSpeed% pixel
else
	ToolTip, Mouse acceleration speed: %MouseAccelerationSpeed% pixels
SetTimer, RemoveToolTip, 1000
return

ButtonMaxSpeedUp:
MouseMaxSpeed++
ToolTip, Mouse maximum speed: %MouseMaxSpeed% pixels
SetTimer, RemoveToolTip, 1000
return
ButtonMaxSpeedDown:
If MouseMaxSpeed > 1
	MouseMaxSpeed--
If MouseMaxSpeed = 1
	ToolTip, Mouse maximum speed: %MouseMaxSpeed% pixel
else
	ToolTip, Mouse maximum speed: %MouseMaxSpeed% pixels
SetTimer, RemoveToolTip, 1000
return

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

ButtonUp:
ButtonDown:
ButtonLeft:
ButtonRight:
ButtonUpLeft:
ButtonUpRight:
ButtonDownLeft:
ButtonDownRight:
If Button <> 0
{
	IfNotInString, A_ThisHotkey, %Button%
	{
		MouseCurrentAccelerationSpeed = 0
		MouseCurrentSpeed = %MouseSpeed%
	}
}
StringReplace, Button, A_ThisHotkey, *

ButtonAccelerationStart:
If MouseAccelerationSpeed >= 1
{
	If MouseMaxSpeed > %MouseCurrentSpeed%
	{
		Temp = 0.001
		Temp *= %MouseAccelerationSpeed%
		MouseCurrentAccelerationSpeed += %Temp%
		MouseCurrentSpeed += %MouseCurrentAccelerationSpeed%
	}
}

;MouseRotationAngle convertion to speed of button direction
{
	MouseCurrentSpeedToDirection = %MouseRotationAngle%
	MouseCurrentSpeedToDirection /= 90.0
	Temp = %MouseCurrentSpeedToDirection%

	if Temp >= 0
	{
		if Temp < 1
		{
			MouseCurrentSpeedToDirection = 1
			MouseCurrentSpeedToDirection -= %Temp%
			Goto EndMouseCurrentSpeedToDirectionCalculation
		}
	}
	if Temp >= 1
	{
		if Temp < 2
		{
			MouseCurrentSpeedToDirection = 0
			Temp -= 1
			MouseCurrentSpeedToDirection -= %Temp%
			Goto EndMouseCurrentSpeedToDirectionCalculation
		}
	}
	if Temp >= 2
	{
		if Temp < 3
		{
			MouseCurrentSpeedToDirection = -1
			Temp -= 2
			MouseCurrentSpeedToDirection += %Temp%
			Goto EndMouseCurrentSpeedToDirectionCalculation
		}
	}
	if Temp >= 3
	{
		if Temp < 4
		{
			MouseCurrentSpeedToDirection = 0
			Temp -= 3
			MouseCurrentSpeedToDirection += %Temp%
			Goto EndMouseCurrentSpeedToDirectionCalculation
		}
	}
}
EndMouseCurrentSpeedToDirectionCalculation:

;MouseRotationAngle convertion to speed of 90 degrees to right
{
	MouseCurrentSpeedToSide = %MouseRotationAngle%
	MouseCurrentSpeedToSide /= 90.0
	Temp = %MouseCurrentSpeedToSide%
	Transform, Temp, mod, %Temp%, 4

	if Temp >= 0
	{
		if Temp < 1
		{
			MouseCurrentSpeedToSide = 0
			MouseCurrentSpeedToSide += %Temp%
			Goto EndMouseCurrentSpeedToSideCalculation
		}
	}
	if Temp >= 1
	{
		if Temp < 2
		{
			MouseCurrentSpeedToSide = 1
			Temp -= 1
			MouseCurrentSpeedToSide -= %Temp%
			Goto EndMouseCurrentSpeedToSideCalculation
		}
	}
	if Temp >= 2
	{
		if Temp < 3
		{
			MouseCurrentSpeedToSide = 0
			Temp -= 2
			MouseCurrentSpeedToSide -= %Temp%
			Goto EndMouseCurrentSpeedToSideCalculation
		}
	}
	if Temp >= 3
	{
		if Temp < 4
		{
			MouseCurrentSpeedToSide = -1
			Temp -= 3
			MouseCurrentSpeedToSide += %Temp%
			Goto EndMouseCurrentSpeedToSideCalculation
		}
	}
}
EndMouseCurrentSpeedToSideCalculation:

MouseCurrentSpeedToDirection *= %MouseCurrentSpeed%
MouseCurrentSpeedToSide *= %MouseCurrentSpeed%

Temp = %MouseRotationAnglePart%
Transform, Temp, Mod, %Temp%, 2

If Button = NumPadUp
{
	if Temp = 1
	{
		MouseCurrentSpeedToSide *= 2
		MouseCurrentSpeedToDirection *= 2
	}

	MouseCurrentSpeedToDirection *= -1
	MouseMove, %MouseCurrentSpeedToSide%, %MouseCurrentSpeedToDirection%, 0, R
}
else if Button = NumPadDown
{
	if Temp = 1
	{
		MouseCurrentSpeedToSide *= 2
		MouseCurrentSpeedToDirection *= 2
	}

	MouseCurrentSpeedToSide *= -1
	MouseMove, %MouseCurrentSpeedToSide%, %MouseCurrentSpeedToDirection%, 0, R
}
else if Button = NumPadLeft
{
	if Temp = 1
	{
		MouseCurrentSpeedToSide *= 2
		MouseCurrentSpeedToDirection *= 2
	}

	MouseCurrentSpeedToSide *= -1
	MouseCurrentSpeedToDirection *= -1

	MouseMove, %MouseCurrentSpeedToDirection%, %MouseCurrentSpeedToSide%, 0, R
}
else if Button = NumPadRight
{
	if Temp = 1
	{
		MouseCurrentSpeedToSide *= 2
		MouseCurrentSpeedToDirection *= 2
	}

	MouseMove, %MouseCurrentSpeedToDirection%, %MouseCurrentSpeedToSide%, 0, R
}
else if Button = NumPadHome
{
	Temp = %MouseCurrentSpeedToDirection%
	Temp -= %MouseCurrentSpeedToSide%
	Temp *= -1
	Temp2 = %MouseCurrentSpeedToDirection%
	Temp2 += %MouseCurrentSpeedToSide%
	Temp2 *= -1
	MouseMove, %Temp%, %Temp2%, 0, R
}
else if Button = NumPadPgUp
{
	Temp = %MouseCurrentSpeedToDirection%
	Temp += %MouseCurrentSpeedToSide%
	Temp2 = %MouseCurrentSpeedToDirection%
	Temp2 -= %MouseCurrentSpeedToSide%
	Temp2 *= -1
	MouseMove, %Temp%, %Temp2%, 0, R
}
else if Button = NumPadEnd
{
	Temp = %MouseCurrentSpeedToDirection%
	Temp += %MouseCurrentSpeedToSide%
	Temp *= -1
	Temp2 = %MouseCurrentSpeedToDirection%
	Temp2 -= %MouseCurrentSpeedToSide%
	MouseMove, %Temp%, %Temp2%, 0, R
}
else if Button = NumPadPgDn
{
	Temp = %MouseCurrentSpeedToDirection%
	Temp -= %MouseCurrentSpeedToSide%
	Temp2 *= -1
	Temp2 = %MouseCurrentSpeedToDirection%
	Temp2 += %MouseCurrentSpeedToSide%
	MouseMove, %Temp%, %Temp2%, 0, R
}

SetTimer, ButtonAccelerationEnd, 10
return

ButtonAccelerationEnd:
GetKeyState, kstate, %Button%, P
if kstate = D
	Goto ButtonAccelerationStart

SetTimer, ButtonAccelerationEnd, off
MouseCurrentAccelerationSpeed = 0
MouseCurrentSpeed = %MouseSpeed%
Button = 0
return

;Mouse wheel movement support

ButtonWheelSpeedUp:
MouseWheelSpeed++
RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
If MouseWheelSpeedMultiplier <= 0
	MouseWheelSpeedMultiplier = 1
MouseWheelSpeedReal = %MouseWheelSpeed%
MouseWheelSpeedReal *= %MouseWheelSpeedMultiplier%
ToolTip, Mouse wheel speed: %MouseWheelSpeedReal% lines
SetTimer, RemoveToolTip, 1000
return
ButtonWheelSpeedDown:
RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
If MouseWheelSpeedMultiplier <= 0
	MouseWheelSpeedMultiplier = 1
If MouseWheelSpeedReal > %MouseWheelSpeedMultiplier%
{
	MouseWheelSpeed--
	MouseWheelSpeedReal = %MouseWheelSpeed%
	MouseWheelSpeedReal *= %MouseWheelSpeedMultiplier%
}
If MouseWheelSpeedReal = 1
	ToolTip, Mouse wheel speed: %MouseWheelSpeedReal% line
else
	ToolTip, Mouse wheel speed: %MouseWheelSpeedReal% lines
SetTimer, RemoveToolTip, 1000
return

ButtonWheelAccelerationSpeedUp:
MouseWheelAccelerationSpeed++
RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
If MouseWheelSpeedMultiplier <= 0
	MouseWheelSpeedMultiplier = 1
MouseWheelAccelerationSpeedReal = %MouseWheelAccelerationSpeed%
MouseWheelAccelerationSpeedReal *= %MouseWheelSpeedMultiplier%
ToolTip, Mouse wheel acceleration speed: %MouseWheelAccelerationSpeedReal% lines
SetTimer, RemoveToolTip, 1000
return
ButtonWheelAccelerationSpeedDown:
RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
If MouseWheelSpeedMultiplier <= 0
	MouseWheelSpeedMultiplier = 1
If MouseWheelAccelerationSpeed > 1
{
	MouseWheelAccelerationSpeed--
	MouseWheelAccelerationSpeedReal = %MouseWheelAccelerationSpeed%
	MouseWheelAccelerationSpeedReal *= %MouseWheelSpeedMultiplier%
}
If MouseWheelAccelerationSpeedReal = 1
	ToolTip, Mouse wheel acceleration speed: %MouseWheelAccelerationSpeedReal% line
else
	ToolTip, Mouse wheel acceleration speed: %MouseWheelAccelerationSpeedReal% lines
SetTimer, RemoveToolTip, 1000
return

ButtonWheelMaxSpeedUp:
MouseWheelMaxSpeed++
RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
If MouseWheelSpeedMultiplier <= 0
	MouseWheelSpeedMultiplier = 1
MouseWheelMaxSpeedReal = %MouseWheelMaxSpeed%
MouseWheelMaxSpeedReal *= %MouseWheelSpeedMultiplier%
ToolTip, Mouse wheel maximum speed: %MouseWheelMaxSpeedReal% lines
SetTimer, RemoveToolTip, 1000
return
ButtonWheelMaxSpeedDown:
RegRead, MouseWheelSpeedMultiplier, HKCU, Control Panel\Desktop, WheelScrollLines
If MouseWheelSpeedMultiplier <= 0
	MouseWheelSpeedMultiplier = 1
If MouseWheelMaxSpeed > 1
{
	MouseWheelMaxSpeed--
	MouseWheelMaxSpeedReal = %MouseWheelMaxSpeed%
	MouseWheelMaxSpeedReal *= %MouseWheelSpeedMultiplier%
}
If MouseWheelMaxSpeedReal = 1
	ToolTip, Mouse wheel maximum speed: %MouseWheelMaxSpeedReal% line
else
	ToolTip, Mouse wheel maximum speed: %MouseWheelMaxSpeedReal% lines
SetTimer, RemoveToolTip, 1000
return

ButtonWheelUp:
ButtonWheelDown:

If Button <> 0
{
	If Button <> %A_ThisHotkey%
	{
		MouseWheelCurrentAccelerationSpeed = 0
		MouseWheelCurrentSpeed = %MouseWheelSpeed%
	}
}
StringReplace, Button, A_ThisHotkey, *

ButtonWheelAccelerationStart:
If MouseWheelAccelerationSpeed >= 1
{
	If MouseWheelMaxSpeed > %MouseWheelCurrentSpeed%
	{
		Temp = 0.001
		Temp *= %MouseWheelAccelerationSpeed%
		MouseWheelCurrentAccelerationSpeed += %Temp%
		MouseWheelCurrentSpeed += %MouseWheelCurrentAccelerationSpeed%
	}
}

If Button = NumPadSub
	MouseClick, wheelup,,, %MouseWheelCurrentSpeed%, 0, D
else if Button = NumPadAdd
	MouseClick, wheeldown,,, %MouseWheelCurrentSpeed%, 0, D

SetTimer, ButtonWheelAccelerationEnd, 100
return

ButtonWheelAccelerationEnd:
GetKeyState, kstate, %Button%, P
if kstate = D
	Goto ButtonWheelAccelerationStart

MouseWheelCurrentAccelerationSpeed = 0
MouseWheelCurrentSpeed = %MouseWheelSpeed%
Button = 0
return

RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
return

error: pathspec 'JKLmouse.ahk' did not match any file(s) known to git


Add a script to launch the 'keep window on top' from other programs

#NoTrayIcon
#Persistent
#SingleInstance force
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Send !+^{T}

error: pathspec 'autohotkey/keep_window_on_top.ahk' did not match any file(s) known to git


Updated on 2015-10-11: qttabbar

Updated on 2015-10-11: qttabbar

; default environment
DetectHiddenWindows, off
SetControlDelay, 20

; modified environment
#NoEnv
#NoTrayIcon
DetectHiddenText, off
SetTitleMatchMode, 2

; variables
winTitleIE = - Internet Explorer ahk_class IEFrame ahk_exe iexplore.exe
winTitleAddons = Manage Add-ons ahk_class #32770 ahk_exe iexplore.exe
winTitleEnable = Enable add-on ahk_class #32770 ahk_exe iexplore.exe

Process, Exist, iexplore.exe
if !ErrorLevel = 0 {
  procExists = 1
  WinActivate,%winTitleIE%
} else {
  procExists = 0
  Run, iexplore, , , pid
;  WinWait, ahk_pid %pid%, Address Bar, 60  ;too quick
;  WinActivate, ahk_pid %pid%, , 10
  WinWait, %winTitleIE%, , 60
  WinActivate, %winTitleIE%, , 60
  Send {ALT Down}x{ALT Up}m
  Sleep 250
}

Send {TAB 2}QTTabBar{ALT Down}e{ALT Up}
Sleep 1000

IfWinActive, %winTitleEnable%
{
  Send {ENTER}
  Send {ALT Down}l{ALT Up}
  CloseIE()
  sleep 10000
  Return
}
IfWinActive, %winTitleAddons%
{
  Send {ALT Down}l{ALT Up}
  CloseIE()
}

CloseIE()
{
  if procExists = 1
  {
    WinActivate,%winTitleIE%,
    Send, ^w
  }
  else
  {
    WinClose, ahk_exe iexplore.exe
  }
}

; File Explorer
Run, explorer
WinWait, ahk_exe explorer.exe, , 60
WinActivate, ahk_exe explorer.exe
Sleep 500
SetKeyDelay 50
Send {ALT}
Send {V}
Send {Y}
Send {DOWN 2}
Send {SPACE}
Send {ALT down}{F4}

error: pathspec 'automatic/_output/qttabbar/1032.0/tools/chocolateyInstall.ahk' did not match any file(s) known to git


add testing

add testing

#s::
    ; 正面
    Send, add -k ptt ezsoft{Enter}
    Sleep, 1500

    Send add -k ptt&alertor ezsoft{Enter}
    Sleep, 1500

    Send, add -a chodino ezsoft{Enter}
    Sleep, 1500

    Send, add -p 10 ezsoft{Enter}
    Sleep, 1500

    Send, add -b 10 ezsoft{Enter}
    Sleep, 1500

    Send, add -k ptt -a chodino -p 10 -b 10 ezsoft,gossiping{Enter}
    Sleep, 1500

    Send, list{Enter}
    Sleep, 1500

    ; 反面
    Send add -a 你好 ezsoft{Enter}
    Sleep, 1500

    Send add -k 123 ezezez{Enter}
    Sleep, 1500

    Send add -p 111 ezsoft{Enter}
    Sleep, 1500

    Send add -p abc ezsoft{Enter}
    Sleep, 1500

    Send add -b abc ezsoft{Enter}
    Sleep, 1500

    Send, list{Enter}
    Sleep, 1500

Escape::
ExitApp
Return

error: pathspec 'testing/commandline.ahk' did not match any file(s) known to git


fix SendAsc not wrok

fix SendAsc not wrok

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/mingone/efficiently.git/'


Stuff

Stuff

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/vovagrechka/fucking-everything.git/'


Updated on 2015-10-11: qttabbar

Updated on 2015-10-11: qttabbar

error: pathspec 'automatic/_output/qttabbar/1035.0/tools/chocolateyInstall.ahk' did not match any file(s) known to git


hot key script

hot key script

; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a
; semicolon, such as this one, are comments.  They are not executed.

; This script has a special filename and path because it is automatically
; launched when you run the program directly.  Also, any text file whose
; name ends in .ahk is associated with the program, which means that it
; can be launched simply by double-clicking it.  You can have as many .ahk
; files as you want, located in any folder.  You can also run more than
; one .ahk file simultaneously and each will get its own tray icon.

; SAMPLE HOTKEYS: Below are two sample hotkeys.  The first is Win+Z and it
; launches a web site in the default browser.  The second is Control+Alt+N
; and it launches a new Notepad window (or activates an existing one).  To
; try out these hotkeys, run AutoHotkey again, which will load this file.

;#z::Run www.autohotkey.com

;^!n::
;IfWinExist Untitled - Notepad
;	WinActivate
;else
;	Run Notepad
;return

#a::Send Administrator{Tab}Administrator

F1::Send jaimie{Tab}jaimie

!z::
CoordMode, Mouse, Screen
MouseMove, (A_ScreenWidth // 2), (A_ScreenHeight // 2)
return

<^>!]::Send {End}
<^>![::Send {Home}

+<^>!]::Send +{End}
+<^>![::Send +{Home}

; Note: From now on whenever you run AutoHotkey directly, this script
; will be loaded.  So feel free to customize it to suit your needs.

; Please read the QUICK-START TUTORIAL near the top of the help file.
; It explains how to perform common automation tasks such as sending
; keystrokes and mouse clicks.  It also explains more about hotkeys.

;stepping instructions for eclipse
#IfWinActive  ahk_class SWT_Window0
<^>!1:: Send {F5}
<^>!2:: Send {F6}
<^>!3:: Send {F7}
<^>!4:: Send {F8}
#IfWinActive

;stepping instructions for firebug
#IfWinActive Firebug
<^>!1:: Send {F11}
<^>!2:: Send {F10}
<^>!3:: Send +{F11}
<^>!4:: Send {F8}
#IfWinActive

;stepping instructions for firefox
#IfWinActive ahk_class MozillaWindowClass
<^>!1:: Send {F11}
<^>!2:: Send {F10}
<^>!3:: Send +{F11}
<^>!4:: Send {F8}
#IfWinActive

;stepping instructions for chrome
#IfWinActive ahk_class Chrome_WidgetWin_1
<^>!1:: Send {F11}
<^>!2:: Send {F10}
<^>!3:: Send +{F11}
<^>!4:: Send {F8}
#IfWinActive

error: pathspec 'AutoHotkey.ahk' did not match any file(s) known to git


AHK sample added (Health overlay for GTA San Andreas Multiplayer)

#SingleInstance, force
#NoEnv
#include ..\..\include\ahk\overlay.ahk

text_overlay :=- 1

; Set the overlay's parameters
SetParam("use_window", "1")
SetParam("window", "GTA:SA:MP")

; Create GUI
Gui, Add, Text, x12 y10 w200 h30 , Health Overlay powered by`nhttp://www.overlay-api.net/
Gui, Show, w237 h52, Health-Overlay

SetTimer, Timer, 50
return

; Delete the overlay if the application will be closed by the user
GuiClose:
if(text_overlay != -1)
	TextDestroy(text_overlay)
ExitApp

; Timer callback
Timer:
if(text_overlay == -1)
	text_overlay := TextCreate("Arial", 6, false, false, 720, 91, 0xFFFFFFFF, "100", true, true)

if(text_overlay == -1)
	return

Obj := ReadDword(0xB6F5F0, "GTA:SA:MP", success)
if(!success)
	return

health := ReadFloat(Obj + 0x540, "GTA:SA:MP", success)
if(!success)
	return

StringTrimRight, health, health, 7

if(TextSetString(text_overlay, health) == 0)
{
	TextDestroy(text_overlay)
	text_overlay := -1
}
return

ReadDword(dwAddr, szProcess, ByRef bSuccess)
{
	bSuccess := false

	VarSetCapacity(dwValue, 4, 0)

	WinGet, pid, pid, %szProcess%

	hHandle := DllCall("OpenProcess" ,"Int",2035711,"Int",0,"UInt",pid)
	if(hHandle <= 0)
		return 0

	if(!DllCall("ReadProcessMemory", "UInt", hHandle, "UInt", dwAddr, "UInt", &dwValue, "UInt", 4, "UInt *", 0))
		return 0

	DllCall("CloseHandle", "UInt", hHandle)
	bSuccess := true

	Loop 4
	result += *(&dwValue + A_Index-1) << 8*(A_Index-1)

	return result
}

ReadFloat(dwAddr, szProcess, byref bSuccess)
{
	bSuccess := false

	VarSetCapacity(fValue,4,0)

	WinGet, pid, pid, %szProcess%

	hHandle := DllCall("OpenProcess" ,"Int",2035711,"Int",0,"UInt",pid)
	if(hHandle <= 0)
		return 0

	if(!DllCall("ReadProcessMemory", "UInt", hHandle, "UInt", dwAddr, "Str", fValue, "UInt", 4, "UInt *", 0))
		return 0

   fValue := *(&fValue+3)<<24 | *(&fValue+2)<<16 | *(&fValue+1)<<8 | *(&fValue)

   DllCall("CloseHandle", "UInt", hHandle)
   bSuccess := true

   return (1-2*(fValue>>31)) * (2**((fValue>>23 & 255)-127)) * (1+(fValue & 8388607)/8388608)
}

error: pathspec 'samples/ahk/samp_health_overlay.ahk' did not match any file(s) known to git


Finally works!!

Finally works!!

error: pathspec '1.4/Rewrite' did not match any file(s) known to git
error: pathspec 'of' did not match any file(s) known to git
error: pathspec 'Revised.ahk' did not match any file(s) known to git


Create together.ahk

Create together.ahk


added KeepScreenAlive Autohotkey Script

added KeepScreenAlive Autohotkey Script

CoordMode, Mouse, Screen
Loop
{
    ; Move mouse
    MouseMove, 1, 1, 0, R
    ; Replace mouse to its original location
    MouseMove, -1, -1, 0, R
    ; Wait before moving the mouse again
    Sleep, 59000
}
return

error: pathspec 'AutoHotKey/KeepScreenAlive.ahk' did not match any file(s) known to git


Update Rewrite of 1.4 Revised.ahk

Update Rewrite of 1.4 Revised.ahk


autohotkey scripts update

autohotkey scripts update

Signed-off-by: rexlee8776 <25c00b6e844cbcca9c367543b1bf5d0d06f7834f@gmail.com>

; auto open and hide total commander
#w::
IfWinNotExist ahk_class TTOTAL_CMD
        Return
Else
IfWinNotActive ahk_class TTOTAL_CMD
        WinActivate
Else
        WinMinimize
Return

; auto open total commander
#t::
If WinExist("ahk_class TTOTAL_CMD")
  WinActivate
else
  Run, d:\GreenTools\totalcmd\TOTALCMD.EXE
return

error: pathspec 'config/rex.ahk' did not match any file(s) known to git


Add Colemak-DHm AHK script

Add Colemak-DHm AHK script

; Colemak Mod-DHm mapping for ANSI boards

;SC010::q
;SC011::w
SC012::f
SC013::p
SC014::b
SC015::j
SC016::l
SC017::u
SC018::y
SC019::;

;SC01E::a
SC01F::r
SC020::s
SC021::t
;SC022::g
SC023::m
SC024::n
SC025::e
SC026::i
SC027::o

SC02c::x
SC02d::c
SC02e::d
;SC02f::v
SC030::z
SC031::k
SC032::h

; set Backspace to CapsLock key

sc03a::backspace

error: pathspec 'dhm.ahk' did not match any file(s) known to git


Delete Serialmacroimgsearch.ahk

Delete Serialmacroimgsearch.ahk

error: pathspec '00_Effectivity' did not match any file(s) known to git
error: pathspec 'macro' did not match any file(s) known to git
error: pathspec 'v1.2/Serialmacroimgsearch.ahk' did not match any file(s) known to git


AutoHotKey: add script to remap capslock to ctrl

error: pathspec 'keys/autohotkey/caps2ctrl.ahk' did not match any file(s) known to git


Global Chat Fix

Global Chat Fix

Dota 2 Keyboard Setups/Project Oracle/Project Oracle.ahk

error: pathspec 'Dota' did not match any file(s) known to git
error: pathspec '2' did not match any file(s) known to git
error: pathspec 'Keyboard' did not match any file(s) known to git
error: pathspec 'Setups/Project' did not match any file(s) known to git
error: pathspec 'Oracle/Project' did not match any file(s) known to git
error: pathspec 'Oracle.ahk' did not match any file(s) known to git


Fix backtick shortcut for Windows Explorer

error: pathspec 'home.windows/AppData/Roaming/Microsoft/Windows/Start' did not match any file(s) known to git
error: pathspec 'Menu/Programs/Startup/SwitchBetweenWindows.ahk' did not match any file(s) known to git


Updated on 2015-04-03: andy

Updated on 2015-04-03: andy

#NoEnv
SetTitleMatchMode, 1  ;matches if title begins with string
WinWait, HandyAndy Says ahk_class #32770, This tool will completely remove traces of Andy, 30
WinActivate
ControlClick, Button1, ahk_class #32770, &Yes,
ExitApp

error: pathspec 'automatic/_output/andy/0.45.5.36/tools/andyUninstall.ahk' did not match any file(s) known to git


Delete Effectivity macro.ahk

Delete Effectivity macro.ahk

00_Effectivity macro v1.2/Effectivity macro.ahk

error: pathspec '00_Effectivity' did not match any file(s) known to git
error: pathspec 'macro' did not match any file(s) known to git
error: pathspec 'v1.2/Effectivity' did not match any file(s) known to git
error: pathspec 'macro.ahk' did not match any file(s) known to git