Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable touchpad laptop if at least one external mouse is existing #95

Open
hsayed21 opened this issue Nov 17, 2022 · 4 comments
Open

Comments

@hsayed21
Copy link

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

@evilC
Copy link
Owner

evilC commented Mar 21, 2023

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

@hsayed21
Copy link
Author

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

@evilC
Copy link
Owner

evilC commented Mar 28, 2023

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")

@hsayed21
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants