help with usb keyboard

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
ositoMalvado
Posts: 183
Joined: 24 Dec 2019, 12:02
Contact:

help with usb keyboard

Post by ositoMalvado » 26 Nov 2022, 17:52

Hello guys, I have a Mechanical Keyboard usb connected to my laptop, sometime i have to put mech-keyboard over the laptop keyboard, so there are some random presses under the mech-keyboard... how can i disable only laptop keyboard, and use usb keyboard without lap-key presses.

i wanna something like this

Code: Select all

if usb_keyboard()==true
	Blockinput, LaptopKeyBoardSend ; any like this?
My WEB some useful stuff

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: help with usb keyboard

Post by mikeyww » 26 Nov 2022, 18:24


User avatar
ositoMalvado
Posts: 183
Joined: 24 Dec 2019, 12:02
Contact:

Re: help with usb keyboard

Post by ositoMalvado » 27 Nov 2022, 09:02

mikeyww wrote:
26 Nov 2022, 18:24
Possibly: viewtopic.php?f=6&t=45307
Thanks, reading and trying.

Code: Select all


#SingleInstance force
#Persistent
#include Lib\AutoHotInterception.ahk
#NoTrayIcon
global AHI := new AutoHotInterception()
SetTimer, loopfunc, 500 ;i will use all the time from the windows start
Return
KeyEvent(code, state){
}

loopfunc(){
	keyid:=""
	keyid:= AHI.GetKeyboardId(0x258A, 0x0049) ;usb keyboard's id, i get it with Monitor.ahk
	if (keyid!=""){
		keyboardId := AHI.GetKeyboardId(0x0000, 0x0000,2) ;laptop keyboard's id, 3rd parameter is 1 by default, i make it work putting 2 as instance
		AHI.SubscribeKeyboard(keyboardId, true, Func("KeyEvent")) ;assign all keys to do nothing (Y) so now can i put my usb keyboard over laptop keyboard
	}
}


^esc::
	ExitApp ;if i need something from laptop keyboard :v

My WEB some useful stuff

User avatar
ositoMalvado
Posts: 183
Joined: 24 Dec 2019, 12:02
Contact:

Re: help with usb keyboard

Post by ositoMalvado » 27 Nov 2022, 15:31

ositoMalvado wrote:
27 Nov 2022, 09:02
mikeyww wrote:
26 Nov 2022, 18:24
Possibly: viewtopic.php?f=6&t=45307
Thanks, reading and trying.

Code: Select all


#SingleInstance force
#Persistent
#include Lib\AutoHotInterception.ahk
#NoTrayIcon
global AHI := new AutoHotInterception()
SetTimer, loopfunc, 500 ;i will use all the time from the windows start
Return
KeyEvent(code, state){
}

loopfunc(){
	keyid:=""
	keyid:= AHI.GetKeyboardId(0x258A, 0x0049) ;usb keyboard's id, i get it with Monitor.ahk
	if (keyid!=""){
		keyboardId := AHI.GetKeyboardId(0x0000, 0x0000,2) ;laptop keyboard's id, 3rd parameter is 1 by default, i make it work putting 2 as instance
		AHI.SubscribeKeyboard(keyboardId, true, Func("KeyEvent")) ;assign all keys to do nothing (Y) so now can i put my usb keyboard over laptop keyboard
	}
}


^esc::
	ExitApp ;if i need something from laptop keyboard :v

I did this and i bug all usb devices.... only touchpad works, to fix it i did next:

run as admin cmd.exe
cd "anywhere\Interception\command line installer"
install-interception.exe /uninstall

then restart pc, and it will be restored



fixed code:::

Code: Select all

#NoTrayIcon
#SingleInstance force
#Persistent
#include Lib\AutoHotInterception.ahk
;#NoTrayIcon
global AHI := new AutoHotInterception()
global LAPTOP_KEY_ID:=AHI.GetKeyboardId(0x0000, 0x0000,2)
Return


KeyEvent(code, state){

}

^#esc::
	escto:=!escto
	if escto
		AHI.SubscribeKeyboard(LAPTOP_KEY_ID, true, Func("KeyEvent"))
	else
		AHI.UnsubscribeKeyboard(LAPTOP_KEY_ID, true, Func("KeyEvent"))

My WEB some useful stuff

Post Reply

Return to “Ask for Help (v1)”