AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

Post your working scripts, libraries and tools for AHK v1.1 and older
serzh82saratov
Posts: 137
Joined: 01 Jul 2017, 03:04

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

11 Jul 2018, 05:23

In what topic?
Sorry, I'm using an translator, no speak english. I mean AutoHotInterception generally.
including the instance itself.
I mean unload dll.
autohotkey_anon
Posts: 1
Joined: 26 Sep 2018, 12:55

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

26 Sep 2018, 13:47

Hello, I'm new in programming in general and I need to map a mouse device to be used like a joystick or mapped to a keyboard button.

What I want:
I want to use a bluetooth mouse to work as a joystick or to emulate key presses using the delta from the mouse.

I want to use this as a controller for a game (GzDoom) that support joysticks or keyboard for movement. Because I also have a giroscopic mouse for the aiming I need to block the signal from the mouse movement on the system so I can use both mices one for movement and one for aiming.
I don't want to configure the giroscopic mouse because it's working fine for aiming.


THE HARDWARE
the hardware I have is this:
https://www.amazon.in/VR-Case-Bluetooth ... B01GMDAD1Y
This is a bluetooth controller for an android device, most of it's buttons are connected to some keys that are not mapped to normal keys:
- rewind
- fast-forward
- volume up / volume down
- home
- something else I don't remember (Tap me thinks).

Now some of it's buttons are not even recognized by windows, so i can't use the buttons for mapping to the directional keys on the keyboard, which is what I tried first (only 2 of them are functional the others are not even being recognized as keys when I try to detect the key codes).
this device also have a mouse function that works when pressing at the same time the @ button and the power button, and it's detected by the system as a mouse device.

It can emulate pure axis movement, meaning that if I move the stick in one direction only the delta on that direction changes, so it's easy to use as a joystick or a mouse. it also doesn't have a VID/ PID number so It's have been only recognized by it's handler.

THE PROBLEM
I have found EvilC Warper for Interception and I have managed to program a script to map the delta to keys, it works but I don't know how to program the return to 0 on the delta of the mouse, so it stops moving when I stop pressing the handle.

I have tried using UCR to map the mouse delta to a vjoy device with the plugin that comes with this program. This works, but it have problems:
When I configure the device to work with both axis X,Y one of the axis never work (one of the axis can only move to max or min and stays there, but the other works)
If I configure the device to use a single axis the plugin works as intended. I have tried using different profiles for each axis but this present the same problem. one of the profiles works fine an the other always have max/min values.

I have also tried with the old version of UCR, now this works fine, in fact it works very well, but I couldn't find a way to disable the mouse movement. I don't know if it's even possible to do it with the old UCR.

this is the new UCR log:
Spoiler
If possible I would want to use UCR for doing this because of it's funcionality or if it's not possible then how can I program the stop from the mouse on interception, I have seen a script that evilC write on AHK for mouse to keys movement on an old thread on the forums of AHK, but is not using interception, I have tried to program something on interception but I can't conceptualize how is gonna listen to an event that doesn't exists and needs to be created by AHK.

this is my script:
Spoiler

If this can't be solved then I will try to buy another "bluetooth joystick" and try to not get scammed by the sellers again...
beepboop
Posts: 2
Joined: 29 Oct 2018, 23:27

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

29 Oct 2018, 23:41

With AHI, is it possible to run a script only when a button specific is released? What about when a button is initially pressed?

My context:
I want to use a 2nd keyboard as a smart medication box - I will remove almost all the keys, stick a flat surface onto each remaining key, and place my medication boxes on these surfaces. That way, when I take my meds, I remove the medication from the board, which updates a database. Same for when they're returned onto the board (which makes sure I haven't taken the box but forgotten to take the meds). I used Taran's system, but holding a key basically ran the intercept script many times per second - both visually annoying (cmd running repeatedly) and inefficient. Does AHI have the capacity to handle this problem?
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

30 Oct 2018, 05:13

Yes it is possible to do this, but it sounds like that is not actually what you want.
Running a new AHK script on each press or release of each key is not the way to go in this instance.
You want one AHK script which reacts to keys in the same way that the sample AHI scripts do.
If a key is held and is repeating, then simply filter out the repeats.

Here is an example of repeat suppression:

Code: Select all

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

AHI := new AutoHotInterception()

keyboardId := AHI.GetKeyboardId(0x04F2, 0x0112)
AHI.SubscribeKey(keyboardId, GetKeySC("1"), true, Func("KeyEvent"))
return

KeyEvent(state){
	; Start repeat suppression
	static lastState :- 0
	if (state == lastState)
		return
	lastState := state
	; End repeat suppression
	ToolTip % "State: " state
}

^Esc::
	ExitApp
Revvilo
Posts: 6
Joined: 17 Nov 2015, 00:30

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

30 Nov 2018, 23:52

I've been messing around trying to subscribe the tilde key, but can't for the life of me work out what to use for the callback. Since "`" can't be used as a function name and the scancode doesn't seem to want to work. Any way I can do this?

Well oof. That's gonna be a big 'my bad' on that one. I made a function that automatically subscribes keys that are in an array and completely forgot you defined the callback yourself. Disregard this.
UV-Virt
Posts: 5
Joined: 20 Dec 2018, 11:49

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

20 Dec 2018, 13:51

It seems like I completely fail to find any devices.
GetDeviceList() gives me nothing and Monitor.ahk shows an empty GUI.
I am on Win 7.

Can someone help?
Thanks.
UV-Virt
Posts: 5
Joined: 20 Dec 2018, 11:49

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

20 Dec 2018, 18:25

Ah ye, I didn't unblock these dlls (unblocked wrong one actually) Sorry, my fault.
Anyway, now I would like to use it, only thing I wanna do is being able to block/unblock mouse movement for one old game.
What is the easiest way to do that?

I tried this and it doesn't work.

Code: Select all

#Persistent
#include Lib\AutoHotInterception.ahk

AHI := new AutoHotInterception()
global Interception := AHI.GetInstance()
mouseId := Interception.GetMouseId(0x0458,0x003A)

~f::
Interception.SubscribeMouseMove(mouseID, true, Func("MouseEvent"))
return
It gave me an error: "Can not implicitly convert type Void to object"

My understanding of this is very low (I am new to AHK) so I guess that I am doing something very wrong here, advice would be very helpful.
Thanks
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

21 Dec 2018, 12:41

I would copy the examples that come with it, I don't know why you are calling methods directly on the C# instance, when it is intended for you to be calling the methods on the AHK wrapper (AHI).
ie mouseId := Interception.GetMouseId(0x0458,0x003A) should probably be mouseId := AHI.GetMouseId(0x0458,0x003A)

Per-app mappings is only supported in Context mode, which does not support mouse movement.
In order to do what you want, you would have to either:
Subscribe / Unsubscribe as the app became active / inactive
or
When the app is inactive, use AHI.SendMouseMove to forward on the movement.

Either way, as the notes say, be careful, I advise having a 2nd mouse handy ;)
UV-Virt
Posts: 5
Joined: 20 Dec 2018, 11:49

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

23 Dec 2018, 14:03

Ok, I made this simple testing script but still getting the same error: "Can not implicitly convert type Void to object"

Code: Select all

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

AHI := new AutoHotInterception()
mouseId := AHI.GetMouseId(0x0458,0x003A)
AHI.SubscribeMouseMove(mouseID, true, Func("MouseEvent"))

MouseEvent(x,y){
	ToolTip % "TEST"
}
UV-Virt
Posts: 5
Joined: 20 Dec 2018, 11:49

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

24 Dec 2018, 19:28

Ye, it works now. Thanks.
Btw, could you please clarify how to unsubscribe?
UV-Virt
Posts: 5
Joined: 20 Dec 2018, 11:49

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

25 Dec 2018, 05:35

Oh and another thing: Why does it block mouse buttons as well? I thought it is supposed to block only movement, no?

EDIT: Nevermind I've found a solution if I use:

Code: Select all

AHI.SubscribeMouseMoveRelative(mouseID, true, Func("MouseEvent"))
AHI.SubscribeMouseButton(mouseID, 0, false, Func("MouseEvent"))
It blocks the movement but allows to use mouse buttons, but is there some "better" way?
Optical
Posts: 5
Joined: 30 Dec 2018, 04:05

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

30 Dec 2018, 04:29

hello. I am russian. Try to configure AutoHotInterception. But it not working.

My Steps in virtual machine Win7 x64:
1) install AHK AutoHotkey_1.1.30.01_setup.exe. x86 verion.
2) Download Interception and install it. | https://github.com/oblitum/Interception/releases/
interception_1.jpg
interception_1.jpg (48.53 KiB) Viewed 6464 times
3) Reboot
4) Download AutoHotInterception, copy Interception.dll to lib folder and Check unlock in DLL files: | https://github.com/evilC/AutoHotInterception/releases
interception_2.jpg
interception_2.jpg (5.73 KiB) Viewed 6464 times
5)run Monitor.ahk
interception_3.jpg
interception_3.jpg (20.18 KiB) Viewed 6464 times
I am always get this error - Check Failed. Try it on Win7(x64) and Win XP(x86).

What is not correct?

I just need to send keyboard keys like this https://www.autohotkey.com/boards/viewtopic.php?t=27007. Can AutoHotInterception to help with this?
Optical
Posts: 5
Joined: 30 Dec 2018, 04:05

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

30 Dec 2018, 17:01

evilC wrote:
30 Dec 2018, 09:44
Did you run unblocker.ps1 as admin?
I think that powershell is too old in my winrtual machine with Win7 and have not command Unblock-File:
ObjectNotFound: (Unblock-File:String) [], CommandNotFoundException

Win XP have not powershell.

What environment is necessary to use AutoHotInterception? Win 7 ... ?
User avatar
evilC
Posts: 4822
Joined: 27 Feb 2014, 12:30

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

30 Dec 2018, 19:07

I am not sure WinXp even had download protection....
https://docs.microsoft.com/en-us/dotnet ... windows-xp
WinXp supports up to .NET 4.0.3, I think AHI uses like 4.2 or something, so I would imagine it is not compatible with WinXP

Regarding Win7, as the dialog says, the other way to unblock is to right-click the DLLs and select properties. If it is blocked, you will be able to unblock it from that dialog.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 78 guests