Code: Select all
#Include <_Struct>
#SingleInstance force
#NoEnv
Process, Priority, , H
SetBatchLines, -1
ListLines Off
#KeyHistory 0
SendMode Input
SetTitleMatchMode 2
SetTitleMatchMode Fast
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetWinDelay, 0 ; Changed to 0 upon recommendation of documentation
SetControlDelay, 0 ; Changed to 0 upon recommendation of documentation
SetDefaultMouseSpeed, 0
SendMode Input
triggerdelay=15
triggerlength=60
load()
context:=create_context()
set_filter(context, "keyboard","KEY_ALL")
loop,5 ;everything but MOUSE_MOVE
;mouse_filter.="MOUSE_BUTTON_" a_index "_DOWN|MOUSE_BUTTON_" a_index "_UP|"
set_filter(context, "mouse", mouse_filter "MOUSE_ALL")
while ( receive(context,device:=wait(context),key,mouse,1) >0 )
{
critical
if is_keyboard(device)
{
get_keyname(key,name,state)
if name=F12
break
send(context,device,key,1)
}
else if is_mouse(device)
{
get_keyname(mouse,name,state)
;ToolTip % "device: " device "`nname:" name "`nstate:" state "`nid:" hardware_id
if (device > 11)
{
if name=LButton
{
if (state=1)
{
if (device = 13 || device = 14|| device = 15)
{
flasher = a
trigger = b
}
if (device = 12 || device = 16|| device = 17)
{
flasher = k
trigger = o
}
send %flasher%
sleep(triggerdelay)
mouse.state := 2
send(context,device,mouse,1)
Send, {%trigger% down}
sleep(triggerlength)
Send, {%trigger% up}
}
}
if name=RButton
{
if (state = 1)
{
if (device = 13 || device = 14|| device = 15)
buttonA = d
if (device = 12 || device = 16|| device = 17)
buttonA = q
send, {%buttonA% down}
sleep(triggerlength)
send, {%buttonA% up}
;mouse.state := 8
;send(context,device,mouse,1)
;send(context,device,mouse,0)
}
}
if name=MButton
{
if (state = 1)
{
if (device = 13 || device = 14|| device = 15)
buttonB = 1
if (device = 12 || device = 16|| device = 17)
buttonB = 2
send, {%buttonB% down}
sleep(triggerlength)
send, {%buttonB% up}
;mouse.state := 0x020
;send(context,device,mouse,1)
;send(context,device,mouse,0)
}
}
}
else
send(context,device,mouse,1)
}
}
destroy_context(context)
return
get_keyname(o,ByRef name,ByRef state){
Critical
if is_keyboard(o.device)
{
state:=o.state
name:=GetKeyName("sc" hex(o.code))
hex:=hex(o.code)
;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 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
}
if state in 1,4,16,64,256 ;down
state:=1
if state in 2,8,32,128,512 ;up
state:=0
}
}
send_keys(device,ByRef stroke,keys*){
global
for every, key in keys
{
stroke.code:=GetKeySC(key)
send(context,device,stroke,1)
}
}
send(context,device,stroke,nstroke){
global
Critical
res:=DllCall(dll . "\interception_send","Ptr",context,"int",device,"ptr",stroke[],"uint",nstroke,"Cdecl Int")
return res
}
receive(context,device,ByRef key,ByRef mouse,nstroke){
global dll
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 is_keyboard(device)
{
res:=DllCall(dll . "\interception_receive","Ptr",context,"int",device,"ptr",key[""],"uint",nstroke,"Cdecl Int")
key.device:=device
}
else if is_mouse(device)
{
res:=DllCall(dll . "\interception_receive","Ptr",context,"int",device,"ptr",mouse[""],"uint",nstroke,"Cdecl Int")
mouse.device:=device
}
return res
}
get_hardware_id(context,device){
global dll
Critical
VarSetCapacity(buffer,500)
if (a_ptrsize > 4)
DllCall(dll . "\interception_get_hardware_id","Ptr",context,"int",device,"str",buffer,"Uint",500,"Cdecl Int")
else if (a_ptrsize < 4)
DllCall(dll . "\interception_get_hardware_id","Ptr",context,"int",device,"ptr",&buffer,"Uint",500,"Cdecl Int")
return a_ptrsize > 4 ? buffer : StrGet(&buffer, "UTF-16")
}
wait(context){
global
Critical
return DllCall(dll . "\interception_wait","Ptr",context,"Cdecl Int")
}
set_filter(context,filter,keys){
global dll
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(dll . "\interception_set_filter","ptr",context,"ptr",f, "int",keys,"Cdecl Int")
}
is_mouse(device){
global
Critical
return DllCall(dll . "\interception_is_mouse","int",device)
}
is_keyboard(device){
global
Critical
return DllCall(dll . "\interception_is_keyboard","int",device)
}
get_pointer(func){
global
return DllCall("GetProcAddress", ptr, dllh, "astr", func, ptr)
}
create_context(){
global
return DllCall(dll . "\interception_create_context")
}
destroy_context(context){
global
return DllCall(dll . "\interception_destroy_context","ptr",context)
}
load(){
global
dll:="interception.dll"
dllh:=DllCall("LoadLibrary", "Str", dll, "Ptr")
}
hex(n){
SetFormat, IntegerFast, hex
n+= 0
n.= ""
SetFormat, IntegerFast, d
return n
}
dec(n){
SetFormat, Integer, D
Dec := (n) + 0
return Dec
}
key2dec(name){
hex:=GetKeySC(name)
return dec(hex)
}
Issue2: I tested with only MOUSE_BUTTON_1_UP|MOUSE_MOVE, the script worked but same results.
I think "Issue3" is not the problem, as when the flash is launched at its timing, the shoot gets correctly positioned. I tried MOUSE_MOVE_ABSOLUTE but the script didnt work with this.
Si I will go for solution for Issue1, but I'm a bit lost, can you give some example or reference, please? and many thanks for your help!