Skip to content

Commit 3289553

Browse files
authored
Merge pull request #3 from Chaoses-Ib/develop
v0.3
2 parents 9f8e68d + 658206f commit 3289553

31 files changed

Lines changed: 1150 additions & 538 deletions

AhkDll.Ahk/v1/IbAhkSend.ahk

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
; IbAhkSendLib (v1)
22
; Description: Enable AHK to send keystrokes by drivers.
33
; Author: Chaoses Ib
4-
; Version: 0.2
4+
; Version: 0.3
55
; Git: https://github.com/Chaoses-Ib/IbAhkSendLib
66

77
IbSendInit(send_type := "AnyDriver", mode := 1, args*){
88
workding_dir := A_WorkingDir
99
SetWorkingDir, %A_ScriptDir%
1010

11-
static hModule := DllCall("LoadLibrary", "Str", "IbAhkSend.dll", "Ptr")
11+
static hModule := DllCall("LoadLibrary", "Str", A_ScriptDir "\IbAhkSend.dll", "Ptr")
1212
if (hModule == 0){
1313
if (A_PtrSize == 4)
1414
throw "SendLibLoadFailed: Please use AutoHotkey x64"
@@ -19,16 +19,18 @@ IbSendInit(send_type := "AnyDriver", mode := 1, args*){
1919
}
2020

2121
if (send_type == "AnyDriver")
22-
result := DllCall("IbAhkSend\IbAhkSendInit", "Int", 0, "Int", 0, "Ptr", 0, "Int")
22+
result := DllCall("IbAhkSend\IbSendInit", "Int", 0, "Int", 0, "Ptr", 0, "Int")
2323
else if (send_type == "SendInput")
24-
result := DllCall("IbAhkSend\IbAhkSendInit", "Int", 1, "Int", 0, "Ptr", 0, "Int")
24+
result := DllCall("IbAhkSend\IbSendInit", "Int", 1, "Int", 0, "Ptr", 0, "Int")
2525
else if (send_type == "Logitech")
26-
result := DllCall("IbAhkSend\IbAhkSendInit", "Int", 2, "Int", 0, "Ptr", 0, "Int")
26+
result := DllCall("IbAhkSend\IbSendInit", "Int", 2, "Int", 0, "Ptr", 0, "Int")
27+
else if (send_type == "Razer")
28+
result := DllCall("IbAhkSend\IbSendInit", "Int", 3, "Int", 0, "Ptr", 0, "Int")
2729
else if (send_type == "DD"){
2830
if (args.MaxIndex() == 1)
29-
result := DllCall("IbAhkSend\IbAhkSendInit", "Int", 3, "Int", 0, "WStr", args[1], "Int")
31+
result := DllCall("IbAhkSend\IbSendInit", "Int", 4, "Int", 0, "WStr", args[1], "Int")
3032
else
31-
result := DllCall("IbAhkSend\IbAhkSendInit", "Int", 3, "Int", 0, "Ptr", 0, "Int")
33+
result := DllCall("IbAhkSend\IbSendInit", "Int", 4, "Int", 0, "Ptr", 0, "Int")
3234
} else
3335
throw "Invalid send type"
3436

@@ -47,28 +49,28 @@ IbSendInit(send_type := "AnyDriver", mode := 1, args*){
4749
IbSendMode(mode){
4850
static ahk_mode := ""
4951
if (mode == 1){
50-
DllCall("IbAhkSend\IbAhkSendInputHook", "Int", 1)
52+
DllCall("IbAhkSend\IbSendInputHook", "Int", 1)
5153
ahk_mode := A_SendMode
5254
SendMode Input
5355
} else if (mode == 0){
5456
SendMode %ahk_mode%
55-
DllCall("IbAhkSend\IbAhkSendInputHook", "Int", 0)
57+
DllCall("IbAhkSend\IbSendInputHook", "Int", 0)
5658
} else {
5759
throw "Invalid send mode"
5860
}
5961
}
6062

6163
IbSendDestroy(){
62-
DllCall("IbAhkSend\IbAhkSendDestroy")
64+
DllCall("IbAhkSend\IbSendDestroy")
6365
;DllCall("FreeLibrary", "Ptr", hModule)
6466
}
6567

6668
IbSyncKeyStates(){
67-
DllCall("IbAhkSend\IbAhkSendSyncKeyStates")
69+
DllCall("IbAhkSend\IbSendSyncKeyStates")
6870
}
6971

7072
IbSend(keys){
71-
DllCall("IbAhkSend\IbAhkSendInputHook", "Int", 1) ;or IbSendMode(1)
73+
DllCall("IbAhkSend\IbSendInputHook", "Int", 1) ;or IbSendMode(1)
7274
SendInput %keys%
73-
DllCall("IbAhkSend\IbAhkSendInputHook", "Int", 0) ;or IbSendMode(0)
75+
DllCall("IbAhkSend\IbSendInputHook", "Int", 0) ;or IbSendMode(0)
7476
}

AhkDll.Ahk/v1/test/KeyHistory.ahk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
#InstallMouseHook
33
KeyHistory
44

5+
; If a key is sent by the driver, it should not have an "i" in the Type field.
6+
57
F4::ExitApp

AhkDll.Ahk/v1/test/mode 0.ahk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
; Mode 0 (v1)
22
; Run Notepad, type "Hello world!" and then select all text by mouse.
33

4+
#Include %A_ScriptDir%
45
#Include ..\IbAhkSend.ahk
56

67
IbSendInit("AnyDriver", 0)
@@ -10,7 +11,7 @@ WinWaitActive, ahk_class #32770
1011
IbSend("notepad`n")
1112

1213
WinWaitActive, ahk_exe notepad.exe
13-
IbSend("Hello world+1")
14+
IbSend("Hello world{!}")
1415
Sleep 100
1516
CoordMode, Mouse, Client
1617
IbSend("{Click 5, 5, down}{click 150, 50, up}")

AhkDll.Ahk/v1/test/mode 1.ahk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
; Mode 1 (v1)
22
; Run Notepad, type "Hello world!" and then select all text by mouse.
33

4+
#Include %A_ScriptDir%
45
#Include ..\IbAhkSend.ahk
56

67
IbSendInit()
@@ -10,7 +11,7 @@ WinWaitActive, ahk_class #32770
1011
Send notepad`n
1112

1213
WinWaitActive, ahk_exe notepad.exe
13-
Send Hello world+1
14+
Send Hello world{!}
1415
Sleep 100
1516
CoordMode, Mouse, Client
1617
MouseClickDrag, Left, 5, 5, 150, 50

AhkDll.Ahk/v1/test/mode ahk.ahk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ WinWaitActive, ahk_class #32770
55
Send notepad`n
66

77
WinWaitActive, ahk_exe notepad.exe
8-
Send Hello world+1
8+
Send Hello world{!}
99
Sleep 100
1010
CoordMode, Mouse, Client
1111
MouseClickDrag, Left, 5, 5, 150, 50

AhkDll.Ahk/v1/test/type DD.ahk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#Include %A_ScriptDir%
12
#Include ..\IbAhkSend.ahk
23
IbSendInit("DD") ;or IbSendInit("DD", 1, "C:\SomeDir\DD64.dll")
34
#include mode ahk.ahk
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#Include %A_ScriptDir%
12
#Include ..\IbAhkSend.ahk
23
IbSendInit("Logitech")
34
#include mode ahk.ahk

AhkDll.Ahk/v1/test/type Razer.ahk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Include %A_ScriptDir%
2+
#Include ..\IbAhkSend.ahk
3+
IbSendInit("Razer")
4+
#include mode ahk.ahk
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#Include %A_ScriptDir%
12
#Include ..\IbAhkSend.ahk
23
IbSendInit("SendInput")
34
#include mode ahk.ahk

AhkDll.Ahk/v2/IbAhkSend.ahk

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; IbAhkSendLib
22
; Description: Enable AHK to send keystrokes by drivers.
33
; Author: Chaoses Ib
4-
; Version: 0.2
4+
; Version: 0.3
55
; Git: https://github.com/Chaoses-Ib/IbAhkSendLib
66

77
#DllLoad "*i IbAhkSend.dll" ;DllCall("LoadLibrary") cannot locate DLL correctly
@@ -19,16 +19,18 @@ IbSendInit(send_type := "AnyDriver", mode := 1, args*){
1919
}
2020

2121
if (send_type == "AnyDriver")
22-
result := DllCall("IbAhkSend\IbAhkSendInit", "Int", 0, "Int", 0, "Ptr", 0, "Int")
22+
result := DllCall("IbAhkSend\IbSendInit", "Int", 0, "Int", 0, "Ptr", 0, "Int")
2323
else if (send_type == "SendInput")
24-
result := DllCall("IbAhkSend\IbAhkSendInit", "Int", 1, "Int", 0, "Ptr", 0, "Int")
24+
result := DllCall("IbAhkSend\IbSendInit", "Int", 1, "Int", 0, "Ptr", 0, "Int")
2525
else if (send_type == "Logitech")
26-
result := DllCall("IbAhkSend\IbAhkSendInit", "Int", 2, "Int", 0, "Ptr", 0, "Int")
26+
result := DllCall("IbAhkSend\IbSendInit", "Int", 2, "Int", 0, "Ptr", 0, "Int")
27+
else if (send_type == "Razer")
28+
result := DllCall("IbAhkSend\IbSendInit", "Int", 3, "Int", 0, "Ptr", 0, "Int")
2729
else if (send_type == "DD"){
2830
if (args.Length == 1)
29-
result := DllCall("IbAhkSend\IbAhkSendInit", "Int", 3, "Int", 0, "WStr", args[1], "Int")
31+
result := DllCall("IbAhkSend\IbSendInit", "Int", 4, "Int", 0, "WStr", args[1], "Int")
3032
else
31-
result := DllCall("IbAhkSend\IbAhkSendInit", "Int", 3, "Int", 0, "Ptr", 0, "Int")
33+
result := DllCall("IbAhkSend\IbSendInit", "Int", 4, "Int", 0, "Ptr", 0, "Int")
3234
} else
3335
throw "Invalid send type"
3436

@@ -55,30 +57,30 @@ IbSendInit(send_type := "AnyDriver", mode := 1, args*){
5557
IbSendMode(mode){
5658
static ahk_mode := ""
5759
if (mode == 1){
58-
DllCall("IbAhkSend\IbAhkSendInputHook", "Int", 1)
60+
DllCall("IbAhkSend\IbSendInputHook", "Int", 1)
5961
ahk_mode := A_SendMode
6062
SendMode("Input")
6163
} else if (mode == 0){
6264
SendMode(ahk_mode)
63-
DllCall("IbAhkSend\IbAhkSendInputHook", "Int", 0)
65+
DllCall("IbAhkSend\IbSendInputHook", "Int", 0)
6466
} else {
6567
throw "Invalid send mode"
6668
}
6769
}
6870

6971
IbSendDestroy(){
70-
DllCall("IbAhkSend\IbAhkSendDestroy")
72+
DllCall("IbAhkSend\IbSendDestroy")
7173
;DllCall("FreeLibrary", "Ptr", hModule)
7274
}
7375

7476
IbSyncKeyStates(){
75-
DllCall("IbAhkSend\IbAhkSendSyncKeyStates")
77+
DllCall("IbAhkSend\IbSendSyncKeyStates")
7678
}
7779

7880
IbSend(keys){
79-
DllCall("IbAhkSend\IbAhkSendInputHook", "Int", 1) ;or IbSendMode(1)
81+
DllCall("IbAhkSend\IbSendInputHook", "Int", 1) ;or IbSendMode(1)
8082
SendInput(keys)
81-
DllCall("IbAhkSend\IbAhkSendInputHook", "Int", 0) ;or IbSendMode(0)
83+
DllCall("IbAhkSend\IbSendInputHook", "Int", 0) ;or IbSendMode(0)
8284
}
8385

8486
IbClick(args*){

0 commit comments

Comments
 (0)