-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPreventAutoLock.cpp
More file actions
49 lines (42 loc) · 1.25 KB
/
Copy pathPreventAutoLock.cpp
File metadata and controls
49 lines (42 loc) · 1.25 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
// Ben Girone 2/26/19 benjamingirone@gmail.com
// Because the SendInput function is only supported in
// Windows 2000 and later, WINVER needs to be set as
// follows so that SendInput gets defined when windows.h
// is included below.
#pragma comment(linker, "/SUBSYSTEM:WINDOWS")
#define WINVER 0x0500
#include <windows.h>
void pressKey(char keyCode)
{
// This structure will be used to create the keyboard
// input event.
INPUT ip;
// Set up a generic keyboard event.
ip.type = INPUT_KEYBOARD;
ip.ki.wScan = 0; // hardware scan code for key
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
// Press the key
ip.ki.wVk = keyCode; // virtual-key code for the key
ip.ki.dwFlags = 0; // 0 for key press
SendInput(1, &ip, sizeof(INPUT));
// Release the key
ip.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release
SendInput(1, &ip, sizeof(INPUT));
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// Loop infinitely
while(true)
{
// Call key press
pressKey(0x90);
pressKey(0x90);
Sleep(59000);
}
// Exit normally
return 0;
}