-
Notifications
You must be signed in to change notification settings - Fork 0
/
a.cpp
50 lines (39 loc) · 1 KB
/
a.cpp
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
#include <windows.h>
#include <stdio.h>
#define KEYEVENTF_UNICODE 0x0004
HWND hWndMain;
static void SendString(LPCTSTR str)
{
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;
for (LPCTSTR p=str; *p; p++) {
inp[0].ki.wVk = inp[1].ki.wVk = *p;
printf("send %d\n", inp[1].ki.wVk);
HWND currentWindow;
currentWindow = GetForegroundWindow();
SetForegroundWindow(hWndMain);
SendInput(1, inp, sizeof(INPUT));
Sleep(30);
SendInput(1, &inp[1], sizeof(INPUT));
SetForegroundWindow(currentWindow);
Sleep(1000);
}
}
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;
}
char *input = argv[1];
while (true) {
SendString(input);
}
return 0;
}