Skip to content

Commit 6f49a0a

Browse files
committed
Add project files.
1 parent 06de18d commit 6f49a0a

28 files changed

Lines changed: 1710 additions & 0 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
##
44
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
55

6+
*.dll
7+
68
# User-specific files
79
*.rsuser
810
*.suo

AhkDll.Ahk/v1/IbAhkSend.ahk

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
; IbAhkSendLib (v1)
2+
; Description: Enable AHK to send keystrokes by drivers.
3+
; Author: Chaoses Ib
4+
; Version: 210815
5+
; Git: https://github.com/Chaoses-Ib/IbAhkSendLib
6+
7+
IbSendInit(mode := 0){
8+
static hModule := DllCall("LoadLibrary", "Str", A_ScriptDir "\IbAhkSend.dll", "Ptr")
9+
if (hModule == 0){
10+
if (A_PtrSize == 4)
11+
throw "LibLoadingFailed: Please use AutoHotkey x64"
12+
else if (!FileExist(A_ScriptDir "\IbAhkSend.dll"))
13+
throw "LibLoadingFailed: Please put IbAhkSend.dll with your script file (or use AHK v2 instead, which can locate those DLLs that are put with the library files)"
14+
else
15+
throw "LibLoadingFailed"
16+
}
17+
18+
result := DllCall("IbAhkSend\IbAhkSendInit", "Int")
19+
if (result != 0){
20+
error_text := ["DeviceNotFound", "DeviceOpeningFailed", "LogiSettingsNotFound"]
21+
throw error_text[result - 1]
22+
}
23+
24+
if (mode != 0){
25+
IbSendMode(mode)
26+
}
27+
}
28+
29+
IbSendMode(mode){
30+
static ahk_mode := ""
31+
if (mode == 1){
32+
DllCall("IbAhkSend\IbAhkSendInputHookBegin")
33+
ahk_mode := A_SendMode
34+
SendMode Input
35+
} else if (mode == 0){
36+
SendMode %ahk_mode%
37+
DllCall("IbAhkSend\IbAhkSendInputHookEnd")
38+
} else {
39+
throw "Invalid argument"
40+
}
41+
}
42+
43+
IbSendDestroy(){
44+
DllCall("IbAhkSend\IbAhkSendDestroy")
45+
;DllCall("FreeLibrary", "Ptr", hModule)
46+
}
47+
48+
49+
IbSend(keys){
50+
DllCall("IbAhkSend\IbAhkSendInputHookBegin") ;or IbSendMode(1)
51+
SendInput %keys%
52+
DllCall("IbAhkSend\IbAhkSendInputHookEnd") ;or IbSendMode(0)
53+
}

AhkDll.Ahk/v1/test/KeyHistory.ahk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#InstallKeybdHook
2+
#InstallMouseHook
3+
KeyHistory
4+
5+
F4::ExitApp

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; Mode 0 (v1)
2+
; Run Notepad, type "Hello world!" and then select all text by mouse.
3+
4+
#Include ..\IbAhkSend.ahk
5+
6+
IbSendInit()
7+
8+
IbSend("#r")
9+
WinWaitActive, ahk_class #32770
10+
IbSend("notepad`n")
11+
12+
WinWaitActive, ahk_exe notepad.exe
13+
IbSend("Hello world+1")
14+
Sleep 100
15+
CoordMode, Mouse, Client
16+
IbSend("{Click 5, 5, down}{click 150, 50, up}")

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; Mode 1 (v1)
2+
; Run Notepad, type "Hello world!" and then select all text by mouse.
3+
4+
#Include ..\IbAhkSend.ahk
5+
6+
IbSendInit(1)
7+
; or:
8+
;IbSendInit()
9+
;IbSendMode(1)
10+
11+
Send #r
12+
WinWaitActive, ahk_class #32770
13+
Send notepad`n
14+
15+
WinWaitActive, ahk_exe notepad.exe
16+
Send Hello world+1
17+
Sleep 100
18+
CoordMode, Mouse, Client
19+
MouseClickDrag, Left, 5, 5, 150, 50

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; Run Notepad, type "Hello world!" and then select all text by mouse.
2+
3+
Send #r
4+
WinWaitActive, ahk_class #32770
5+
Send notepad`n
6+
7+
WinWaitActive, ahk_exe notepad.exe
8+
Send Hello world+1
9+
MouseClickDrag, Left, 0, 0, 150, 50

AhkDll.Ahk/v2/IbAhkSend.ahk

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
; IbAhkSendLib
2+
; Description: Enable AHK to send keystrokes by drivers.
3+
; Author: Chaoses Ib
4+
; Version: 210815
5+
; Git: https://github.com/Chaoses-Ib/IbAhkSendLib
6+
7+
#DllLoad "*i IbAhkSend.dll" ;DllCall("LoadLibrary") cannot locate DLL correctly
8+
9+
IbSendInit(mode := 0){
10+
static hModule := DllCall("GetModuleHandle", "Str", "IbAhkSend.dll", "Ptr")
11+
if (hModule == 0){
12+
if (A_PtrSize == 4)
13+
throw "LibLoadingFailed: Please use AutoHotkey x64"
14+
else
15+
throw "LibLoadingFailed"
16+
}
17+
18+
result := DllCall("IbAhkSend\IbAhkSendInit", "Int")
19+
if (result != 0){
20+
error_text := [
21+
"DeviceNotFound",
22+
"DeviceOpeningFailed",
23+
"LogiSettingsNotFound"
24+
]
25+
throw error_text[result - 1]
26+
}
27+
28+
if (mode != 0){
29+
IbSendMode(mode)
30+
}
31+
}
32+
33+
IbSendMode(mode){
34+
static ahk_mode := ""
35+
if (mode == 1){
36+
DllCall("IbAhkSend\IbAhkSendInputHookBegin")
37+
ahk_mode := A_SendMode
38+
SendMode("Input")
39+
} else if (mode == 0){
40+
SendMode(ahk_mode)
41+
DllCall("IbAhkSend\IbAhkSendInputHookEnd")
42+
} else {
43+
throw "Invalid argument"
44+
}
45+
}
46+
47+
IbSendDestroy(){
48+
DllCall("IbAhkSend\IbAhkSendDestroy")
49+
;DllCall("FreeLibrary", "Ptr", hModule)
50+
}
51+
52+
53+
IbSend(keys){
54+
DllCall("IbAhkSend\IbAhkSendInputHookBegin") ;or IbSendMode(1)
55+
SendInput(keys)
56+
DllCall("IbAhkSend\IbAhkSendInputHookEnd") ;or IbSendMode(0)
57+
}
58+
59+
IbClick(args*){
60+
IbSendMode(1)
61+
Click(args*)
62+
IbSendMode(0)
63+
}
64+
65+
IbMouseMove(args*){
66+
IbSendMode(1)
67+
MouseMove(args*)
68+
IbSendMode(0)
69+
}
70+
71+
IbMouseClick(args*){
72+
IbSendMode(1)
73+
MouseClick(args*)
74+
IbSendMode(0)
75+
}
76+
77+
IbMouseClickDrag(args*){
78+
IbSendMode(1)
79+
MouseClickDrag(args*)
80+
IbSendMode(0)
81+
}

AhkDll.Ahk/v2/test/KeyHistory.ahk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#InstallKeybdHook
2+
#InstallMouseHook
3+
KeyHistory()
4+
5+
F4::ExitApp()

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; Mode 0
2+
; Run Notepad, type "Hello world!" and then select all text by mouse.
3+
4+
#Include "..\IbAhkSend.ahk"
5+
6+
IbSendInit()
7+
8+
IbSend("#r")
9+
WinWaitActive("ahk_class #32770")
10+
IbSend("notepad`n")
11+
12+
WinWaitActive("ahk_exe notepad.exe")
13+
IbSend("Hello world+1")
14+
Sleep 100
15+
IbMouseClickDrag("Left", 5, 5, 150, 50)

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; Mode 1
2+
; Run Notepad, type "Hello world!" and then select all text by mouse.
3+
4+
#Include "..\IbAhkSend.ahk"
5+
6+
IbSendInit(1)
7+
; or:
8+
;IbSendInit()
9+
;IbSendMode(1)
10+
11+
Send("#r")
12+
WinWaitActive("ahk_class #32770")
13+
Send("notepad`n")
14+
15+
WinWaitActive("ahk_exe notepad.exe")
16+
Send("Hello world+1")
17+
Sleep 100
18+
MouseClickDrag("Left", 5, 5, 150, 50)

0 commit comments

Comments
 (0)