Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

HID/Extended input devices (MS Natural Keyboard 4000 etc.)


  • Please log in to reply
44 replies to this topic
ezuk
  • Members
  • 149 posts
  • Last active: Jan 02 2013 08:54 AM
  • Joined: 04 Jun 2005
This is truly fantastic, Shaun. I've been waiting for something like this for a long long time. Awesome!

sutari
  • Guests
  • Last active:
  • Joined: --
Hi this is great, now I can map my keyboard without microsoft drivers. The only thing is that is a problem now is I am so new to AHK that I do not understand the script. If anyone can help me out here would be great. I want to map zoom slider to "[" "]" keys on the keyboard.

thanks

mai9
  • Members
  • 63 posts
  • Last active: Aug 15 2011 04:23 PM
  • Joined: 17 Mar 2008

Hi this is great, now I can map my keyboard without microsoft drivers. The only thing is that is a problem now is I am so new to AHK that I do not understand the script. If anyone can help me out here would be great. I want to map zoom slider to "[" "]" keys on the keyboard.

thanks


hi sutari, I don't know much about AutoHotkey (and I don't know if you'll read this after 4 months), but I think that this code will do what you want, although the zoom slider is not suposed to send normal keys as the hardware sends repeated strokes.


; Capture input from the "Zoom" slider on the Natural Keyboard 4000
; and use it to scroll up and scroll down

; The HID top level collection for the Natural Keyboard 4000 is:
;   Usage         1
;   Usage Page   12

#NoTrayIcon

; Replace any previous instance
#SingleInstance force

DetectHiddenWindows, on
OnMessage(0x00FF, "InputMessage")

SizeofRawInputDeviceList := 8
SizeofRidDeviceInfo := 32

RIM_TYPEMOUSE := 0
RIM_TYPEKEYBOARD := 1
RIM_TYPEHID := 2

RIDI_DEVICENAME := 0x20000007
RIDI_DEVICEINFO := 0x2000000b

RIDEV_INPUTSINK := 0x00000100

RID_INPUT       := 0x10000003

Usage := 1
UsagePage := 12

Gui, Show, Hide, NaturalCapture

HWND := WinExist("NaturalCapture")

; Keyboards are always Usage 6, Usage Page 1, Mice are Usage 2, Usage Page 1,
; HID devices specify their top level collection in the info block   

VarSetCapacity(RawDevice, 12)
NumPut(RIDEV_INPUTSINK, RawDevice, 4)
NumPut(HWND, RawDevice, 8)
NumPut(UsagePage, RawDevice, 0, "UShort")
NumPut(Usage, RawDevice, 2, "UShort")     

Res := DllCall("RegisterRawInputDevices", "UInt", &RawDevice, UInt, 1, UInt, 12)
if (Res = 0)
   MsgBox, Failed to register for Natural Keyboard

InputMessage(wParam, lParam, msg, hwnd)
{
   global DoCapture
   global RIM_TYPEMOUSE, RIM_TYPEKEYBOARD, RIM_TYPEHID
   global RID_INPUT
   
   if (DoCapture = 0)
      return
   
   Res := DllCall("GetRawInputData", UInt, lParam, UInt, RID_INPUT, UInt, 0, "UInt *", Size, UInt, 16)
     
   VarSetCapacity(Buffer, Size)
   
   Res := DllCall("GetRawInputData", UInt, lParam, UInt, RID_INPUT, UInt, &Buffer, "UInt *", Size, UInt, 16)
   
   Type := NumGet(Buffer, 0 * 4)
   Size := NumGet(Buffer, 1 * 4)
   Handle := NumGet(Buffer, 2 * 4)
   
   ;AppendOutput("Got Input with " . Res . " size " . Size . " Type " . Type . " Handle " . Handle . "`r`n")
   
   if (Type = RIM_TYPEHID)
   {
      SizeHid := NumGet(Buffer, (16 + 0))
      InputCount := NumGet(Buffer, (16 + 4))
      ;Debug("HND " . Handle . " HID Size " . SizeHid . " Count " . InputCount . " Ptr " . &Buffer . "`r`n")
      Loop %InputCount% {
         Addr := &Buffer + 24 + ((A_Index - 1) * SizeHid)
         BAddr := &Buffer
         ;MsgBox, BAddr %BAddr% Addr %Addr%
         Input := Mem2Hex(Addr, SizeHid)
         ;Debug("Input " . Input . "`r`n")
         if (IsLabel(Input))
            Gosub, %Input%
      }
   }
   
   return
}
return

Exit

GuiClose:
ExitApp

; 1 = UP, 2 = DOWN
ScrollDir := 0

DoScroll:
ControlGetFocus, fcontrol, A
; WM_VSCROLL = 0x115, SB_LINEUP = 0, SB_LINEDOWN = 1

WinGetClass, ClassName, A
;Debug("Class " . ClassName)
if (InStr(ClassName, "Mozilla"))
{
   IsMozilla := 1
}
else
{
   IsMozilla := 0
}
Loop 1 {
   if (ScrollDir = 1)
   {
      if (IsMozilla)
         SendInput, {Up}
      else
         Send [
   }
   else
   {
      if (IsMozilla)
         SendInput, {Down}
      else
         Send ]
   }
}
;Debug("Done")
Return

; Zoom down
012E020000010000:
ScrollDir := 2
GoSub, DoScroll
SetTimer, DoScroll, 1080
return

; Zoom up
012D020000010000:
ScrollDir := 1
GoSub, DoScroll
SetTimer, DoScroll, 1080
return

; All up
0100000000010000:
ScrollDir := 0
SetTimer, DoScroll, Off
return

Debug(msg)
{
   OutputDebug, %msg%
   return
}

Mem2Hex( pointer, len )
{
 A_FI := A_FormatInteger
 SetFormat, Integer, Hex
 Loop, %len%  {
                   Hex := *Pointer+0
                   StringReplace, Hex, Hex, 0x, 0x0
                   StringRight Hex, Hex, 2           
                   hexDump := hexDump . hex
                   Pointer ++
                 }
 SetFormat, Integer, %A_FI%
 StringUpper, hexDump, hexDump
Return hexDump
}

What I did is remove the loop so it only sends one keystroke and increase the timer so it takes a long time to send two keystrokes. It still scrolls on Mozilla, you can eliminate that if you want.

fenderist
  • Members
  • 12 posts
  • Last active: Mar 17 2014 06:05 PM
  • Joined: 14 Jul 2010
First of all, thank you so much for this thread!
Well, when I remap the arrow keys into favorite keys, I can get the navigation correctly (i.e. word processor), but when I try it with shortcut keys, it does not work. For example, Win+Left will not give me the half screen in Windows 7.
I can remap left key into 'b' like this
*b::SendInput {Blind}{Right}
and it works, but if I do
; Favorites 2
 0100000000090000:
 SendInput {Blind}{Left}
 return
it does not work. Is there any way to key around this problem?

blablaman1
  • Members
  • 2 posts
  • Last active: Oct 31 2010 05:24 PM
  • Joined: 31 Oct 2010
this is awesome! Thank you very much. I've tamed my MS keyboard horse )

But actually I've spent a few hours for that... And the problem was DLL calls you use do not work under win7x64 if you install 64-bit version of autohotkey... But discovering that took me whole life...

But now It is ok. I do not remap all the extra keys - I use intelliType too (but disabled remapped keys, otherwise events duplicate each other and do double work). Remapped keys are very clever now =) for example, My Favorites launches Total Commander if it is not launched or brings to front if it exist. So do PlayPause button with aimp.

; My Favorites
0182010000010000:
   If WinExist("ahk_class TTOTAL_CMD")
       WinActivate ; use the window found above
   else
       Run d:\distrib\TotalCommander\Totalcmd7\LaunchTC.lnk

; Play-Pause button
01CD000000010000:
    If WinExist("ahk_class TAIMP2MainW")
    {
        Send ^!+p ; this is my AIMP's global hot key - CtrlAltShiftP
    }
    else
    {
        Run d:\distrib\AIMP\AIMP2\AIMP2.exe
        while !(WinExist("ahk_class TAIMP2MainW"))
        {
            Sleep 333
        }
        Sleep 999
        Send ^!+p
    }

To find out this key code 01CD000000010000 I have to use VMWare and WinXP 32 bit (this is how I've managed to run all these scripts at all including AHKHID <!-- m -->http://www.autohotke... ... 910226214f<!-- m -->

blablaman11
  • Guests
  • Last active:
  • Joined: --
wow I can not reproduce catching codes for special buttons =(( I mean favorites keys and other extra. I use vmware and WinXP, I use my win7x64 and autohotkey in all of them... different versions of autohotkey. Just do not know what to do )))

blablaman1
  • Members
  • 2 posts
  • Last active: Oct 31 2010 05:24 PM
  • Joined: 31 Oct 2010
oh I have just misplaced usage and usage page.

Use AHKHID example 2 and type 12 as usage page and 1 as usage. Then you will be able to catch ms natural 4000 extra buttons

mai9
  • Members
  • 63 posts
  • Last active: Aug 15 2011 04:23 PM
  • Joined: 17 Mar 2008

the problem was DLL calls you use do not work under win7x64 if you install 64-bit version of autohotkey... But discovering that took me whole life...


I also found that the script doesn't work when using the new AutoHotkey_L v1.0.92.00. What should we do? Does anybody know how to fix it?

When I load the script it says "Failed to register for Natural Keyboard". :cry:

Kuklakot
  • Guests
  • Last active:
  • Joined: --
OK, so I butchered the original script a little to adapt it for x64 platform. The problem was with the fact that Windows pointer types became twice as big in x64 so the original structs didn't fit the actual messages. NumGet is also platform sensitive so the data sizes need to be stated explicitly in every call. I also tried to get rid of all the "magic numbers" in the original code to improve readability a little.

; Capture input from the "Zoom" slider on the Natural Keyboard 4000 
; and use it to scroll up and scroll down 

; The HID top level collection for the Natural Keyboard 4000 is: 
;   Usage         1 
;   Usage Page   12

#NoTrayIcon

; Replace any previous instance
#SingleInstance force

C(str) ; const container
{
return, (%str%)
static MS_SHORT := 2
static MS_DWORD := 4
static MS_PTR := 8 ;x64 specific

static SizeofRawInputDevice := MS_SHORT*2 + MS_DWORD + MS_PTR
/*
typedef struct tagRAWINPUTDEVICE {
  USHORT usUsagePage;
  USHORT usUsage;
  DWORD  dwFlags;
  HWND   hwndTarget;
} RAWINPUTDEVICE, *PRAWINPUTDEVICE, *LPRAWINPUTDEVICE;
*/

static SizeofRawInputDataHeader := MS_DWORD*2 + MS_PTR*2
/*
typedef struct tagRAWINPUTHEADER {
  DWORD  dwType;
  DWORD  dwSize;
  HANDLE hDevice;
  WPARAM wParam;
} RAWINPUTHEADER, *PRAWINPUTHEADER;
*/

static RIM_TYPEMOUSE := 0
static RIM_TYPEKEYBOARD := 1
static RIM_TYPEHID := 2

static RIDI_DEVICENAME := 0x20000007
static RIDI_DEVICEINFO := 0x2000000b

static RIDEV_INPUTSINK := 0x00000100 ; receive in foreground
static RID_INPUT       := 0x10000003 ; request header

; Keyboards are always Usage 6, Usage Page 1, Mice are Usage 2, Usage Page 1, 
; HID devices specify their top level collection in the info block   
static Usage := 1
static UsagePage := 12
}

HID_Input_Init:
{
DetectHiddenWindows, on
OnMessage(0x00FF, "InputMessage")

Gui, Show, Hide, NaturalCapture

HWND := WinExist("NaturalCapture")

VarSetCapacity(RawInputDevice, C("SizeofRawInputDevice"))
NumPut(C("UsagePage"), RawInputDevice, 0)
NumPut(C("Usage"), RawInputDevice, C("MS_SHORT"))
NumPut(C("RIDEV_INPUTSINK"), RawInputDevice, C("MS_SHORT")*2)
NumPut(HWND, RawInputDevice, C("MS_SHORT")*2 + C("MS_DWORD"))

Res := DllCall("RegisterRawInputDevices", "UInt", &RawInputDevice, UInt, 1, UInt, C("SizeofRawInputDevice"))
if (Res = 0)
    MsgBox, Failed to register for Natural Keyboard

return
}

InputMessage(wParam, lParam, msg, hwnd)
{
    Res := DllCall("GetRawInputData", UInt, lParam, UInt, C("RID_INPUT"), UInt, 0, "UInt *", Size, UInt, C("SizeofRawInputDataHeader"))

    VarSetCapacity(RawInputData, Size)

    Res := DllCall("GetRawInputData", UInt, lParam, UInt, C("RID_INPUT"), UInt, &RawInputData, "UInt *", Size, UInt, C("SizeofRawInputDataHeader"))

    SetFormat, Integer, Hex
    Type := NumGet(RawInputData, 0, "UInt")
    Size := NumGet(RawInputData, 1 * C("MS_DWORD"), "UInt")
    Handle := NumGet(RawInputData, 2 * C("MS_DWORD"), "UInt64") ; x64 specific

    if (Type = C("RIM_TYPEHID"))
    {
        SizeHid := NumGet(RawInputData, (C("SizeofRawInputDataHeader") + 0), "UInt")
        InputCount := NumGet(RawInputData, (C("SizeofRawInputDataHeader") + C("MS_DWORD")), "UInt")
        Loop %InputCount% {
            Addr := &RawInputData + C("SizeofRawInputDataHeader") + C("MS_DWORD")*2 + ((A_Index - 1) * SizeHid)
            BAddr := &RawInputData
            Input := Mem2Hex(Addr, SizeHid)
		    ;MsgBox, %Input%
			/*
			if (Input != 0100000000010000 && Input != 0100000000000000)
			{
			    SoundPlay, *64
			    clipboard = %clipboard%`r`n%Input%
			}
			*/
            if (IsLabel(Input))
            Gosub, %Input%
        }
    }
    else

    return
}

Scroll:
{
    if (ScrollDirection == 1)
	{
		SendInput, {up}
	}
	else if (ScrollDirection == 2)
	{
		SendInput, {down}
	}
	return
}

; Zoom up
012D020000010000:
ScrollDirection := 1
GoSub Scroll
SetTimer, Scroll, 50
return

; Zoom down
012E020000010000:
ScrollDirection := 2
GoSub Scroll
SetTimer, Scroll, 50
return

; All up
0100000000010000:
ScrollDirection := 0
SetTimer, Scroll, Off
return

Mem2Hex(pointer, len)
{
    A_FI := A_FormatInteger
    SetFormat, Integer, Hex
	Loop, %len% {
                    Hex := *Pointer+0
                    StringReplace, Hex, Hex, 0x, 0x0
                    StringRight Hex, Hex, 2
                    hexDump := hexDump . hex
                    Pointer ++
                }
    SetFormat, Integer, %A_FI%
    StringUpper, hexDump, hexDump
    Return hexDump
}


Silion
  • Guests
  • Last active:
  • Joined: --
Kuklakot you are my hero :D

I don't like using up and down as scrolling though so here is my take on it (plus a few hotkeys and different keycodes)

; Capture input from the "Zoom" slider on the Natural Keyboard 4000 
; and use it to scroll up and scroll down 

; The HID top level collection for the Natural Keyboard 4000 is: 
;   Usage         1 
;   Usage Page   12 

#NoTrayIcon 

; Replace any previous instance 
#SingleInstance force 

C(str) ; const container 
{ 
return, (%str%) 
static MS_SHORT := 2 
static MS_DWORD := 4 
static MS_PTR := 8 ;x64 specific 

static SizeofRawInputDevice := MS_SHORT*2 + MS_DWORD + MS_PTR 
/* 
typedef struct tagRAWINPUTDEVICE { 
  USHORT usUsagePage; 
  USHORT usUsage; 
  DWORD  dwFlags; 
  HWND   hwndTarget; 
} RAWINPUTDEVICE, *PRAWINPUTDEVICE, *LPRAWINPUTDEVICE; 
*/ 

static SizeofRawInputDataHeader := MS_DWORD*2 + MS_PTR*2 
/* 
typedef struct tagRAWINPUTHEADER { 
  DWORD  dwType; 
  DWORD  dwSize; 
  HANDLE hDevice; 
  WPARAM wParam; 
} RAWINPUTHEADER, *PRAWINPUTHEADER; 
*/ 

static RIM_TYPEMOUSE := 0 
static RIM_TYPEKEYBOARD := 1 
static RIM_TYPEHID := 2 

static RIDI_DEVICENAME := 0x20000007 
static RIDI_DEVICEINFO := 0x2000000b 

static RIDEV_INPUTSINK := 0x00000100 ; receive in foreground 
static RID_INPUT       := 0x10000003 ; request header 

; Keyboards are always Usage 6, Usage Page 1, Mice are Usage 2, Usage Page 1, 
; HID devices specify their top level collection in the info block    
static Usage := 1 
static UsagePage := 12 
} 

HID_Input_Init: 
{ 
DetectHiddenWindows, on 
OnMessage(0x00FF, "InputMessage") 

Gui, Show, Hide, NaturalCapture 

HWND := WinExist("NaturalCapture") 

VarSetCapacity(RawInputDevice, C("SizeofRawInputDevice")) 
NumPut(C("UsagePage"), RawInputDevice, 0) 
NumPut(C("Usage"), RawInputDevice, C("MS_SHORT")) 
NumPut(C("RIDEV_INPUTSINK"), RawInputDevice, C("MS_SHORT")*2) 
NumPut(HWND, RawInputDevice, C("MS_SHORT")*2 + C("MS_DWORD")) 

Res := DllCall("RegisterRawInputDevices", "UInt", &RawInputDevice, UInt, 1, UInt, C("SizeofRawInputDevice")) 
if (Res = 0) 
    MsgBox, Failed to register for Natural Keyboard 

return 
} 

InputMessage(wParam, lParam, msg, hwnd) 
{ 
    Res := DllCall("GetRawInputData", UInt, lParam, UInt, C("RID_INPUT"), UInt, 0, "UInt *", Size, UInt, C("SizeofRawInputDataHeader")) 

    VarSetCapacity(RawInputData, Size) 

    Res := DllCall("GetRawInputData", UInt, lParam, UInt, C("RID_INPUT"), UInt, &RawInputData, "UInt *", Size, UInt, C("SizeofRawInputDataHeader")) 

    SetFormat, Integer, Hex 
    Type := NumGet(RawInputData, 0, "UInt") 
    Size := NumGet(RawInputData, 1 * C("MS_DWORD"), "UInt") 
    Handle := NumGet(RawInputData, 2 * C("MS_DWORD"), "UInt64") ; x64 specific 

    if (Type = C("RIM_TYPEHID")) 
    { 
        SizeHid := NumGet(RawInputData, (C("SizeofRawInputDataHeader") + 0), "UInt") 
        InputCount := NumGet(RawInputData, (C("SizeofRawInputDataHeader") + C("MS_DWORD")), "UInt") 
        Loop %InputCount% { 
            Addr := &RawInputData + C("SizeofRawInputDataHeader") + C("MS_DWORD")*2 + ((A_Index - 1) * SizeHid) 
            BAddr := &RawInputData 
            Input := Mem2Hex(Addr, SizeHid) 
          ;MsgBox, %Input% 
         /* 
         if (Input != 0100000000010000 && Input != 0100000000000000) 
         { 
             SoundPlay, *64 
             clipboard = %clipboard%`r`n%Input% 
         } 
         */ 
            if (IsLabel(Input)) 
            Gosub, %Input% 
        } 
    } 
    else 
    return 
}

; 1 = UP, 2 = DOWN 
ScrollDir := 0 

DoScroll: 
ControlGetFocus, fcontrol, A 
; WM_VSCROLL = 0x115, SB_LINEUP = 0, SB_LINEDOWN = 1 

Loop 1 
{ 
   if (ScrollDir = 1) 
      SendInput, {WheelUp}  
   else 
      SendInput, {WheelDown} 
} 
Return 

; //  Special Keys  //
	; ++  Function Keys  ++
		; Function Key "=" 
		0100006700000000: 
		Send {=}
		return
		
		; Function Key "(" 
		010000B600000000:
		Send {(} 
		return
		
		; Function Key ")" 
		010000B700000000:
		Send {)} 
		return

	; ++  Favorites Keys  ++
		; Favorites 1
		0100000000040000:
		Send {)} 
		return
		
		; Favorites 2
		0100000000080000:
		Send {)} 
		return
		
		; Favorites 3
		0100000000100000:
		Send {)} 
		return
		
		; Favorites 4
		0100000000200000:
		Send {)} 
		return
		
		; Favorites 5
		0100000000400000:
		Run "C:\Program Files\uTorrent\utorrent.exe" 
		return
		
		; My Favorites
		0182010000000000:
		Run "C:\Program Files\uTorrent\utorrent.exe"
		return

	; ++  Media Keys  ++
		; Play/Pause
		01CD000000000000:
		If WinExist("ahk_class XMPLAY-MAIN") 
				ControlSend, , {Media_Play_Pause}, ahk_class XMPLAY-MAIN
		else
		{ 
			Run "D:\Archiwum\Programy\Inne\Music Players\XMPlay\XMPlay.exe"
			while !(WinExist("ahk_class XMPLAY-MAIN"))          
				Sleep 333         
			Sleep 999 
			ControlSend, , {Media_Play_Pause}, ahk_class XMPLAY-MAIN
		}
		return

		; Calculator
		0192010000000000:
		Run "D:\Archiwum\Programy\System\Narzedzia\Windows7-calculator\Calc.exe"
		return
	; ++  Zoom/Scroll Keys  ++
		; Zoom Down 
		012E020000000000: 
		ScrollDir := 2 
		GoSub, DoScroll 
		SetTimer, DoScroll, 80 
		return 

		; Zoom Up 
		012D020000000000: 
		ScrollDir := 1 
		GoSub, DoScroll 
		SetTimer, DoScroll, 80 
		return 
		
	; All up 
	0100000000000000: 
	ScrollDir := 0 
	SetTimer, DoScroll, Off 
	return 
	
	; ++  Standard Special Keys  ++
	Launch_Mail::Run "C:\Program Files (x86)\Mozilla\Thunderbird\thunderbird.exe"
	Browser_Search::Run "C:\Program Files (x86)\Avira\AntiVir Desktop\avscan.exe" /GUIMODE=1 /PATH="c:\"
	Browser_Home::DllCall("PowrProf\SetSuspendState", "int", 0, "int", 1, "int", 0)

; //  Combinations  //
	^PgUp::ControlSend, , ^{PgUp}, ahk_class XMPLAY-MAIN
	^PgDn::ControlSend, , ^{PgDn}, ahk_class XMPLAY-MAIN
	^End::ControlSend, , ^{End}, ahk_class XMPLAY-MAIN

; //  Buttons Customized for Applications  //
	if (InStr(ClassName, "Mozilla") or InStr(ClassName, "Opera")) 
	 	Browser_Forward::^Right
	
Debug(msg) 
{ 
   OutputDebug, %msg% 
   return 
} 

Mem2Hex( pointer, len ) 
{ 
	A_FI := A_FormatInteger 
	SetFormat, Integer, Hex 
	Loop, %len%  
	{ 
        Hex := *Pointer+0 
        StringReplace, Hex, Hex, 0x, 0x0 
        StringRight Hex, Hex, 2            
        hexDump := hexDump . hex
        Pointer ++ 
    } 
	SetFormat, Integer, %A_FI% 
	StringUpper, hexDump, hexDump 
	Return hexDump 
}


xpanta
  • Members
  • 5 posts
  • Last active: Dec 11 2011 10:38 AM
  • Joined: 16 Nov 2011
Hi, I am trying to use the script and I get this error message:

Warning: Local variable with same name as global.

Specifically: Res (in function InputMessage)

I use AutoHotKey_L and I haven't loaded the IntelliType Driver.

The script is not loaded (although problem is a Warning and not an Error)

Any ideas what am I doing wrong?

EDIT: Sorry, the script is actually loaded but the icon is not shown. I can tell this because I have remapped some keys to skip to next and previous media track and it works. However, zoom button is not responding

CircuitryMaker
  • Members
  • 89 posts
  • Last active: Jan 09 2012 10:56 AM
  • Joined: 28 Jan 2006
Very useful script. One thing to add:

0100000000010000 means that no key is pressed.

If you want to find out when Key <insert single key here> was released you have to write into a variable, which one was used. This can be quite annoying with many hotkeys. Can you add a workaround so you know which key was released in addition to no key being pressed.

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006
How can we find out those strings for the various labels?

Zoom down 
012E020000010000:


Philister
  • Members
  • 57 posts
  • Last active: Sep 27 2016 08:10 PM
  • Joined: 12 Feb 2012
@automaticman: You have to use the first script posted in this thread. Copy the code into an .ahk file and run it. Click on "Capture on" button and press the key you need. Click on "Capture off" and copy the information. Voila.

If anyone wants to script the F-Lock key, several changes need to be made as its status changes the messages sent by many of the other special keys. Here is what I use in my script:

; Zoom down
012E020000000000:
012E020000010000:
ScrollDir := 2
GoSub, DoScroll
SetTimer, DoScroll, 80
return

; Zoom up
012D020000000000:
012D020000010000:
ScrollDir := 1
GoSub, DoScroll
SetTimer, DoScroll, 80
return

; All up
0100000000000000:
0100000000010000:
ScrollDir := 0
SetTimer, DoScroll, Off
return

;numpad=
0100006700000000:
0100006700010000:
msgbox equal
return

;numpad(
010000B600000000:
010000B600010000:
msgbox (
return

;numpad)
010000B700000000:
010000B700010000:
msgbox )
return

; My Favorites
0182010000000000:
0182010000010000:
   MsgBox My Favorites Button
return
; Favorites 1
0100000000040000:
0100000000050000:
   MsgBox Favorites 1
return
; Favorites 2
0100000000080000:
0100000000090000:
   MsgBox Favorites 2
return
; Favorites 3
0100000000100000:
0100000000110000:
   MsgBox Favorites 3
return
; Favorites 4
0100000000200000:
0100000000210000:
   MsgBox Favorites 4
return
; Favorites 5
0100000000400000:
0100000000410000:
   MsgBox Favorites 5
return

; F-lock - message alternates with each press (shifted / not shifted)
0100000000020000:
0100000000030000:
	MsgBox F-lock
return

; F-keys when F-lock enabled
; F1
0195000000000000:
SendInput, {f1}
return
;F2
011A020000000000:
SendInput, {f2}
return
;F3
0179020000000000:
SendInput, {f3}
return
;F4
0101020000000000:
SendInput, {f4}
return
;F5
0102020000000000:
SendInput, {f5}
return
;F6
0103020000000000:
SendInput, {f6}
return
;F7
0189020000000000:
SendInput, {f7}
return
;F8
018B020000000000:
SendInput, {f8}
return
;F9
018C020000000000:
SendInput, {f9}
return
;F10
01AB010000000000:
SendInput, {f10}
return
;F11
0107020000000000:
SendInput, {f11}
return
;F12
0108020000000000:
SendInput, {f12}
return

Of course you could assign different actions to any of the keys with F-Lock enabled to get even more functionality out of your keyboard...

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006

@automaticman: You have to use the first script posted in this thread. Copy the code into an .ahk file and run it. Click on "Capture on" button and press the key you need. Click on "Capture off" and copy the information. Voila.

For a keyboard capture shows

AppendOutput("HND " . Handle . " KBD ScanCode " . ScanCode . " VKey " . VKey . " Msg " . Message . "`r`n")
Which one to use?