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;
|
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)
|
private void SetThreadState(bool state)
|
||||||
{
|
{
|
||||||
if (state)
|
if (state)
|
||||||
|
@ -14,7 +14,8 @@ class TestApp
|
|||||||
var iw = new InterceptionWrapper();
|
var iw = new InterceptionWrapper();
|
||||||
var str = iw.GetDeviceList();
|
var str = iw.GetDeviceList();
|
||||||
// 0x2D = X key
|
// 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);
|
Console.WriteLine("Subscription Value: " + value);
|
||||||
//}), 0x413C, 0x2107);
|
//}), 0x413C, 0x2107);
|
||||||
|
@ -11,32 +11,48 @@ if (!devices){
|
|||||||
msgbox Device List Check failed
|
msgbox Device List Check failed
|
||||||
ExitApp
|
ExitApp
|
||||||
}
|
}
|
||||||
|
keyboardId := Interception.GetDeviceId(VID, PID)
|
||||||
|
if (keyboardId == 0){
|
||||||
|
MsgBox % "Could not find keyboard with VID " VID " PID " PID
|
||||||
|
ExitApp
|
||||||
|
}
|
||||||
;~ clipboard := devices
|
;~ clipboard := devices
|
||||||
;~ MsgBox % devices
|
;~ MsgBox % devices
|
||||||
|
|
||||||
result := Interception.SetContextCallback(VID, PID, Func("SetKb1Context"))
|
result := Interception.SubscribeKey(GetKeySC("2"), true, Func("KeyEvent"), VID, PID)
|
||||||
if (result != -1){
|
if (result != -1){
|
||||||
msgbox Subscribe failed
|
msgbox Subscribe failed
|
||||||
ExitApp
|
ExitApp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result := Interception.SetContextCallback(VID, PID, Func("SetKb1Context"))
|
||||||
|
if (result != -1){
|
||||||
|
msgbox Context request failed
|
||||||
|
ExitApp
|
||||||
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
|
KeyEvent(state){
|
||||||
|
static ctrlCode := GetKeySC("Ctrl")
|
||||||
|
global keyboardId
|
||||||
|
Interception.SendKeyEvent(ctrlCode, state, keyboardId)
|
||||||
|
;~ ToolTip % "State: " state
|
||||||
|
}
|
||||||
|
|
||||||
SetKb1Context(state){
|
SetKb1Context(state){
|
||||||
global isKeyboard1Active
|
global isKeyboard1Active
|
||||||
Sleep 0 ; We seem to need this for hotstrings to work, not sure why
|
Sleep 0 ; We seem to need this for hotstrings to work, not sure why
|
||||||
isKeyboard1Active := state
|
isKeyboard1Active := state
|
||||||
}
|
}
|
||||||
#if isKeyboard1Active
|
#if isKeyboard1Active
|
||||||
1::ctrl
|
::aaa::JACKPOT
|
||||||
;~ ::aaa::JACKPOT
|
1::
|
||||||
;~ 1::
|
ToolTip % "KEY DOWN EVENT @ " A_TickCount
|
||||||
;~ ToolTip % "KEY DOWN EVENT @ " A_TickCount
|
return
|
||||||
;~ return
|
|
||||||
|
|
||||||
;~ 1 up::
|
1 up::
|
||||||
;~ ToolTip % "KEY UP EVENT @ " A_TickCount
|
ToolTip % "KEY UP EVENT @ " A_TickCount
|
||||||
;~ return
|
return
|
||||||
#if
|
#if
|
||||||
|
|
||||||
^Esc::
|
^Esc::
|
Loading…
Reference in New Issue
Block a user