Skip to content

Instantly share code, notes, and snippets.

@MasterGroosha
Last active July 15, 2017 08:34
Show Gist options
  • Save MasterGroosha/0ae99d58b556e14e923397094d4a8d03 to your computer and use it in GitHub Desktop.
Save MasterGroosha/0ae99d58b556e14e923397094d4a8d03 to your computer and use it in GitHub Desktop.
#NoEnv
#SingleInstance force
SendMode Input
SetWorkingDir %A_ScriptDir%
#Include AHKHID.ahk
;Set up the constants
AHKHID_UseConstants()
diff := 101
Gui, +LastFound
hGui := WinExist()
;Intercept WM_INPUT
OnMessage(0x00FF, "InputMsg")
AHKHID_AddRegister(1)
; 2 for mouse, 6 for keyboard
AHKHID_AddRegister(1, 2, hGui, RIDEV_INPUTSINK)
AHKHID_Register()
; Getting input from mouse
InputMsg(wParam, lParam) {
Local r, h
Critical ; Or otherwise you could get ERROR_INVALID_HANDLE
lastUsedMouse := A_TickCount
}
KeyCombo(key) {
SendInput, {VK5B down}{vk%key%}{VK5B up}
Return
}
$F13::
diff := (A_TickCount - lastUsedMouse)
if (diff > 100) {
SendInput, {VK5B down}{VK5B up}
Return
} else {
Return
}
F13 & a::
diff := (A_TickCount - lastUsedMouse)
if (diff > 100) {
SendInput, {VK5B down}a{VK5B up}
Return
} else {
Return
}
F13 & d::
diff := (A_TickCount - lastUsedMouse)
if (diff > 100) {
SendInput, {VK5B down}d{VK5B up}
Return
} else {
Return
}
F13 & e::KeyCombo(45)
F13 & m::KeyCombo(4D)
F13 & p::KeyCombo(50)
F13 & r::KeyCombo(52)
F13 & f::KeyCombo(46)
F13 & s::KeyCombo(53)
F13 & VK09::KeyCombo(09) ; Win+Tab
F13 & VK13::KeyCombo(13) ; Win+Pause
F13 & VK30::KeyCombo(30) ; 0-9
F13 & VK31::KeyCombo(31)
F13 & VK32::KeyCombo(32)
F13 & VK33::KeyCombo(33)
F13 & VK34::KeyCombo(34)
F13 & VK35::KeyCombo(35)
F13 & VK36::KeyCombo(36)
F13 & VK37::KeyCombo(37)
F13 & VK38::KeyCombo(38)
F13 & VK39::KeyCombo(39)
F13 & Down::
diff := (A_TickCount - lastUsedMouse)
if (diff > 100) {
SendInput, {VK5B down}{Down}{VK5B up}
Return
} else {
Return
}
F13 & Up::
SendInput, {VK5B down}{Up}{VK5B up}
Return
F13 & Left::
KeyWait, LCtrl, d, t0.2
If ErrorLevel
SendInput, {VK5B down}{Left}{VK5B up}
else
SendInput, {VK5B down}{LCtrl down}{Left}{LCtrl up}{VK5B up}
Return
F13 & Right::
KeyWait, LCtrl, d, t0.2
If ErrorLevel
SendInput, {VK5B down}{Right}{VK5B up}
Else
SendInput, {VK5B down}{LCtrl down}{Right}{LCtrl up}{VK5B up}
Return
; Ctrl+Win
^F13::
KeyWait, Left, d, t0.2
If (ErrorLevel) {
KeyWait, Right, d, t0.2
If (ErrorLevel) {
SendInput, {LCtrl down}{VK5B down}{VK5B up}{LCtrl up}
} else {
SendInput, {VK5B down}{LCtrl down}{Right}{LCtrl up}{VK5B up}
}
} else {
SendInput, {VK5B down}{LCtrl down}{Left}{LCtrl up}{VK5B up}
}
Return
F13 & T::
diff := (A_TickCount - lastUsedMouse)
if (diff > 100) {
SendInput, {VK5B down}{T}{VK5B up}
Return
} else {
Return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment