Version = 0.16.0
ScriptName = Mouse 2 Keyboard
Please post your errors and bugs.
Thanks.
*Advanced dynamic hotkeys implemented for the mouse buttons.
Axis and program setting keys in future updates
Code:
#SingleInstance force
SetKeyDelay 0
SetBatchLines -1
SetMouseDelay -1
SetTitleMatchMode 2
SetDefaultMouseSpeed 0
Coordmode, Mouse , Screen
SetWorkingDir, %A_ScriptDir%
Version = 0.16.0
ScriptName = Mouse 2 Keyboard
;#include C:\WINDOWS\ShellNew\Auto_Backup.ahk
Menu, Tray, Icon, Shell32.dll, 44
Menu, tray, NoStandard
Menu, tray, add, Start, Menu_Start
Menu, tray, add, Pause, Menu_Pause
Menu, tray, add, Reload, Menu_Reload
Menu, tray, add, ExitApp, Menu_ExitApp
gosub Window_List
gosub Message
gosub Draw_Gui
Settimer Watch_Native, 300
return
+++++++++++++++++++++++++++
Draw_Gui:
Gui,1: Add, GroupBox, x22 y2 w450 h50 , Select Visible Window
Gui,1: Add, DropDownList, x32 y22 w270 vWindow_Choice Choose%Prefer_Window%, %visible_window_list%
Gui,1: Add, Button, x322 y22 w140 h20 gReload, Reload
Gui,1: Add, GroupBox, x22 y62 w280 h140 , General Settings
Gui,1: Add, CheckBox, x42 y92 w250 h20 vglobal_native, Use M2K settings as native for global system
Gui,1: Add, Radio, x42 y132 w110 h20 checked 1 vMode, 1. Step Mode
Gui,1: Add, Radio, x182 y132 w110 h20 vMode2, 2. Continous Mode
Gui,1: Add, Text, x42 y172 w100 h20 +Center, Idle Center Size
Gui,1: Add, Edit, x152 y172 w30 h20 +Center number limit4 vStep, 1
Gui,1: Add, Text, x192 y172 w100 h20 +Center, Pixels
Gui,1: Add, GroupBox, x322 y62 w150 h140 , Program Settings
Gui,1: Add, Text, x332 y82 w40 h20 +Center, Start
Gui,1: Add, Hotkey, x382 y82 w60 h20 vHotkey_Start, ^a
Gui,1: Add, Button, x442 y82 w20 h20 gscStart,
Gui,1: Add, Text, x332 y112 w40 h20 +Center, Pause
Gui,1: Add, Hotkey, x382 y112 w60 h20 vHotkey_Pause, ^p
Gui,1: Add, Button, x442 y112 w20 h20 gscPause,
Gui,1: Add, Text, x332 y142 w40 h20 +Center, Reload
Gui,1: Add, Hotkey, x382 y142 w60 h20 vHotkey_Reload, ^r
Gui,1: Add, Button, x442 y142 w20 h20 gscReload,
Gui,1: Add, Text, x332 y172 w40 h20 +Center, Exit
Gui,1: Add, Hotkey, x382 y172 w60 h20 vHotkey_Exit, ^x
Gui,1: Add, Button, x442 y172 w20 h20 gscExit,
Gui,1: Add, GroupBox, x22 y212 w280 h305 , Mouse Settings
Gui,1: Add, Text, x42 y232 w130 h20 , Tickbox: Native Function
Gui,1: Add, Text, x172 y232 w110 h20 ,Button :Advanced key
Gui,1: Add, GroupBox, x42 y252 w240 h135 , Buttons
Gui,1: Add, Text, x92 y302 w40 h20 +Center, Left
Gui,1: Add, Hotkey, x92 y322 w40 h20 vHotkey_ButLeft, d
Gui,1: Add, CheckBox, x82 y292 w10 h30 vHotkey_ButLeftNat, CheckBox
Gui,1: Add, Button, x132 y322 w20 h20 gscButLeft ,
Gui,1: Add, Text, x152 y302 w40 h20 +Center, Middle
Gui,1: Add, Hotkey, x152 y322 w40 h20 vHotkey_ButMiddle, s
Gui,1: Add, CheckBox, x142 y292 w10 h30 vHotkey_ButMiddleNat, CheckBox
Gui,1: Add, Button, x192 y322 w20 h20 gscButMiddle,
Gui,1: Add, Text, x212 y302 w40 h20 +Center, Right
Gui,1: Add, Hotkey, x212 y322 w40 h20 vHotkey_ButRight, f
Gui,1: Add, CheckBox, x202 y292 w10 h30 vHotkey_ButRightNat, CheckBox
Gui,1: Add, Button, x252 y322 w20 h20 gscButRight,
Gui,1: Add, Text, x102 y272 w50 h20 +Center, Wheel Up
Gui,1: Add, Hotkey, x152 y272 w40 h20 vHotkey_ButWheelUp, w
Gui,1: Add, CheckBox, x92 y262 w10 h30 vHotkey_ButWheelUpNat, CheckBox
Gui,1: Add, Button, x192 y272 w20 h20 gscButWheelup,
Gui,1: Add, Text, x102 y352 w50 h20 +Center, Wheel Dn
Gui,1: Add, Hotkey, x152 y352 w40 h20 vHotkey_ButWheelDn, x
Gui,1: Add, CheckBox, x92 y342 w10 h30 vHotkey_ButWheelDnNat, CheckBox
Gui,1: Add, Button, x192 y352 w20 h20 gscButWheelDn,
Gui,1: Add, GroupBox, x42 y392 w240 h115 , Axis
Gui,1: Add, CheckBox, x62 y412 w10 h20 vAxis, CheckBox
Gui,1: Add, Text, x112 y412 w40 h20 +Center, Up
Gui,1: Add, Hotkey, x152 y412 w40 h20 vHotkey_Up, Up
Gui,1: Add, Button, x192 y412 w20 h20 gscUP,
Gui,1: Add, Text, x112 y472 w40 h20 +Center, Down
Gui,1: Add, Hotkey, x152 y472 w40 h20 vHotkey_Down, Down
Gui,1: Add, Button, x192 y472 w20 h20 gscdown,
Gui,1: Add, Text, x62 y442 w40 h20 +Center, Left
Gui,1: Add, Hotkey, x102 y442 w40 h20 vHotkey_Left, Left
Gui,1: Add, Button, x142 y442 w20 h20 gscLeft,
Gui,1: Add, Text, x162 y442 w40 h20 +Center, Right
Gui,1: Add, Hotkey, x202 y442 w40 h20 vHotkey_Right, Right
Gui,1: Add, Button, x242 y442 w20 h20 gscRight,
Gui,1: Font, Arial Bold,
Gui,1: Add, Button, x332 y232 w130 h90 gStart, Start
Gui,1: Font, norm,
Gui,1: Add, Button, x332 y342 w130 h30 gWebsite, Project Website
Gui,1: Add, Text, x332 y492 w130 h20 +Center cF67D00 gAHK_Lee, AHK_Lee
Gui,1: Font, norm,
Gui,1: Font, italic
Gui,1: Font,, Arial Bold
Gui,1: Add, Button, x332 y392 w130 h30 gDonate, Donate a coffee
Gui,1: Show,h537 w496, %ScriptName% - Version: %Version%
Return
scStart:
scPause:
scReload:
scExit:
scButLeft:
scButMiddle:
scButRight:
scButWheelup:
scButWheelDn:
scUP:
scDown:
scLeft:
scRight:
scbutton = %A_ThisLabel%
Gui,2: Destroy
ScanCode:
Gui,2: Add, CheckBox, x22 y12 w70 h20 vWildcard, Wildcard
Gui,2: Add, CheckBox, x112 y12 w70 h20 vNative, Native
Gui,2: Add, CheckBox, x202 y12 w70 h20 vComprise, Comprise
Gui,2: Add, CheckBox, x22 y42 w50 h20 vShift, Shift
Gui,2: Add, CheckBox, x92 y42 w50 h20 vCTRL, CTRL
Gui,2: Add, CheckBox, x162 y42 w50 h20 vWIN, WIN
Gui,2: Add, CheckBox, x232 y42 w40 h20 vALT, ALT
Gui,2: Font, s14 Bold, Arial
Gui,2: Add, Text, x22 y72 w150 h40 vSC 0x201 +Border, Press any key
Gui,2: Add, Button, x192 y72 w80 h40 gButtonSC, Accept
Gui,2: +ToolWindow -SysMenu +AlwaysOnTop
Gui,2: Show,h125 w295, % "Input ScanCode: " scButton
Loop 9
OnMessage( 255+A_Index, "ScanCode" ) ; 0x100 to 0x108
Return
;%
return
Message:
OnMessage(0x7777, "MsgMonitor")
MsgMonitor(wParam, lParam, msg)
{
if wParam != 1
return
if lParam = 1
{
gosub Menu_Start
}
if lParam = 2
{
msgbox test
;gosub Menu_Pause
}
if lParam = 3
{
gosub Menu_Reload
}
if lParam = 4
{
gosub Menu_ExitApp
}
}
return
Menu_Start:
process,close, ahk Pid_sec
gosub start
return
Menu_Pause:
process,close, ahk Pid_sec
Pause
return
Menu_Reload:
process,close, ahk Pid_sec
reload
return
Menu_ExitApp:
process,close, ahk Pid_sec
exitapp
return
Reload:
process,close, ahk Pid_sec
Reload
Return
Window_List:
WinGet, window_id, list,,, Program Manager
Loop, %window_id%
{
this_window_id := window_id%A_Index%
WinGetTitle, this_window_title, ahk_id %this_window_id%
if (this_window_title = "Start" or "")
continue
if visible_window_list =
visible_window_list = %this_window_title%
else
visible_window_list = %visible_window_list%|%this_window_title%
}
sort,visible_window_list, D|
Loop, parse, visible_window_list, |,
{
ifinstring,A_LoopField,Jnes
Prefer_window := A_Index
}
return
ButtonSC:
Gui,2: Submit
Gui,2: Destroy
SC_hotkey:=
If Wildcard = 1
SC_hotkey.="*"
If Native = 1
SC_hotkey.="~"
If Comprise = 1
SC_hotkey.="$"
if SCButton = scStart
SC_hotkey.="scStart::"
if SCButton = scPause
SC_hotkey.="scPause::"
if SCButton = scReload
SC_hotkey.="scReload::"
if SCButton = scExit
SC_hotkey.="scExit::"
if SCButton = scButLeft
SC_hotkey.="lbutton::"
if SCButton = scButMiddle
SC_hotkey.="mbutton::"
if SCButton = scButRight
SC_hotkey.="rbutton::"
if SCButton = scButWheelup
SC_hotkey.="Wheelup::"
if SCButton = scButWheelDn
SC_hotkey.="Wheeldown::"
if SCButton = scUP
SC_hotkey.="scUP::"
if SCButton = scDown
SC_hotkey.="scDown::"
if SCButton = scLeft
SC_hotkey.="ScLeft::"
if SCButton = scRight
SC_hotkey.="scRight::"
If Shift = 1
SC_hotkey.="+"
If CTRL = 1
SC_hotkey.="^"
If WIN = 1
SC_hotkey.="#"
If ALT = 1
SC_hotkey.="!"
SC_hotkey.=SC
if SCButton = scButLeft
{
GuiControlGet, Hotkey_ButLeft,1:Pos
Guicontrol, 1:hide, Hotkey_ButLeft
GuiControlGet, ScHotkey_ButLeft, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButLeftX% y%Hotkey_ButLeftY% w%Hotkey_ButLeftW% h%Hotkey_ButLeftH% vScHotkey_ButLeft, %SC%
}
Guicontrol, 1:,ScHotkey_ButLeft,%SC%
Guicontrol, 1:disable, ScHotkey_ButLeft
sc_hotkey_butleft:=SC_Hotkey
}
if SCButton = scButMiddle
{
GuiControlGet, Hotkey_ButMiddle,1:Pos
Guicontrol, 1:hide, Hotkey_ButMiddle
GuiControlGet, ScHotkey_ButMiddle, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButMiddleX% y%Hotkey_ButMiddleY% w%Hotkey_ButMiddleW% h%Hotkey_ButMiddleH% vScHotkey_ButMiddle, %SC%
}
Guicontrol, 1:,ScHotkey_ButMiddle,%SC%
Guicontrol, 1:disable, ScHotkey_ButMiddle
sc_hotkey_butMiddle:=SC_Hotkey
}
if SCButton = scButRight
{
GuiControlGet, Hotkey_ButRight,1:Pos
Guicontrol, 1:hide, Hotkey_ButRight
GuiControlGet, ScHotkey_ButRight, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButRightX% y%Hotkey_ButRightY% w%Hotkey_ButRightW% h%Hotkey_ButRightH% vScHotkey_ButRight, %SC%
}
Guicontrol, 1:,ScHotkey_ButRight,%SC%
Guicontrol, 1:disable, ScHotkey_ButRight
sc_hotkey_butRight:=SC_Hotkey
}
if SCButton = scButWheelup
{
GuiControlGet, Hotkey_ButWheelup,1:Pos
Guicontrol, 1:hide, Hotkey_ButWheelup
GuiControlGet, ScHotkey_ButWheelup, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButWheelupX% y%Hotkey_ButWheelupY% w%Hotkey_ButWheelupW% h%Hotkey_ButWheelupH% vScHotkey_ButWheelup, %SC%
}
Guicontrol, 1:,ScHotkey_ButWheelup,%SC%
Guicontrol, 1:disable, ScHotkey_ButWheelup
sc_hotkey_butWheelup:=SC_Hotkey
}
if SCButton = scButWheelDn
{
GuiControlGet, Hotkey_ButWheelDn,1:Pos
Guicontrol, 1:hide, Hotkey_ButWheelDn
GuiControlGet, ScHotkey_ButWheelDn, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButWheelDnX% y%Hotkey_ButWheelDnY% w%Hotkey_ButWheelDnW% h%Hotkey_ButWheelDnH% vScHotkey_ButWheelDn, %SC%
}
Guicontrol, 1:,ScHotkey_ButWheelDn,%SC%
Guicontrol, 1:disable, ScHotkey_ButWheelDn
sc_hotkey_butWheelDn:=SC_Hotkey
}
return
Watch_Native:
GuiControlGet,global_native,1:
if global_native = 1
{
Guicontrol, 1:,mode2,1
Guicontrol, 1:,Axis,1
Guicontrol, 1:,Hotkey_ButWheelDnNat,1
Guicontrol, 1:,Hotkey_ButWheelUpNat,1
Guicontrol, 1:,Hotkey_ButRightNat,1
Guicontrol, 1:,Hotkey_ButMiddleNat,1
Guicontrol, 1:,Hotkey_ButLeftNat,1
Settimer,Watch_Native,off
}
return
Start:
Gui Submit
If Axis = 1
Mode = 2
StringLower, Hotkey_Start, Hotkey_Start
StringLower, Hotkey_Pause, Hotkey_Pause
StringLower, Hotkey_Reload, Hotkey_Reload
StringLower, Hotkey_Exit, Hotkey_Exit
StringLower, Hotkey_ButLeft, Hotkey_ButLeft
StringLower, Hotkey_ButMiddle, Hotkey_ButMiddle
StringLower, Hotkey_ButRight, Hotkey_ButRight
StringLower, Hotkey_ButWheelUp, Hotkey_ButWheelUp
StringLower, Hotkey_ButWheelDn, Hotkey_ButWheelDn
StringLower, Hotkey_Up, Hotkey_Up
StringLower, Hotkey_Down, Hotkey_Down
StringLower, Hotkey_Left, Hotkey_Left
StringLower, Hotkey_Right, Hotkey_Right
GuiControlGet, ScHotkey_ButLeft, 1:Enabled
if ScHotkey_Butleft = 0
Final_Hotkey_ButLeft:= Sc_Hotkey_Butleft
else
Final_Hotkey_ButLeft:= "lbutton::"Hotkey_ButLeft
GuiControlGet, ScHotkey_ButMiddle, 1:Enabled
if ScHotkey_ButMiddle = 0
Final_Hotkey_ButMiddle:= Sc_Hotkey_ButMiddle
else
Final_Hotkey_ButMiddle:= "mbutton::"Hotkey_ButMiddle
GuiControlGet, ScHotkey_ButRight, 1:Enabled
if ScHotkey_ButRight = 0
Final_Hotkey_ButRight:= Sc_Hotkey_ButRight
else
Final_Hotkey_ButRight:= "rbutton::"Hotkey_ButRight
GuiControlGet, ScHotkey_ButWheelUp, 1:Enabled
if ScHotkey_ButWheelUp = 0
Final_Hotkey_ButWheelUp:= Sc_Hotkey_ButWheelUp
else
Final_Hotkey_ButWheelUp:= "WheelUp::"Hotkey_ButWheelUp
GuiControlGet, ScHotkey_ButWheelDn, 1:Enabled
if ScHotkey_ButWheelDn = 0
Final_Hotkey_ButWheelDn:= Sc_Hotkey_ButWheelDn
else
Final_Hotkey_ButWheelDn:= "WheelDown::"Hotkey_ButWheelDn
if Hotkey_ButLeftNat = 1
Final_Hotkey_ButLeft := "lbutton::lbutton"
if Hotkey_ButMiddleNat = 1
Final_Hotkey_ButMiddle := "mbutton::mbutton"
if Hotkey_ButRightNat = 1
Final_Hotkey_ButRight := "rbutton::rbutton"
if Hotkey_ButWheelUpNat = 1
Final_Hotkey_ButWheelUp := "WheelUp::WheelUp"
if Hotkey_ButWheelDnNat = 1
Final_Hotkey_ButWheelDn := "WheelDown::WheelDown"
if global_native != 1
if Window_Choice =
reload
Gui Hide
Gosub dynamic_lee
Return
Website:
Run http://www.autohotkey.com/forum/viewtopic.php?p=347496#347496
Return
Donate:
Run "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=disput`%40home`%2enl&lc=US¤cy_code=EUR&bn=PP"
Return
AHK_Lee:
Run http://www.autohotkey.com/forum/profile.php?mode=viewprofile&u=44629
return
GuiClose:
ExitApp
Dynamic_lee:
Pid_main := DllCall("GetCurrentProcessId")
Critical
FileDelete, %A_ScriptDir%\hotkey.ahk
Critical
FileAppend ,
(
#SingleInstance force
#NoTrayIcon
DetectHiddenWindows On
SetKeyDelay 0
SetBatchLines -1
SetMouseDelay -1
SetTitleMatchMode 2
SetDefaultMouseSpeed 0
Coordmode, Mouse , Screen
Axis = %Axis%
If Axis = 1
sleep -1
else
SetTimer WatchMouse, 1
), %A_ScriptDir%\hotkey.ahk
If global_native = 1
sleep -1
else
{
Critical
FileAppend ,
(
#IfWinActive %Window_Choice%
), %A_ScriptDir%\hotkey.ahk
}
{
Critical
FileAppend ,
(
%Final_Hotkey_ButLeft%
%Final_Hotkey_ButMiddle%
%Final_Hotkey_ButRight%
%Final_Hotkey_ButWheelUp%
%Final_Hotkey_ButWheelDn%
), %A_ScriptDir%\hotkey.ahk
}
If global_native = 1
sleep -1
else
{
Critical
FileAppend ,
(
#IfWinActive
), %A_ScriptDir%\hotkey.ahk
}
Critical
FileAppend ,
(
*%Hotkey_Start%::
Suspend, Permit
PostMessage, 0x7777, 1, 1 ,,ahk_pid %Pid_main%
exitapp
return
*%Hotkey_Pause%::
Suspend
Pause,,1
return
*%Hotkey_Reload%::
Suspend, Permit
PostMessage, 0x7777, 1, 3 ,,ahk_pid %Pid_main%
exitapp
return
*%Hotkey_Exit%::
Suspend, Permit
PostMessage, 0x7777, 1, 4 ,,ahk_pid %Pid_main%
exitapp
return
WatchMouse:
Process,exist,%Pid_main%
if errorlevel = 0
exitapp
IfWinNotActive, %Window_Choice%
{
startingpos = 0
return
}
If startingpos = 0
MouseMove A_ScreenWidth/2, A_ScreenHeight/2, 0
startingpos = 1
KeyToHoldDownPrev1 = `%KeyToHoldDown1`%
KeyToHoldDownPrev2 = `%KeyToHoldDown2`%
MouseGetPos x, y
If (x < (A_ScreenWidth/2-%Step%))
{
KeyToHoldDown1 = %Hotkey_Left%
}
Else If (x > (A_ScreenWidth/2+%Step%))
{
KeyToHoldDown1 = %Hotkey_Right%
}
Else
KeyToHoldDown1 =
If (y > (A_ScreenHeight/2+%Step%))
{
KeyToHoldDown2 = %Hotkey_Down%
}
Else If (y < (A_ScreenHeight/2-%Step%))
{
KeyToHoldDown2 = %Hotkey_Up%
}
Else
KeyToHoldDown2 =
Hotkey_XAxis_Nat_Left = %Hotkey_XAxis_Nat_Left%
Hotkey_XAxis_Nat_Right = %Hotkey_XAxis_Nat_Right%
if KeyToHoldDown1 != `%KeyToHoldDownPrev1`%
{
if KeyToHoldDownPrev1
Send, {`%KeyToHoldDownPrev1`% up}
if KeyToHoldDown1
Send, {`%KeyToHoldDown1`% down}
}
Hotkey_YAxis_Nat_Up = %Hotkey_YAxis_Nat_Up%
Hotkey_YAxis_Nat_Down = %Hotkey_YAxis_Nat_Down%
if KeyToHoldDown2 != `%KeyToHoldDownPrev2`%
{
if KeyToHoldDownPrev2
Send, {`%KeyToHoldDownPrev2`% up}
if KeyToHoldDown2
Send, {`%KeyToHoldDown2`% down}
}
Mode = %mode%
if Mode = 1
MouseMove A_ScreenWidth/2, A_ScreenHeight/2, 0
Return
del::reload
home::pause
pgup::suspend
end::Exitapp
), %A_ScriptDir%\hotkey.ahk
FileSetAttrib, ^H, %A_ScriptDir%\hotkey.ahk
Run, autohotkey.exe hotkey.ahk,%A_ScriptDir%,,Pid_sec
return
ScanCode( wParam, lParam )
{
global
SetFormat, Integer, Hex
Clipboard := "SC" SubStr((((lParam>>16) & 0xFF)+0xF000),-2)
GuiControl,, SC, %Clipboard%
SC:= Clipboard
}
Version = 0.18.0
ScriptName = Mouse 2 Keyboard
Since I am cleaning up my NAS after a worm attack I decided to put this version online aswell. Forgot wich changes I made between 16 and 18. Also it still needs alot of fine tunning to make the script smaller and better.
Code:
#SingleInstance force
SetKeyDelay 0
SetBatchLines -1
SetMouseDelay -1
SetTitleMatchMode 2
SetDefaultMouseSpeed 0
Coordmode, Mouse , Screen
SetWorkingDir, %A_ScriptDir%
Version = 0.18.0
ScriptName = Mouse 2 Keyboard
;#include C:\WINDOWS\ShellNew\Auto_Backup.ahk
Menu, Tray, Icon, Shell32.dll, 44
Menu, tray, NoStandard
Menu, tray, add, Start, Menu_Start
Menu, tray, add, Pause, Menu_Pause
Menu, tray, add, Reload, Menu_Reload
Menu, tray, add, ExitApp, Menu_ExitApp
gosub Window_List
gosub Message
gosub Draw_Gui
Settimer Watch_Native, 300
return
+++++++++++++++++++++++++++
Draw_Gui:
Gui,1: Add, GroupBox, x22 y2 w450 h50 , Select Visible Window
Gui,1: Add, DropDownList, x32 y22 w270 vWindow_Choice Choose%Prefer_Window%, %visible_window_list%
Gui,1: Add, Button, x322 y22 w140 h20 gReload, Reload
Gui,1: Add, GroupBox, x22 y62 w280 h140 , General Settings
Gui,1: Add, CheckBox, x42 y92 w250 h20 vglobal_native, Use M2K settings as native for global system
Gui,1: Add, Radio, x42 y132 w110 h20 checked 1 vMode, 1. Step Mode
Gui,1: Add, Radio, x182 y132 w110 h20 vMode2, 2. Continous Mode
Gui,1: Add, Text, x42 y172 w100 h20 +Center, Idle Center Size
Gui,1: Add, Edit, x152 y172 w30 h20 +Center number limit4 vStep, 1
Gui,1: Add, Text, x192 y172 w100 h20 +Center, Pixels
Gui,1: Add, GroupBox, x322 y62 w150 h140 , Program Settings
Gui,1: Add, Text, x332 y82 w40 h20 +Center, Start
Gui,1: Add, Hotkey, x382 y82 w60 h20 vHotkey_Start, ^a
Gui,1: Add, Button, x442 y82 w20 h20 gscStart,
Gui,1: Add, Text, x332 y112 w40 h20 +Center, Pause
Gui,1: Add, Hotkey, x382 y112 w60 h20 vHotkey_Pause, ^p
Gui,1: Add, Button, x442 y112 w20 h20 gscPause,
Gui,1: Add, Text, x332 y142 w40 h20 +Center, Reload
Gui,1: Add, Hotkey, x382 y142 w60 h20 vHotkey_Reload, ^r
Gui,1: Add, Button, x442 y142 w20 h20 gscReload,
Gui,1: Add, Text, x332 y172 w40 h20 +Center, Exit
Gui,1: Add, Hotkey, x382 y172 w60 h20 vHotkey_Exit, ^x
Gui,1: Add, Button, x442 y172 w20 h20 gscExit,
Gui,1: Add, GroupBox, x22 y212 w280 h305 , Mouse Settings
Gui,1: Add, Text, x42 y232 w130 h20 , Tickbox: Native Function
Gui,1: Add, Text, x172 y232 w110 h20 ,Button :Advanced key
Gui,1: Add, GroupBox, x42 y252 w240 h135 , Buttons
Gui,1: Add, Text, x92 y302 w40 h20 +Center, Left
Gui,1: Add, Hotkey, x92 y322 w40 h20 vHotkey_ButLeft, d
Gui,1: Add, CheckBox, x82 y292 w10 h30 vHotkey_ButLeftNat, CheckBox
Gui,1: Add, Button, x132 y322 w20 h20 gscButLeft ,
Gui,1: Add, Text, x152 y302 w40 h20 +Center, Middle
Gui,1: Add, Hotkey, x152 y322 w40 h20 vHotkey_ButMiddle, s
Gui,1: Add, CheckBox, x142 y292 w10 h30 vHotkey_ButMiddleNat, CheckBox
Gui,1: Add, Button, x192 y322 w20 h20 gscButMiddle,
Gui,1: Add, Text, x212 y302 w40 h20 +Center, Right
Gui,1: Add, Hotkey, x212 y322 w40 h20 vHotkey_ButRight, f
Gui,1: Add, CheckBox, x202 y292 w10 h30 vHotkey_ButRightNat, CheckBox
Gui,1: Add, Button, x252 y322 w20 h20 gscButRight,
Gui,1: Add, Text, x102 y272 w50 h20 +Center, Wheel Up
Gui,1: Add, Hotkey, x152 y272 w40 h20 vHotkey_ButWheelUp, w
Gui,1: Add, CheckBox, x92 y262 w10 h30 vHotkey_ButWheelUpNat, CheckBox
Gui,1: Add, Button, x192 y272 w20 h20 gscButWheelup,
Gui,1: Add, Text, x102 y352 w50 h20 +Center, Wheel Dn
Gui,1: Add, Hotkey, x152 y352 w40 h20 vHotkey_ButWheelDn, x
Gui,1: Add, CheckBox, x92 y342 w10 h30 vHotkey_ButWheelDnNat, CheckBox
Gui,1: Add, Button, x192 y352 w20 h20 gscButWheelDn,
Gui,1: Add, GroupBox, x42 y392 w240 h115 , Axis
Gui,1: Add, CheckBox, x62 y412 w10 h20 vAxis, CheckBox
Gui,1: Add, Text, x112 y412 w40 h20 +Center, Up
Gui,1: Add, Hotkey, x152 y412 w40 h20 vHotkey_Up, Up
Gui,1: Add, Button, x192 y412 w20 h20 gscUP,
Gui,1: Add, Text, x112 y472 w40 h20 +Center, Down
Gui,1: Add, Hotkey, x152 y472 w40 h20 vHotkey_Down, Down
Gui,1: Add, Button, x192 y472 w20 h20 gscdown,
Gui,1: Add, Text, x62 y442 w40 h20 +Center, Left
Gui,1: Add, Hotkey, x102 y442 w40 h20 vHotkey_Left, Left
Gui,1: Add, Button, x142 y442 w20 h20 gscLeft,
Gui,1: Add, Text, x162 y442 w40 h20 +Center, Right
Gui,1: Add, Hotkey, x202 y442 w40 h20 vHotkey_Right, Right
Gui,1: Add, Button, x242 y442 w20 h20 gscRight,
Gui,1: Font, Arial Bold,
Gui,1: Add, Button, x332 y232 w130 h90 gStart, Start
Gui,1: Font, norm,
Gui,1: Add, Button, x332 y342 w130 h30 gWebsite, Project Website
Gui,1: Add, Text, x332 y492 w130 h20 +Center cF67D00 gAHK_Lee, AHK_Lee
Gui,1: Font, norm,
Gui,1: Font, italic
Gui,1: Font,, Arial Bold
Gui,1: Add, Button, x332 y392 w130 h30 gDonate, Donate a coffee
Gui,1: Show,h537 w496, %ScriptName% - Version: %Version%
Return
scStart:
scPause:
scReload:
scExit:
scButLeft:
scButMiddle:
scButRight:
scButWheelup:
scButWheelDn:
scUP:
scDown:
scLeft:
scRight:
scbutton = %A_ThisLabel%
Gui,2: Destroy
ScanCode:
Gui,2: Add, CheckBox, x22 y12 w70 h20 vWildcard, Wildcard
Gui,2: Add, CheckBox, x112 y12 w70 h20 vNative, Native
Gui,2: Add, CheckBox, x202 y12 w70 h20 vComprise, Comprise
Gui,2: Add, CheckBox, x22 y42 w50 h20 vShift, Shift
Gui,2: Add, CheckBox, x92 y42 w50 h20 vCTRL, CTRL
Gui,2: Add, CheckBox, x162 y42 w50 h20 vWIN, WIN
Gui,2: Add, CheckBox, x232 y42 w40 h20 vALT, ALT
Gui,2: Font, s14 Bold, Arial
Gui,2: Add, Text, x22 y72 w150 h40 vSC 0x201 +Border, Press any key
Gui,2: Add, Button, x192 y72 w80 h40 gButtonSC, Accept
Gui,2: +ToolWindow -SysMenu +AlwaysOnTop
Gui,2: Show,h125 w295, % "Input ScanCode: " scButton
Loop 9
OnMessage( 255+A_Index, "ScanCode" ) ; 0x100 to 0x108
Return
;%
return
Message:
OnMessage(0x7777, "MsgMonitor")
MsgMonitor(wParam, lParam, msg)
{
if wParam != 1
return
if lParam = 1
{
gosub Menu_Start
}
if lParam = 2
{
msgbox test
;gosub Menu_Pause
}
if lParam = 3
{
gosub Menu_Reload
}
if lParam = 4
{
gosub Menu_ExitApp
}
}
return
Menu_Start:
process,close, ahk Pid_sec
gosub start
return
Menu_Pause:
process,close, ahk Pid_sec
Pause
return
Menu_Reload:
Reload:
process,close, ahk Pid_sec
Reload
Return
Menu_ExitApp:
process,close, ahk Pid_sec
exitapp
return
Window_List:
WinGet, window_id, list,,, Program Manager
Loop, %window_id%
{
this_window_id := window_id%A_Index%
WinGetTitle, this_window_title, ahk_id %this_window_id%
if (this_window_title = "Start" or "")
continue
if visible_window_list =
visible_window_list = %this_window_title%
else
visible_window_list = %visible_window_list%|%this_window_title%
}
sort,visible_window_list, D|
Loop, parse, visible_window_list, |,
{
ifinstring,A_LoopField,Jnes
Prefer_window := A_Index
}
return
ButtonSC:
Gui,2: Submit
Gui,2: Destroy
SC_hotkey:=
If Wildcard = 1
SC_hotkey.="*"
If Native = 1
SC_hotkey.="~"
If Comprise = 1
SC_hotkey.="$"
if SCButton = scStart
SC_hotkey.="scStart::"
if SCButton = scPause
SC_hotkey.="scPause::"
if SCButton = scReload
SC_hotkey.="scReload::"
if SCButton = scExit
SC_hotkey.="scExit::"
if SCButton = scButLeft
{
SC_hotkey.="lbutton::"
Create_Hotkey(SCBUTTON)
}
if SCButton = scButMiddle
SC_hotkey.="mbutton::"
if SCButton = scButRight
SC_hotkey.="rbutton::"
if SCButton = scButWheelup
SC_hotkey.="Wheelup::"
if SCButton = scButWheelDn
SC_hotkey.="Wheeldown::"
if SCButton = scUP
SC_hotkey.="scUP::"
if SCButton = scDown
SC_hotkey.="scDown::"
if SCButton = scLeft
SC_hotkey.="ScLeft::"
if SCButton = scRight
SC_hotkey.="scRight::"
If Shift = 1
SC_hotkey.="+"
If CTRL = 1
SC_hotkey.="^"
If WIN = 1
SC_hotkey.="#"
If ALT = 1
SC_hotkey.="!"
SC_hotkey.=SC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;if SCButton = scButLeft
;{
;GuiControlGet, Hotkey_ButLeft,1:Pos
;Guicontrol, 1:hide, Hotkey_ButLeft
;GuiControlGet, ScHotkey_ButLeft, 1:
;if errorlevel = 1
;{
;Gui,1: Add, edit, x%Hotkey_ButLeftX% y%Hotkey_ButLeftY% w%Hotkey_ButLeftW% h%Hotkey_ButLeftH% vScHotkey_ButLeft, %SC%
;}
;Guicontrol, 1:,ScHotkey_ButLeft,%SC%
;Guicontrol, 1:disable, ScHotkey_ButLeft
;
;sc_hotkey_butleft:=SC_Hotkey
;}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if SCButton = scButMiddle
{
GuiControlGet, Hotkey_ButMiddle,1:Pos
Guicontrol, 1:hide, Hotkey_ButMiddle
GuiControlGet, ScHotkey_ButMiddle, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButMiddleX% y%Hotkey_ButMiddleY% w%Hotkey_ButMiddleW% h%Hotkey_ButMiddleH% vScHotkey_ButMiddle, %SC%
}
Guicontrol, 1:,ScHotkey_ButMiddle,%SC%
Guicontrol, 1:disable, ScHotkey_ButMiddle
sc_hotkey_butMiddle:=SC_Hotkey
}
if SCButton = scButRight
{
GuiControlGet, Hotkey_ButRight,1:Pos
Guicontrol, 1:hide, Hotkey_ButRight
GuiControlGet, ScHotkey_ButRight, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButRightX% y%Hotkey_ButRightY% w%Hotkey_ButRightW% h%Hotkey_ButRightH% vScHotkey_ButRight, %SC%
}
Guicontrol, 1:,ScHotkey_ButRight,%SC%
Guicontrol, 1:disable, ScHotkey_ButRight
sc_hotkey_butRight:=SC_Hotkey
}
if SCButton = scButWheelup
{
GuiControlGet, Hotkey_ButWheelup,1:Pos
Guicontrol, 1:hide, Hotkey_ButWheelup
GuiControlGet, ScHotkey_ButWheelup, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButWheelupX% y%Hotkey_ButWheelupY% w%Hotkey_ButWheelupW% h%Hotkey_ButWheelupH% vScHotkey_ButWheelup, %SC%
}
Guicontrol, 1:,ScHotkey_ButWheelup,%SC%
Guicontrol, 1:disable, ScHotkey_ButWheelup
sc_hotkey_butWheelup:=SC_Hotkey
}
if SCButton = scButWheelDn
{
GuiControlGet, Hotkey_ButWheelDn,1:Pos
Guicontrol, 1:hide, Hotkey_ButWheelDn
GuiControlGet, ScHotkey_ButWheelDn, 1:
if errorlevel = 1
{
Gui,1: Add, edit, x%Hotkey_ButWheelDnX% y%Hotkey_ButWheelDnY% w%Hotkey_ButWheelDnW% h%Hotkey_ButWheelDnH% vScHotkey_ButWheelDn, %SC%
}
Guicontrol, 1:,ScHotkey_ButWheelDn,%SC%
Guicontrol, 1:disable, ScHotkey_ButWheelDn
sc_hotkey_butWheelDn:=SC_Hotkey
}
return
Watch_Native:
GuiControlGet,global_native,1:
if global_native = 1
{
Guicontrol, 1:,mode2,1
Guicontrol, 1:,Axis,1
Guicontrol, 1:,Hotkey_ButWheelDnNat,1
Guicontrol, 1:,Hotkey_ButWheelUpNat,1
Guicontrol, 1:,Hotkey_ButRightNat,1
Guicontrol, 1:,Hotkey_ButMiddleNat,1
Guicontrol, 1:,Hotkey_ButLeftNat,1
Settimer,Watch_Native,off
}
return
Start:
Gui Submit
If Axis = 1
Mode = 2
StringLower, Hotkey_Start, Hotkey_Start
StringLower, Hotkey_Pause, Hotkey_Pause
StringLower, Hotkey_Reload, Hotkey_Reload
StringLower, Hotkey_Exit, Hotkey_Exit
StringLower, Hotkey_ButLeft, Hotkey_ButLeft
StringLower, Hotkey_ButMiddle, Hotkey_ButMiddle
StringLower, Hotkey_ButRight, Hotkey_ButRight
StringLower, Hotkey_ButWheelUp, Hotkey_ButWheelUp
StringLower, Hotkey_ButWheelDn, Hotkey_ButWheelDn
StringLower, Hotkey_Up, Hotkey_Up
StringLower, Hotkey_Down, Hotkey_Down
StringLower, Hotkey_Left, Hotkey_Left
StringLower, Hotkey_Right, Hotkey_Right
Final_Hotkey_ButLeft:="lbutton"
Final_Hotkey_ButLeft:=HotkeyOrScanCode(Sc_Hotkey_ButLeft,Final_Hotkey_ButLeft,Hotkey_ButLeft,Hotkey_ButLeftNat)
Final_Hotkey_ButMiddle:="mbutton"
Final_Hotkey_ButMiddle:=HotkeyOrScanCode(Sc_Hotkey_ButMiddle,Final_Hotkey_ButMiddle,Hotkey_ButMiddle,Hotkey_ButMiddleNat)
Final_Hotkey_ButRight:="rbutton"
Final_Hotkey_ButRight:=HotkeyOrScanCode(Sc_Hotkey_ButRight,Final_Hotkey_ButRight,Hotkey_ButRight,Hotkey_ButRightNat)
Final_Hotkey_ButWheelUp:="WheelUp"
Final_Hotkey_ButWheelUp:=HotkeyOrScanCode(Sc_Hotkey_ButWheelUp,Final_Hotkey_ButWheelUp,Hotkey_ButWheelUp,Hotkey_ButWheelUpNat)
Final_Hotkey_ButWheelDn:="WheelDown"
Final_Hotkey_ButWheelDn:=HotkeyOrScanCode(Sc_Hotkey_ButWheelDn,Final_Hotkey_ButWheelDn,Hotkey_ButWheelDn,Hotkey_ButWheelDnNat)
if global_native != 1
if Window_Choice =
reload
Gui Hide
Gosub dynamic_lee
Return
Website:
Run http://www.autohotkey.com/forum/viewtopic.php?p=347496#347496
Return
Donate:
Run "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=disput`%40home`%2enl&lc=US¤cy_code=EUR&bn=PP"
Return
AHK_Lee:
Run http://www.autohotkey.com/forum/profile.php?mode=viewprofile&u=44629
return
GuiClose:
ExitApp
Dynamic_lee:
Pid_main := DllCall("GetCurrentProcessId")
Critical
FileDelete, %A_ScriptDir%\hotkey.ahk
Critical
FileAppend ,
(
#SingleInstance force
#NoTrayIcon
DetectHiddenWindows On
SetKeyDelay 0
SetBatchLines -1
SetMouseDelay -1
SetTitleMatchMode 2
SetDefaultMouseSpeed 0
Coordmode, Mouse , Screen
Axis = %Axis%
If Axis = 1
sleep -1
else
SetTimer WatchMouse, 1
), %A_ScriptDir%\hotkey.ahk
If global_native = 1
sleep -1
else
{
Critical
FileAppend ,
(
#IfWinActive %Window_Choice%
), %A_ScriptDir%\hotkey.ahk
}
{
Critical
FileAppend ,
(
%Final_Hotkey_ButLeft%
%Final_Hotkey_ButMiddle%
%Final_Hotkey_ButRight%
%Final_Hotkey_ButWheelUp%
%Final_Hotkey_ButWheelDn%
), %A_ScriptDir%\hotkey.ahk
}
If global_native = 1
sleep -1
else
{
Critical
FileAppend ,
(
#IfWinActive
), %A_ScriptDir%\hotkey.ahk
}
Critical
FileAppend ,
(
*%Hotkey_Start%::
Suspend, Permit
PostMessage, 0x7777, 1, 1 ,,ahk_pid %Pid_main%
exitapp
return
*%Hotkey_Pause%::
Suspend
Pause,,1
return
*%Hotkey_Reload%::
Suspend, Permit
PostMessage, 0x7777, 1, 3 ,,ahk_pid %Pid_main%
exitapp
return
*%Hotkey_Exit%::
Suspend, Permit
PostMessage, 0x7777, 1, 4 ,,ahk_pid %Pid_main%
exitapp
return
WatchMouse:
Process,exist,%Pid_main%
if errorlevel = 0
exitapp
IfWinNotActive, %Window_Choice%
{
startingpos = 0
return
}
If startingpos = 0
MouseMove A_ScreenWidth/2, A_ScreenHeight/2, 0
startingpos = 1
KeyToHoldDownPrev1 = `%KeyToHoldDown1`%
KeyToHoldDownPrev2 = `%KeyToHoldDown2`%
MouseGetPos x, y
If (x < (A_ScreenWidth/2-%Step%))
{
KeyToHoldDown1 = %Hotkey_Left%
}
Else If (x > (A_ScreenWidth/2+%Step%))
{
KeyToHoldDown1 = %Hotkey_Right%
}
Else
KeyToHoldDown1 =
If (y > (A_ScreenHeight/2+%Step%))
{
KeyToHoldDown2 = %Hotkey_Down%
}
Else If (y < (A_ScreenHeight/2-%Step%))
{
KeyToHoldDown2 = %Hotkey_Up%
}
Else
KeyToHoldDown2 =
Hotkey_XAxis_Nat_Left = %Hotkey_XAxis_Nat_Left%
Hotkey_XAxis_Nat_Right = %Hotkey_XAxis_Nat_Right%
if KeyToHoldDown1 != `%KeyToHoldDownPrev1`%
{
if KeyToHoldDownPrev1
Send, {`%KeyToHoldDownPrev1`% up}
if KeyToHoldDown1
Send, {`%KeyToHoldDown1`% down}
}
Hotkey_YAxis_Nat_Up = %Hotkey_YAxis_Nat_Up%
Hotkey_YAxis_Nat_Down = %Hotkey_YAxis_Nat_Down%
if KeyToHoldDown2 != `%KeyToHoldDownPrev2`%
{
if KeyToHoldDownPrev2
Send, {`%KeyToHoldDownPrev2`% up}
if KeyToHoldDown2
Send, {`%KeyToHoldDown2`% down}
}
Mode = %mode%
if Mode = 1
MouseMove A_ScreenWidth/2, A_ScreenHeight/2, 0
Return
del::reload
home::pause
pgup::suspend
end::Exitapp
), %A_ScriptDir%\hotkey.ahk
FileSetAttrib, ^H, %A_ScriptDir%\hotkey.ahk
Run, autohotkey.exe hotkey.ahk,%A_ScriptDir%,,Pid_sec
return
ScanCode( wParam, lParam )
{
global
SetFormat, Integer, Hex
Clipboard := "SC" SubStr((((lParam>>16) & 0xFF)+0xF000),-2)
GuiControl,, SC, %Clipboard%
SC:= Clipboard
}
HotkeyOrScanCode(HS1,HS2,HS3,HS4)
{
if HS1 !=
HS:= HS1
else
HS:= "*" HS2 "::" HS3
if HS4 = 1
HS:=
Return HS
}
Create_hotkey(SCButton)
{
global
StringTrimLeft, SCButton, String, 5
GuiControlGet, Hotkey_But%SCButton%,1:Pos
Guicontrol, 1:hide, Hotkey_But%SCButton%
GuiControlGet, ScHotkey_But%SCButton%, 1:
if errorlevel = 1
{
test%A_index%:= test
msgbox %test0% %A_index%
Gui,1: Add, edit, x%Hotkey_But%SCButton%X% y%Hotkey_But%SCButton%Y% w%Hotkey_But%SCButton%W% h%Hotkey_But%SCButton%H% vScHotkey_But%SCButton%, %SC%
}
Guicontrol, 1:,ScHotkey_But%SCButton%,%SC%
Guicontrol, 1:disable, ScHotkey_But%SCButton%
sc_hotkey_but%SCButton%:=SC_Hotkey
}