Oops, that would be because you don't have that file, sorry about that.
On my machine, I've separated the functions from the sample into a file named interception.ahk (i.e. I created a library from them) and since I'd forgotten that I'd done that, and the sample actually had the script & functions in the same file, I put that at the top thinking it was separate. Just remove the #include line and copy the functions into a file with the above code or do similar to what i did and create a library. The library I actually use follows:
Code: Select all
#Include <_Struct>
Global interception_dll_path := A_ScriptDir "\interception.dll" ; Path to interception.dll
get_keyname(o,ByRef name,ByRef state){
Critical
if Interception_Is_Keyboard(o.device)
{
state:=o.state
hex:=hex(o.code)
name:=GetKeyName("sc" hex)
;ToolTip % state "`n" name "`n" hex
if !name ;windows key
{
if hex=0x5b
name=LWin
if hex=0x5c
name=RWin
}
else if name in LControl,LAlt
{
if state=2
name:= "R" . SubStr(name,2, strlen(name))
if state=3
name:= "R" . SubStr(name,2, strlen(name))
}
else if name
{
if hex=0x53
{
if state in 0,1
name= NumpadDot
if state in 2,3
name=Delete
}
else if hex=0x36
name=RShift
else if (hex=0x2a) AND state=3
name:="PrintScreen", state:=1
else if (hex=0x37) AND state=2
name:="PrintScreen", state:=0
}
if state in 0,2 ;down
state:=1
else if state in 1,3 ;up
state:=0
}
else if Interception_Is_Mouse(o.device)
{
state:=o.state
if state in 1,2
name=LButton
else if state in 4,8
name=RButton
else if state in 16,32
name=MButton
else if state in 64,128
name=XButton1
else if state in 256,512
name=XButton2
else if state=1024
{
name=Wheel
if (o.rolling<0)
state:=1 ;down
else
state:=0 ;up
}
else if state = 2048
{
name=HWheel
if (o.rolling>0)
state:=1 ;right
else
state:=0 ;left
}
if state in 1,4,16,64,256 ;down
state:=1
if state in 2,8,32,128,512 ;up
state:=0
}
}
Interception_Send(context,device,stroke,nstroke)
{
Critical
res:=DllCall(interception_dll_path "\interception_send","Ptr",context,"int",device,"ptr",stroke[],"uint",nstroke,"Cdecl Int")
return res
}
Interception_Receive(context,device,ByRef key,ByRef mouse,nstroke)
{
Critical
if !isObject(key)
{
_key:="
(
ushort code;
ushort state;
uint information;
uint device;
)"
;varsetcapacity(key,12)
key:= new _Struct(_key)
}
if !isObject(mouse)
{
_mouse:="
(
ushort state;
ushort flags;
short rolling;
int x;
int y;
uint information;
uint device;
)"
;varsetcapacity(mouse,18)
mouse:= new _Struct(_mouse)
}
if Interception_Is_Keyboard(device)
{
res:=DllCall(interception_dll_path "\interception_receive","Ptr",context,"int",device,"ptr",key[""],"uint",nstroke,"Cdecl Int")
key.device:=device
}
else if Interception_Is_Mouse(device)
{
res:=DllCall(interception_dll_path "\interception_receive","Ptr",context,"int",device,"ptr",mouse[""],"uint",nstroke,"Cdecl Int")
mouse.device:=device
}
return res
}
Interception_Get_Hardware_ID(context,device){
Critical
VarSetCapacity(buffer,500)
if (a_ptrsize > 4)
DllCall(interception_dll_path "\interception_get_hardware_id","Ptr",context,"int",device,"str",buffer,"Uint",500,"Cdecl Int")
else if (a_ptrsize < 4)
DllCall(interception_dll_path "\interception_get_hardware_id","Ptr",context,"int",device,"ptr",&buffer,"Uint",500,"Cdecl Int")
return a_ptrsize > 4 ? buffer : StrGet(&buffer, "UTF-16")
}
Interception_Wait(context)
{
Critical
return DllCall(interception_dll_path "\interception_wait","Ptr",context,"Cdecl Int")
}
Interception_Set_Filter(context,filter,keys)
{
Static keyboard:="interception_is_keyboard"
,mouse:="interception_is_mouse"
,KEY_DOWN = 0x00
,KEY_UP = 0x01
,KEY_NONE = 0x0000
,KEY_ALL = 0xFFFF
,KEY_E0 = 0x02 ;Delete Key
,KEY_E1 = 0x04
,KEY_TERMSRV_SET_LED = 0x08
,KEY_TERMSRV_SHADOW = 0x10
,KEY_TERMSRV_VKPACKET = 0x20
,FILTER_KEY_NONE = 0x0000
,FILTER_KEY_ALL = 0xFFFF
,FILTER_KEY_DOWN := KEY_UP
,FILTER_KEY_UP := KEY_UP << 1
,FILTER_KEY_E0 := KEY_E0 << 1
,FILTER_KEY_E1 := KEY_E1 << 1
,FILTER_KEY_TERMSRV_SET_LED := KEY_TERMSRV_SET_LED << 1
,FILTER_KEY_TERMSRV_SHADOW := KEY_TERMSRV_SHADOW << 1
,FILTER_KEY_TERMSRV_VKPACKET := KEY_TERMSRV_VKPACKET << 1
,MOUSE_NONE = 0x0000
,MOUSE_ALL = 0xFFFF
,MOUSE_LEFT_BUTTON_DOWN = 0x001
,MOUSE_LEFT_BUTTON_UP = 0x002
,MOUSE_RIGHT_BUTTON_DOWN = 0x004
,MOUSE_RIGHT_BUTTON_UP = 0x008
,MOUSE_MIDDLE_BUTTON_DOWN= 0x010
,MOUSE_MIDDLE_BUTTON_UP = 0x020
,MOUSE_BUTTON_1_DOWN := MOUSE_LEFT_BUTTON_DOWN
,MOUSE_BUTTON_1_UP := MOUSE_LEFT_BUTTON_UP
,MOUSE_BUTTON_2_DOWN := MOUSE_RIGHT_BUTTON_DOWN
,MOUSE_BUTTON_2_UP := MOUSE_RIGHT_BUTTON_UP
,MOUSE_BUTTON_3_DOWN := MOUSE_MIDDLE_BUTTON_DOWN
,MOUSE_BUTTON_3_UP := MOUSE_MIDDLE_BUTTON_UP
,MOUSE_BUTTON_4_DOWN = 0x040
,MOUSE_BUTTON_4_UP = 0x080
,MOUSE_BUTTON_5_DOWN = 0x100
,MOUSE_BUTTON_5_UP = 0x200
,MOUSE_WHEEL = 0x400
,MOUSE_HWHEEL = 0x800
,MOUSE_MOVE = 0x1000
,MOUSE_MOVE_RELATIVE = 0x000
,MOUSE_MOVE_ABSOLUTE = 0x001
,MOUSE_VIRTUAL_DESKTOP = 0x002
,MOUSE_ATTRIBUTES_CHANGED = 0x004
,MOUSE_MOVE_NOCOALESCE = 0x008
,MOUSE_TERMSRV_SRC_SHADOW = 0x100
if Instr(keys,"|")
{
loop,parse,keys,|
{
key:=%a_loopfield%
if a_index=1
keys2:=key
else
keys2:=keys2|key
}
keys:=keys2
}
else
keys:=%keys%
f:=get_pointer(%filter%)
DllCall(interception_dll_path "\interception_set_filter","ptr",context,"ptr",f, "int",keys,"Cdecl Int")
}
Interception_Is_Mouse(device)
{
Critical
return DllCall(interception_dll_path "\interception_is_mouse","int",device)
}
Interception_Is_Keyboard(device)
{
Critical
return DllCall(interception_dll_path "\interception_is_keyboard","int",device)
}
get_pointer(func){
global dllh
return DllCall("GetProcAddress", ptr, dllh, "astr", func, ptr)
}
Interception_Create_Context()
{
return DllCall(interception_dll_path "\interception_create_context")
}
Interception_Destroy_Context(context)
{
return DllCall(interception_dll_path "\interception_destroy_context","ptr",context)
}
Interception_Load()
{
global dllh
dllh:=DllCall("LoadLibrary", "Str", interception_dll_path "", "Ptr")
}
hex(n){
SetFormat, IntegerFast, hex
n+= 0
n.= ""
SetFormat, IntegerFast, d
return n
}
Note: You'll possibly notice there are a couple of changes from the sample. There is an Interception_ prefixed to most the functions, if you use this as a library file, you will need to either add Interception_ to the beginning of the calling functions that use the relevant functions, or remove them from the library file. For info on Library files see AHK's help. And remember to update the variable "interception_dll_path" to point to the correct place on your hard drive if it isn't in the same folder as this file.