From d30d2bf46264b14b8147688e67316b931dc97127 Mon Sep 17 00:00:00 2001 From: Clive Galway Date: Wed, 28 Mar 2018 21:10:29 +0100 Subject: [PATCH 1/2] Update README.md --- README.md | 55 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 7e87369..c686a11 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,15 @@ If this all scares you and you don't really understand it, then TL/DR is you sho 4. Edit the example script, enter the VID and PID of your keyboard 5. Run the example script +# Device IDs / VIDs PIDs etc +Interception identifies unique devices by an ID. This is a number from 1..21. +Devices 1-10 are always keyboards +Devices 11-21 are always mice +This ID scheme is totally unique to Interception, and IDs may change as you plug / unplug devices etc. +On PC, devices are often identified by VendorID (VID) and ProductID (PID). These are identifiers baked into the hardware at time of manufacture, and are identical for all devices of the same make / model. +Most AHI functions (eg to Subscribe to a key etc) use an ID, so some handy functions are provided to allow you to find the (current) Interception ID of your device, given a VID / PID. +If you are unsure of what the VID / PID of your device is (or even if Interception can see it), you can use the included Monitor script to find it. + # Usage ## Initializing the Library Include the library @@ -34,8 +43,25 @@ Include the library Initialize the library ``` -Interception := AutoHotInterception_Init() +InterceptionWrapper := new AutoHotInterception() +global Interception := InterceptionWrapper.GetInstance() ``` +`Interception` is an instance of the C# class - Most of the time, you will want to directly call the functions in the DLL using this object. +`InterceptionWrapper` is an AHK class that makes it easy to interact with the `Interception` object. For example, it wraps `GetDeviceList()` to make it return a normal AHK array. Most of the time you will not need it. + +## Finding Device IDs +For most of your scripts, once you know the VID/PID of your device, you just need to find out what it's ID is for that run of the script. +To do so, call `Interception.GetDeviceId(, , )` +Where `isMouse` is `true` if you wish to find a mouse, or `false` if you wish to find a keyboard. +eg `Interception.GetDeviceId(false, 0x04F2, 0x0112)` to find a keyboard with VID 0x04F2 and PID 0x0112 + +If you wish to get a list of all available devices, you can call `InterceptionWrapper.GetDeviceList()`, which will return an array of `DeviceInfo` objects, each of which has the following properties: +``` +Id +isMouse +Vid +Pid +``` ## Modes There are two modes of operation for AHI, and both can be used simultaneously. @@ -57,8 +83,8 @@ AHI then fires the callback once more, passing `0` and the context variable gets #### Step 1 Register your callback with AHI ``` -VID := 0x04F2, PID := 0x0112 -Interception.SetContextCallback(VID, PID, Func("SetKb1Context")) +keyboard1Id := Interception.GetDeviceId(false, 0x04F2, 0x0112) +Interception.SetContextCallback(keyboard1Id, Func("SetKb1Context")) ``` #### Step 2 @@ -94,10 +120,9 @@ Subscription Mode overrides Context Mode - that is, if a key on a keyboard has b #### Keyboard Subscribe to a key on a specific keyboard -`SubscribeKey(, , , , )` +`SubscribeKey(, , , )` ``` -VID := 0x04F2, PID := 0x0112 -Interception.SubscribeKey(GetKeySC("1"), true, Func("KeyEvent"), VID, PID) +Interception.SubscribeKey(keyboardId, GetKeySC("1"), true, Func("KeyEvent")) return ``` @@ -109,7 +134,7 @@ KeyEvent(state){ ``` #### Mouse Buttons -`SubscribeMouseButton(