Repository navigation
Expand file tree
/
Copy pathctrlv.c
More file actions
60 lines (51 loc) · 1.59 KB
/
Copy pathctrlv.c
File metadata and controls
60 lines (51 loc) · 1.59 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
#define WINVER 0x0500
#include <windows.h>
INPUT ip;
HHOOK hHock = NULL;
KBDLLHOOKSTRUCT kbdstruct;
LRESULT CALLBACK MyLowLevelHook ( int nCode , WPARAM wParam , LPARAM lParam)
{
if(nCode >= 0)
{
if(wParam == WM_KEYDOWN && GetAsyncKeyState(VK_CONTROL))
{
kbdstruct = *((KBDLLHOOKSTRUCT *)lParam);
if(kbdstruct.vkCode == VK_F3)
{
ip.ki.wVk = VK_CONTROL;
ip.ki.dwFlags = 0; // 0 for key press
SendInput(1, &ip, sizeof(INPUT));
// Press the "V" key
ip.ki.wVk = 'V';
ip.ki.dwFlags = 0; // 0 for key press
SendInput(1, &ip, sizeof(INPUT));
// Release the "V" key
ip.ki.wVk = 'V';
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
// Release the "Ctrl" key
ip.ki.wVk = VK_CONTROL;
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
printf("_a_");
}
}
}
return CallNextHookEx(hHock , nCode ,wParam , lParam);
}
int main()
{
// Create a generic keyboard event structure
ip.type = INPUT_KEYBOARD;
ip.ki.wScan = 0;
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
MSG msg;
hHock = SetWindowsHookEx(WH_KEYBOARD_LL, MyLowLevelHook , NULL,NULL);
while(!GetMessage(&msg, NULL, NULL, NULL)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
UnhookWindowsHookEx(hHock);
return 0;
}