Hello Guys
I am new at AHK, but I learned it quickly.
I have a Logitech Keyboard Controller
http://www.logitech.com/en-us/smartTV/a ... controller
It's a Logitech Keyboard with Touchpad specially designed for Google TV, but it also works on PC using the Logitech Unifying receiver provided with it.
So when I use it with my PC, some special keys don't work.
I investigated it deeply and found Raw Input.
Using AHKHID (That is implemented with Raw Input) I could capture this special keys, then I have made a script for managing those keys using AHK and AHKHID.
Here it is:
Code:
/*!
Script Developed by Emisand
Logitech Keyboard Controller (LKC)
Model: K700
Vendor ID: 1133
Product ID: 50475
Version Number: 4610
Usage Page: 12
Usage: 1
Key Name Raw Data Description
-------------- ---------- -------------------------
LKC_RELEASE 0300000000 Key released event
LKC_FN 03F0010000 FN Key
LKC_TV_LEFT 0389000000 Left TV Key
LKC_GUIDE 038D000000 Guide Key
LKC_DVR 039A000000 DVR Key
LKC_AVR 03F3010000 AVR Key
LKC_STB 03FC010000 STB Key
LKC_TV_RIGHT 03FE010000 Right TV Key
LKC_FN_AVR 03F001F201 FN + AVR
LKC_FN_STB 03F001FB01 FN + STB
LKC_FN_TV 03F001FD01 FN + Right TV
LKC_CH_UP 039C000000 Channel Up Key
LKC_CH_DN 039D000000 Channel Down Key
LKC_FAV 032A020000 Favorites Key (Star)
LKC_SCREEN 03F1010000 Screen Key (Squares)
LKC_SK_A 03F001F501 Special Key A (FN+5)
LKC_SK_B 03F001F401 Special Key B (FN+6)
LKC_SK_C 03F001F701 Special Key C (FN+7)
LKC_SK_D 03F001F601 Special Key D (FN+8)
LKC_MENU 03F001EF01 Menu Key (FN+9)
LKC_INFO 03F001FF01 Info Key (FN+0)
LKC_ZOOM_OUT 03F0012E02 Zoom Out Key (FN+-)
LKC_ZOOM_IN 03F0012D02 Zoom In Key (FM+=)
LKC_REW 03B4000000 Rewind Key
LKC_PLAY 03B0000000 Play Key
LKC_PAUSE 03B1000000 Pause Key
LKC_FF 03B3000000 Fast Forward Key
LKC_PREV 03F001B600 Previous Track (FN+REW)
LKC_STOP 03F001B700 Stop Key (FN+Pause)
LKC_NEXT 03F001B500 Next Track (FN+FF)
LKC_REC 03F001B200 Rec Key (FN+Fav)
LKC_HOME 0323020000 Home Key
LKC_BACK 0324020000 Back key (Arrow)
*/
;Loads the required AHKHID Script
#Include AHKHID.ahk
;Create GUI to receive messages
Gui, +LastFound
hGui := WinExist()
;Intercept WM_INPUT messages
WM_INPUT := 0xFF
OnMessage(WM_INPUT, "InputMsg")
;Register Remote Control with RIDEV_INPUTSINK (so that data is received even in the background)
r := AHKHID_Register(12, 1, hGui, RIDEV_INPUTSINK)
InputMsg(wParam, lParam)
{
Local devh, iKey, sLabel
Critical
;Get handle of device
devh := AHKHID_GetInputInfo(lParam, II_DEVHANDLE)
;Check for error
If (devh <> -1) ;Check that it is Logitech Keyboard Controller
And (AHKHID_GetDevInfo(devh, DI_DEVTYPE, True) = RIM_TYPEHID)
And (AHKHID_GetDevInfo(devh, DI_HID_VENDORID, True) = 1133)
And (AHKHID_GetDevInfo(devh, DI_HID_PRODUCTID, True) = 50475)
And (AHKHID_GetDevInfo(devh, DI_HID_VERSIONNUMBER, True) = 4610)
{
;Get data
iKey := AHKHID_GetInputData(lParam, uData)
;Check for error
If (iKey <> -1)
{
byte1 := NumGet(uData, 1, "UChar")
byte2 := NumGet(uData, 2, "UChar")
byte3 := NumGet(uData, 3, "UChar")
byte4 := NumGet(uData, 4, "UChar")
sLabel := "UNDEFINED"
If(byte1 = 0x0 And byte2 = 0x0 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_RELEASE"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_FN"
If(byte1 = 0x89 And byte2 = 0x0 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_TV_LEFT"
If(byte1 = 0x8D And byte2 = 0x0 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_GUIDE"
If(byte1 = 0x9A And byte2 = 0x0 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_DVR"
If(byte1 = 0xF3 And byte2 = 0x1 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_AVR"
If(byte1 = 0xFC And byte2 = 0x1 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_STB"
If(byte1 = 0xFE And byte2 = 0x1 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_TV_RIGHT"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0xF2 And byte4 = 0x1)
sLabel := "LKC_FN_AVR"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0xFB And byte4 = 0x1)
sLabel := "LKC_FN_STB"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0xFD And byte4 = 0x1)
sLabel := "LKC_FN_TV"
If(byte1 = 0x9C And byte2 = 0x0 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_CH_UP"
If(byte1 = 0x9D And byte2 = 0x0 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_CH_DN"
If(byte1 = 0x2A And byte2 = 0x2 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_FAV"
If(byte1 = 0xF1 And byte2 = 0x1 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_SCREEN"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0xF5 And byte4 = 0x1)
sLabel := "LKC_SK_A"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0xF4 And byte4 = 0x1)
sLabel := "LKC_SK_B"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0xF7 And byte4 = 0x1)
sLabel := "LKC_SK_C"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0xF6 And byte4 = 0x1)
sLabel := "LKC_SK_D"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0xEF And byte4 = 0x1)
sLabel := "LKC_MENU"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0xFF And byte4 = 0x1)
sLabel := "LKC_INFO"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0x2E And byte4 = 0x2)
sLabel := "LKC_ZOOM_OUT"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0x2D And byte4 = 0x2)
sLabel := "LKC_ZOOM_IN"
If(byte1 = 0xB4 And byte2 = 0x0 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_REW"
If(byte1 = 0xB0 And byte2 = 0x0 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_PLAY"
If(byte1 = 0xB1 And byte2 = 0x0 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_PAUSE"
If(byte1 = 0xB3 And byte2 = 0x0 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_FF"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0xB6 And byte4 = 0x0)
sLabel := "LKC_PREV"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0xB7 And byte4 = 0x0)
sLabel := "LKC_STOP"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0xB5 And byte4 = 0x0)
sLabel := "LKC_NEXT"
If(byte1 = 0xF0 And byte2 = 0x1 And byte3 = 0xB2 And byte4 = 0x0)
sLabel := "LKC_REC"
If(byte1 = 0x23 And byte2 = 0x2 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_HOME"
If(byte1 = 0x24 And byte2 = 0x2 And byte3 = 0x0 And byte4 = 0x0)
sLabel := "LKC_BACK"
If IsLabel(sLabel)
Gosub, %sLabel%
}
}
}
LKC_RELEASE: ; Key released event
Return
LKC_FN: ; FN Key
Return
LKC_TV_LEFT: ; Left TV Key
SendInput LKC_TV_LEFT {Enter}
Return
LKC_GUIDE: ; Guide Key
SendInput LKC_GUIDE {Enter}
Return
LKC_DVR: ; DVR Key
SendInput LKC_DVR {Enter}
Return
LKC_AVR: ; AVR Key
SendInput LKC_AVR {Enter}
Return
LKC_STB: ; STB Key
SendInput LKC_STB {Enter}
Return
LKC_TV_RIGHT: ; Right TV Key
SendInput LKC_TV_RIGHT {Enter}
Return
LKC_FN_AVR: ; FN + AVR
SendInput LKC_FN_AVR {Enter}
Return
LKC_FN_STB: ; FN + STB
SendInput LKC_FN_STB {Enter}
Return
LKC_FN_TV: ; FN + Right TV
SendInput LKC_FN_TV {Enter}
Return
LKC_CH_UP: ; Channel Up Key
SendInput LKC_CH_UP {Enter}
Return
LKC_CH_DN: ; Channel Down Key
SendInput LKC_CH_DN {Enter}
Return
LKC_FAV: ; Favorites Key (Star)
SendInput LKC_FAV {Enter}
Return
LKC_SCREEN: ; Screen Key (Squares)
SendInput LKC_SCREEN {Enter}
Return
LKC_SK_A: ; Special Key A (FN+5)
SendInput LKC_SK_A {Enter}
Return
LKC_SK_B: ; Special Key B (FN+6)
SendInput LKC_SK_B {Enter}
Return
LKC_SK_C: ; Special Key C (FN+7)
SendInput LKC_SK_C {Enter}
Return
LKC_SK_D: ; Special Key D (FN+8)
SendInput LKC_SK_D {Enter}
Return
LKC_MENU: ; Menu Key (FN+9)
SendInput LKC_MENU {Enter}
Return
LKC_INFO: ; Info Key (FN+0)
SendInput LKC_INFO {Enter}
Return
LKC_ZOOM_OUT: ; Zoom Out Key (FN+-)
SendInput LKC_ZOOM_OUT {Enter}
Return
LKC_ZOOM_IN: ; Zoom In Key (FM+=)
SendInput LKC_ZOOM_IN {Enter}
Return
LKC_REW: ; Rewind Key
SendInput LKC_REW {Enter}
Return
LKC_PLAY: ; Play Key
SendInput LKC_PLAY {Enter}
Return
LKC_PAUSE: ; Pause Key
SendInput LKC_PAUSE {Enter}
Return
LKC_FF: ; Fast Forward Key
SendInput LKC_FF {Enter}
Return
LKC_PREV: ; Previous Track (FN+REW)
SendInput LKC_PREV {Enter}
Return
LKC_STOP: ; Stop Key (FN+Pause)
SendInput LKC_STOP {Enter}
Return
LKC_NEXT: ; Next Track (FN+FF)
SendInput LKC_NEXT {Enter}
Return
LKC_REC: ; Rec Key (FN+Fav)
SendInput LKC_REC {Enter}
Return
LKC_HOME: ; Home Key
SendInput LKC_HOME {Enter}
Return
LKC_BACK: ; Back key (Arrow)
SendInput LKC_BACK {Enter}
Return
I have properly commented every key, showing a name I picked for them, the raw data sent by the keyboard and a description of the key.
Then I have managed the WM_INPUT Message so for each recognized raw input data I let the script go to a tag and do any specific operation with that key.
For now, it just sends an input with the key name, so it's open to customize.
You can recognize some more keys of this keybord that I have not listed, for example FN+1, FN+2, FN+3, FN+4, you can get the raw data of those keystrokes using AHKHID.
I hope this can help someone.