evilC / AutoHotInterception

An AutoHotkey wrapper for the Interception driver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disable touchpad laptop if at least one external mouse is existing

hsayed21 opened this issue · comments

My script for testing on Notepad

#SingleInstance force
#Persistent
#include ..\Lib\AutoHotInterception.ahk

AHI := new AutoHotInterception()
mousedId := AHI.GetMouseIdFromHandle("ACPI\VEN_SYN&DEV_2B96")

SetTimer, WatchWin, -0
return

; 0: Left Mouse
; 1: Right Mouse
; 2: Middle Mouse
; 3: Side Button 1
; 4: Side Button 2
; 5: Mouse Wheel (Vertical)
; 6: Mouse Wheel (Horizontal)

MouseButtonEvent(code, state){
	ToolTip % "Mouse Button - Code: " code ", State: " state	
}

DoSub(state){
	global AHI, mousedId
	if (state){
		AHI.SubscribeMouseButtons(mouseId, true, Func("MouseButtonEvent"))
	} else {
		AHI.UnsubscribeMouseButtons(mouseId)
	}
}

WatchWin:
	Loop {
		WinWaitActive, ahk_class Notepad
		DoSub(true)
		WinWaitNotActive, ahk_class Notepad
		DoSub(false)
	}
	return

^Esc::
	ExitApp

Error:

Error in #include file "d:\AutoHotInterception\Lib\AutoHotInterception.ahk":
     0x80004002 - No such interface supported

Specifically: SubscribeMouseButtons

	Line#
	184: {
	185: this.Instance.SubscribeMouseButton(id, btn, block, callback, concurrent)  
	186: }
	188: {
	189: this.Instance.UnsubscribeMouseButton(id, btn)  
	190: }
	192: {
--->	193: this.Instance.SubscribeMouseButtons(id, block, callback, concurrent)  
	194: }
	196: {
	197: this.Instance.UnsubscribeMouseButtons(id)  
	198: }
	200: {
	201: this.Instance.SubscribeMouseMove(id, block, callback, concurrent)  
	202: }

Continue running the script?Error in #include file "d:\AutoHotInterception\Lib\AutoHotInterception.ahk":
     0x80004002 - No such interface supported

Specifically: UnsubscribeMouseButtons

	Line#
	188: {
	189: this.Instance.UnsubscribeMouseButton(id, btn)  
	190: }
	192: {
	193: this.Instance.SubscribeMouseButtons(id, block, callback, concurrent)  
	194: }
	196: {
--->	197: this.Instance.UnsubscribeMouseButtons(id)  
	198: }
	200: {
	201: this.Instance.SubscribeMouseMove(id, block, callback, concurrent)  
	202: }
	204: {
	205: this.Instance.UnsubscribeMouseMove(id)  
	206: }

Continue running the script?

@evilC

Double-check that you are getting a value in mouseId
The "No such interface supported" error usually means you have an empty parameter

I simplified it to be Unsubscribe only but when clicking on buttons touchpad it clicks normal not disabled

#SingleInstance force
#Persistent
#include Lib\AutoHotInterception.ahk

AHI := new AutoHotInterception()
mouseId := AHI.GetMouseId(0x0000, 0x0000)
AHI.UnsubscribeMouseButtons(mouseId)
return

^Esc::
	ExitApp

image

I would not be surprised if mouseId := AHI.GetMouseId(0x0000, 0x0000) did not work (ie passing a VID and PID of 0).
The monitor is likely showing 0 for VID and PID because it cannot get them.
Use the handle instead: mouseId := AHI.GetDeviceIdFromHandle("ACPI\VEN_SYN&DEV_2B96")

This is after the change with handle, touchpad click also work
Animation