Windows10 VS2017 C++模拟点击按键


#include "pch.h"
#include <Windows.h>
#include <stdio.h>
#include <iostream> using namespace std; int main()
{
Sleep(3000); system("start notepad"); Sleep(3000); // 模拟点击右键
//mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
//mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); // 模拟按下'A'键
for (int i = 0; i < 100; i++)
{
keybd_event('A', 0, 0, 0);
keybd_event('A', 0, KEYEVENTF_KEYUP, 0);
} // 模拟按下 CTRL + S
keybd_event(VK_CONTROL, (BYTE)0, 0, 0);
keybd_event('S', (BYTE)0, 0, 0); keybd_event('S', (BYTE)0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL, (BYTE)0, KEYEVENTF_KEYUP, 0); cout << "Input over, press any key to exit." << endl; getchar();
return 0;
}

参考文章:

https://blog.csdn.net/dxk539687357/article/details/69668936/

上一篇:SQL Server 当表分区遇上唯一约束(转载)


下一篇:windows 常用操作