我正在嘗試使用SendInput()
函數。我寫了這個代碼:無法找到SendInput()函數使用的任何數據類型。
#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);
編譯:
gcc -Wall -o window.exe win32.c -lWs2_32
我得到:
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)
我不知道如何解決tihis。根據documentation它在 Winuser.h
標題中聲明。但不適合我。任何幫助非常感謝。提前致謝。
您可以檢查頭文件,如果這些結構已經在一些宏下聲明瞭,在這種情況下,您將不得不通過命令行使用'-D'選項來傳遞宏定義,或者在源代碼中明確定義它。 –
謝謝!我會嘗試一下。 – Jack