Keyboard detection - twice Raw output problem

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
MIRKOSOFT
Posts: 334
Joined: 23 Sep 2014, 14:29

Keyboard detection - twice Raw output problem

05 Aug 2018, 08:38

Hi!

I'm using part of script for keyboard betection between keyboard and numeric pad.
Here's code:

Code: Select all

KeyChk:

#NoEnv
SetBatchLines -1

OnMessage(0xFF, "InputHandler")
RegisterRawInputDevices(1, 6)

InputHandler(wParam, lParam) {
    static RID_INPUT        := 0x10000003
    static RIDI_DEVICENAME  := 0x20000007

    Critical

    DllCall("GetRawInputData"
        , "Ptr",    lParam
        , "UInt",   RID_INPUT
        , "Ptr",    0
        , "UIntP",  size
        , "UInt",   8 + A_PtrSize * 2)
    VarSetCapacity(buffer, size)
    DllCall("GetRawInputData"
        , "Ptr",    lParam
        , "UInt",   RID_INPUT
        , "Ptr",    &buffer
        , "UIntP",  size
        , "UInt",   8 + A_PtrSize * 2)

    devHandle := NumGet(buffer, 8)
    vk := NumGet(buffer, 8 + 2 * A_PtrSize + 6, "UShort")

    DllCall("GetRawInputDeviceInfo"
        , "Ptr",    devHandle
        , "UInt",   RIDI_DEVICENAME
        , "Ptr",    0
        , "UIntP",  size)
    VarSetCapacity(info, size)
    DllCall("GetRawInputDeviceInfo"
        , "Ptr",    devHandle
        , "UInt",   RIDI_DEVICENAME
        , "Ptr",    &info
        , "UIntP",  size)
    GotInfo := StrGet(&info)
    StringMid, GotID, GotInfo, 13 , 3
    if GotID =1A2
	{
	KB =Inland
	}
     Else if GotID =1C4
	{
	KB =Keypad
	}
     Else if GotID =05A
	{
	KB =Wireless
	}
     Else if GotID =04F
	{
	KB =Japanese
	}
     Else if GotID =13B
	{
	KB =Dell PS/2
	}
     Else if GotID =030
	{
	KB =Adesso
	}
     Else
	{
	KB = %GotInfo%
	}
;ToolTip % "`keyboard:`t"   KB
;        . "`nscancode vk:`t"     vk
;	. "`npressed:`t`t"    A_TickCount
}
return
When is keyboard detected I'm using this code:

Code: Select all

If KB =Keypad
	{
	if vk =8	; Keypad Backspace sc00e
		{
		Send, {LCtrl Down}{z 1}{LCtrl Up}
		Send, {Raw}*
		return
		}
	Else if vk =9	; Keypad Tabulator sc00f
		{
		Gosub, Tabulator
		return
		}
	Else if vk =235	; Keypad NumLock sc045 (remapped to NoConvert vkEBsc07B)
		{
		Send, {Raw}e
		return
		}
	}
If KB =Adesso
	{
	if vk =8	; Keyboard Backspace sc00e
		{
		;Send, {sc00e 1)
		return
		}
	Else if vk =9	; Keyboard Tabulator sc00f
		{
		return
		}
	Else if vk =235	;  Keyboard NumLock sc045 (remapped to NoConvert vkEBsc07B)
		{
		Send, {Raw}¢
		return
		}
	}
At this part NumLock remapped to Japanese NoConvert sends raw output twice:
KeyPad:

Code: Select all

	Else if vk =235	; Keypad NumLock sc045 (remapped to NoConvert vkEBsc07B)
		{
		Send, {Raw}e
		return
		}
Keyboard:

Code: Select all

	Else if vk =235	;  Keyboard NumLock sc045 (remapped to NoConvert vkEBsc07B)
		{
		Send, {Raw}¢
		return
		}
How to fix it to have output e instead ee and ¢ instead ¢¢ ?

These keys are no handled in whole script, only in code above.

Thank you for each help, reply or comment.
Miro
burque505
Posts: 1733
Joined: 22 Jan 2017, 19:37

Re: Keyboard detection - twice Raw output problem

13 Aug 2018, 17:38

Hi, I'm shooting in the dark here - Since it's limited to those sections, have you tried something like

Code: Select all

	Else if vk =235	;  Keyboard NumLock sc045 (remapped to NoConvert vkEBsc07B)
		{
		Send, {Blind}{Raw}¢
		return
		}
or any of the other 'Send' modes ({Text}, etc.) for this limited section of code?
Sorry if this isn't helpful, I have no way to test this on my system.
Regards,
burque505
MIRKOSOFT
Posts: 334
Joined: 23 Sep 2014, 14:29

Re: Keyboard detection - twice Raw output problem

14 Aug 2018, 22:22

So, I tested blind mode, but behavior is not changed - always two character output.
Miro
MIRKOSOFT
Posts: 334
Joined: 23 Sep 2014, 14:29

Re: Keyboard detection - twice Raw output problem

15 Aug 2018, 08:35

Thank you, I'll explorer both in your signature.

Thank you very much - looks perfect and very helpful to present and future.

Miro

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, mcd, Nerafius, RandomBoy, Rohwedder and 110 guests