Page 1 of 1

Keyboard detection - twice Raw output problem

Posted: 05 Aug 2018, 08:38
by MIRKOSOFT
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

Re: Keyboard detection - twice Raw output problem

Posted: 09 Aug 2018, 18:02
by MIRKOSOFT
No idea?

Miro

Re: Keyboard detection - twice Raw output problem

Posted: 13 Aug 2018, 17:24
by MIRKOSOFT
Any help?
Miro

Re: Keyboard detection - twice Raw output problem

Posted: 13 Aug 2018, 17:38
by burque505
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

Re: Keyboard detection - twice Raw output problem

Posted: 14 Aug 2018, 22:22
by MIRKOSOFT
So, I tested blind mode, but behavior is not changed - always two character output.
Miro

Re: Keyboard detection - twice Raw output problem

Posted: 15 Aug 2018, 04:57
by evilC
If you want to remap multiple keyboards at a scancode level, independently of each other, then you probably want AutoHotInterception (see signature)

Re: Keyboard detection - twice Raw output problem

Posted: 15 Aug 2018, 08:35
by MIRKOSOFT
Thank you, I'll explorer both in your signature.

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

Miro

Re: Keyboard detection - twice Raw output problem

Posted: 15 Aug 2018, 11:42
by evilC
FYI, by the sounds of it, "Subscription Mode" is what you want in AHI, not "Context Mode".