It would be good to add a check like this on top of the script.. Otherwise dumb ones like me will miss the whole point of the script :p
! Note ! some of the examples are only to show the effect of value, you definitely should change it to your needs
I hope you find it useful
Code:
MainHotkey= ~LWin|~<^RAlt|~CapsLock|~<^<Alt|Numpad0|NumpadDot
;!!! the higher the value the slower mouse will move !!!
speed= 2.5|5|7|10|20|50
startdelay= 30|10|20|40|10|100
color= 0000FF|FF0000|00FF00|AA55EE|EEFF00|553344
KeyUp= w|Numpad8
KeyDown= s|Numpad2
KeyLeft= a|Numpad4
KeyRight= d|Numpad6
KeyUpLeft= Numpad7
KeyUpRight= Numpad9
KeyDownLeft= Numpad1
KeyDownRight= Numpad3
Exit= Escape
;=======================================================================================
#persistent
#MaxHotkeysPerInterval,1000
SetWinDelay,0
SetBatchLines,-1
CoordMode,ToolTip,Screen
CoordMode,Mouse,Screen
StringSplit,color,color,|
StringSplit,speed,speed,|
StringSplit,startdelay,startdelay,|
keys=KeyUp|KeyDown|KeyLeft|KeyRight|KeyUpLeft|KeyUpRight|KeyDownLeft|KeyDownRight
Loop,Parse,MainHotkey,|
{
hotkeyvar:=RegExReplace(A_LoopField,"\<|\>|\*|\$|\^|\!|\+|\~")
Hotkey,$%A_LoopField%,Main,UseErrorLevel
If ErrorLevel
MsgBox You cannot use HotKey: $%A_LoopField%`nProgram will not work if this is the only Main hotkey
else
%hotkeyvar%:=A_Index
}
return
Main:
mainhotkey:=A_ThisHotkey
thishotkey:=RegExReplace(A_ThisHotkey,"\>|\<|\*|\$|\^|\!|\+|\~")
Tooltip:=%thishotkey% ;assign number of tooltip
Loop,Parse,keys,|
Loop,Parse,%A_LoopField%,|
Hotkey,% "$*" A_LoopField,Move,On
Hotkey,*%Exit%,Exit,On
If !x%Tooltip%
ToolTip % " `n`n",% A_ScreenWidth/2,% A_ScreenHeight/2,%ToolTip%
else
ToolTip % " `n`n",% x%ToolTip%,% y%ToolTip%,%ToolTip%
tthwnd:=WinExist("ahk_class tooltips_class32")
WinSet, Region, 1-4 15-18 9-18 13-27 10-28 5-19 1-23, ahk_id %tthwnd%
WinSet,ExStyle,^0x20,ahk_id %tthwnd%
SetToolTipColor(tthwnd,!color%ToolTip% ? color1 : color%ToolTip%)
speed:=!speed%ToolTip% ? speed1 : speed%ToolTip%
startdelay:=!startdelay%ToolTip% ? startdelay1 : startdelay%ToolTip%
KeyWait,%thishotkey%
If InStr(mainhotkey,"~")
Send, {%thishotkey% Up}
Loop,Parse,keys,|
Loop,Parse,%A_LoopField%,|
Hotkey,% "$*" A_LoopField,Move,Off
Hotkey,*%Exit%,Exit,Off
If MouseMoved
{
wingetpos, winx, winy,,,% "ahk_id " . hwnd:=Dllcall("WindowFromPoint", "Int", x%ToolTip%, "Int", y%ToolTip%)
KeyWait,%thishotkey%, D T0.15
ErrorLevel_:=ErrorLevel
KeyWait,%thishotkey%
If ErrorLevel_
ControlClick,% "x" . (x%ToolTip%+1 - winx) . " y" . (y%ToolTip%+5 - winy), ahk_id %hwnd%,,,, NA
else {
WinActivate,ahk_id %hwnd%
WinWaitActive,ahk_id %hwnd%,,0.1
MouseClick,Left,% (x%ToolTip%+1),% (y%ToolTip%+5)
}
}
else if !InStr(mainhotkey,"~")
Send, {%thishotkey%}
ToolTip,,,,%ToolTip%
MouseMoved=
Return
Move:
MouseMoved:=True
WinGetPos,x%ToolTip%,y%ToolTip%,,,ahk_id %tthwnd%
SysGet,xmin,76
SysGet,xmax,78
SysGet,ymin,77
SysGet,ymax,79
Loop
{
i:=Round(A_Index/speed)
Loop,Parse,keys,|
{
key:=A_LoopField
Loop,Parse,%A_LoopField%,|
{
If GetKeyState(A_LoopField,"P"){
IfInString,key,Up
y%ToolTip%-=(y%ToolTip%-i)<=ymin ? 0 : i
IfInString,key,Down
y%ToolTip%+=(y%ToolTip%+i)>=ymax ? 0 : i
IfInString,key,Left
x%ToolTip%-=(x%ToolTip%-i)<=xmin ? 0 : i
IfInString,key,Right
x%ToolTip%+=(x%ToolTip%+i)>=xmax ? 0 : i
stopbreak:=1
}
}
}
If !stopbreak
Break
stopbreak=
WinMove,ahk_id %tthwnd%,,% x%ToolTip%,% y%ToolTip%
Sleep % (startdelay-i) > 1 ? Round(startdelay-i) : 1
}
Return
SetToolTipColor(hwnd,B){
B := (StrLen(B) < 8 ? "0x" : "") . B
B := ((B&255)<<16)+(((B>>8)&255)<<8)+(B>>16) ; rgb -> bgr
DllCall("SendMessage", "Uint", hWnd, "Uint", 1043, "Uint", B, "Uint", 0) ; TTM_SETTIPBKCOLOR
}
exit:
ExitApp