I'm trying to use SendInput() function. I wrote this code:
#include <stdio.h> #include <stdlib.h> #include <windows.h> #include <winuser.h> #define WIN32_LEAN_AND_MEAN //... KEYBDINPUT kbi; kbi.wVk = 0x31; kbi.wScan = 0; kbi.dwFlags = 0; kbi.time = 0; INPUT input; input.type = INPUT_KEYBOARD; input.ki = kbi; SendInput(1, &input, sizeof input); Compiling:
gcc -Wall -o window.exe win32.c -lWs2_32
I get:
win32.c: In function ‘main’: win32.c:13:2: error: ‘KEYBDINPUT’ undeclared (first use in this function) win32.c:13:2: note: each undeclared identifier is reported only once for each function it appears in win32.c:13:13: error: expected ‘;’ before ‘kbi’ win32.c:14:2: error: ‘kbi’ undeclared (first use in this function) win32.c:20:2: error: ‘INPUT’ undeclared (first use in this function) win32.c:20:8: error: expected ‘;’ before ‘input’ win32.c:21:2: error: ‘input’ undeclared (first use in this function) win32.c:21:15: error: ‘INPUT_KEYBOARD’ undeclared (first use in this function) I have no idea how to fix tihis. According the documentation it's declared in Winuser.h header. But don't works for me.
-Doption or explicitly define it in your source