-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfish.cpp
More file actions
101 lines (81 loc) · 1.9 KB
/
Copy pathfish.cpp
File metadata and controls
101 lines (81 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <windows.h>
#include <stdio.h>
#define KEYEVENTF_UNICODE 0x0004
HWND hWndMain;
HWND hWndSave;
static void SendVK(char vk)
{
hWndSave = GetForegroundWindow();
SetForegroundWindow(hWndMain);
INPUT inp[2];
memset(inp,0,sizeof(INPUT));
inp[0].type = INPUT_KEYBOARD;
inp[0].ki.dwFlags = 0;
inp[1] = inp[0];
inp[1].ki.dwFlags |= KEYEVENTF_KEYUP;
inp[0].ki.wVk = inp[1].ki.wVk = vk;
inp[0].ki.wScan = inp[1].ki.wScan = 0;
printf("vk %d\n", vk);
SendInput(1, inp, sizeof(INPUT));
Sleep(40);
SendInput(1, &inp[1], sizeof(INPUT));
Sleep(40);
SetForegroundWindow(hWndSave);
}
static void SendScan(char vk)
{
INPUT inp[2];
memset(inp,0,sizeof(INPUT));
inp[0].type = INPUT_KEYBOARD;
inp[0].ki.dwFlags = KEYEVENTF_UNICODE;
inp[1] = inp[0];
inp[1].ki.dwFlags |= KEYEVENTF_KEYUP;
inp[0].ki.wVk = inp[1].ki.wVk = 0;
inp[0].ki.wScan = inp[1].ki.wScan = vk;
printf("uc %d\n", vk);
SendInput(2, inp, sizeof(INPUT));
}
static void SendString(LPCTSTR str)
{
SendVK(13);
for (LPCTSTR p=str; *p; p++) {
SendScan(*p);
}
Sleep(50);
SendVK(13);
Sleep(1000);
}
static void sleeper(int n) {
for (int i=0;i<n;i++) {
printf("%d\n",i);
Sleep(1000);
}
printf("\n");
}
int main(int argc,char **argv)
{
hWndMain = FindWindow(0, "FINAL FANTASY XIV: A Realm Reborn");
if(hWndMain == NULL)
{
printf("Main window not found, terminating\n");
return -1;
}
SetForegroundWindow(hWndMain);
Sleep(2000);
int delay1 = 15;
int delay2 = 12;
if (argc > 1) {
delay1 = atoi(argv[1]);
}
if (argc > 2) {
delay2 = atoi(argv[2]);
}
printf("%d %d\n",delay1,delay2);
while (true) {
SendVK('2');
sleeper(delay1);
SendVK('3');
sleeper(delay2);
}
return 0;
}