directx 游戏模拟键盘输入
生活随笔
收集整理的這篇文章主要介紹了
directx 游戏模拟键盘输入
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一個小demo:
#include <windows.h> #include <stdio.h>int main() {printf("等待10秒...\n");Sleep(10000);printf("開始模擬按鍵\n");SHORT key;UINT mappedkey;INPUT input = { 0 };key = VkKeyScan('w');mappedkey = MapVirtualKey(LOBYTE(key), 0);input.type = INPUT_KEYBOARD;input.ki.dwFlags = KEYEVENTF_SCANCODE;input.ki.wScan = mappedkey;SendInput(1, &input, sizeof(input));Sleep(1000); // 按下1秒input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;SendInput(1, &input, sizeof(input));return 0; }總結
以上是生活随笔為你收集整理的directx 游戏模拟键盘输入的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用 detours 框架 hook 函
- 下一篇: 【攻防世界020】easyRE1