mirror of
https://github.com/evilC/AutoHotInterception.git
synced 2024-11-12 13:10:47 +00:00
Implements SendKeyEvent
This commit is contained in:
parent
4e5dc009b4
commit
7592b2ec30
@ -73,6 +73,14 @@ public class InterceptionWrapper
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SendKeyEvent(int key, int state, int device = 1)
|
||||
{
|
||||
var stroke = new Stroke();
|
||||
stroke.key.code = (ushort)key;
|
||||
stroke.key.state = (ushort)(1 - state);
|
||||
Send(_deviceContext, device, ref stroke, 1);
|
||||
}
|
||||
|
||||
private void SetThreadState(bool state)
|
||||
{
|
||||
if (state)
|
||||
|
@ -14,7 +14,8 @@ class TestApp
|
||||
var iw = new InterceptionWrapper();
|
||||
var str = iw.GetDeviceList();
|
||||
// 0x2D = X key
|
||||
iw.SubscribeKey(0x2D, true, new Action<int>((value) =>
|
||||
//iw.SubscribeKey(0x2D, true, new Action<int>((value) =>
|
||||
iw.SubscribeKey(2, true, new Action<int>((value) =>
|
||||
{
|
||||
Console.WriteLine("Subscription Value: " + value);
|
||||
//}), 0x413C, 0x2107);
|
||||
|
@ -11,32 +11,48 @@ if (!devices){
|
||||
msgbox Device List Check failed
|
||||
ExitApp
|
||||
}
|
||||
|
||||
keyboardId := Interception.GetDeviceId(VID, PID)
|
||||
if (keyboardId == 0){
|
||||
MsgBox % "Could not find keyboard with VID " VID " PID " PID
|
||||
ExitApp
|
||||
}
|
||||
;~ clipboard := devices
|
||||
;~ MsgBox % devices
|
||||
|
||||
result := Interception.SetContextCallback(VID, PID, Func("SetKb1Context"))
|
||||
result := Interception.SubscribeKey(GetKeySC("2"), true, Func("KeyEvent"), VID, PID)
|
||||
if (result != -1){
|
||||
msgbox Subscribe failed
|
||||
ExitApp
|
||||
}
|
||||
|
||||
result := Interception.SetContextCallback(VID, PID, Func("SetKb1Context"))
|
||||
if (result != -1){
|
||||
msgbox Context request failed
|
||||
ExitApp
|
||||
}
|
||||
return
|
||||
|
||||
KeyEvent(state){
|
||||
static ctrlCode := GetKeySC("Ctrl")
|
||||
global keyboardId
|
||||
Interception.SendKeyEvent(ctrlCode, state, keyboardId)
|
||||
;~ ToolTip % "State: " state
|
||||
}
|
||||
|
||||
SetKb1Context(state){
|
||||
global isKeyboard1Active
|
||||
Sleep 0 ; We seem to need this for hotstrings to work, not sure why
|
||||
isKeyboard1Active := state
|
||||
}
|
||||
#if isKeyboard1Active
|
||||
1::ctrl
|
||||
;~ ::aaa::JACKPOT
|
||||
;~ 1::
|
||||
;~ ToolTip % "KEY DOWN EVENT @ " A_TickCount
|
||||
;~ return
|
||||
::aaa::JACKPOT
|
||||
1::
|
||||
ToolTip % "KEY DOWN EVENT @ " A_TickCount
|
||||
return
|
||||
|
||||
;~ 1 up::
|
||||
;~ ToolTip % "KEY UP EVENT @ " A_TickCount
|
||||
;~ return
|
||||
1 up::
|
||||
ToolTip % "KEY UP EVENT @ " A_TickCount
|
||||
return
|
||||
#if
|
||||
|
||||
^Esc::
|
Loading…
Reference in New Issue
Block a user