Griffin Powermate (USB) AHKHID script
Posted: 19 Jun 2018, 18:03
Here's my script to control the Griffin Powermate. This enables you to get rid of the official (unsupported) Powermate software.
Per default, only left and right turn are assigned (mousewheel up and down), but you can easily add the other functions as well (button press, button press + turn left, button press + turn right.
Additionally you can also use modifiers (which is not possible with the official software). So you can use CTRL + Powermate turn left, etc...
And last but not least, you could also create different assignments, depending on which window has focus.
The only thing you can't configure: the LED.
Per default, only left and right turn are assigned (mousewheel up and down), but you can easily add the other functions as well (button press, button press + turn left, button press + turn right.
Additionally you can also use modifiers (which is not possible with the official software). So you can use CTRL + Powermate turn left, etc...
And last but not least, you could also create different assignments, depending on which window has focus.
The only thing you can't configure: the LED.
Code: Select all
SetWorkingDir %A_ScriptDir%
#include ahkhid.ahk
#InstallKeybdHook ;install keyboard hook, enables you to use modifier keys in conjunction with the Powermate
Gui, +LastFound
GuiH := WinExist()
;Intercept WM_INPUT messages
WM_INPUT := 0xFF
OnMessage(WM_INPUT, "InputMsg")
AHKHID_Register(12, 1,GuiH, RIDEV_INPUTSINK) ;register device
InputMsg(wParam, lParam)
{
Local devh, key
Critical ;or otherwise you could get ERROR_INVALID_HANDLE
;get handle of device
devh := AHKHID_GetInputInfo(lParam, II_DEVHANDLE)
If (devh <> -1)
And (AHKHID_GetDevInfo(devh, DI_DEVTYPE, True) = RIM_TYPEHID)
And (AHKHID_GetDevInfo(devh, DI_HID_VENDORID, True) = 1917) ;Replace these three
And (AHKHID_GetDevInfo(devh, DI_HID_PRODUCTID, True) = 1040) ;numbers with your
And (AHKHID_GetDevInfo(devh, DI_HID_VERSIONNUMBER, True) = 8) ;devices numbers.
{
;get the keycode
key := (AHKHID_GetInputInfo(lParam, II_MSE_RAWBUTTONS))
If (key == 16711680) ; turn Powermate left
SendInput {WheelDown} ;send mousewheel down
If (key == 65536) ; turn Powermate right
SendInput {WheelUp} ;send mousewheel up
;If (key == 256) ; press button
;assign your own action
;If (key == 16711936) ; press button + turn Powermate left
;assign your own action
;If (key == 65792) ; press button + turn Powermate right
;assign your own action
}
}