gpt4 book ai didi

c++ - 在 Windows 8.1 中模拟按键

转载 作者:行者123 更新时间:2023-11-28 00:15:48 24 4
gpt4 key购买 nike

我一直在尝试制作一个垃圾左键点击程序,因为我的 friend 挑战我在 10 秒内点击次数比他多。

这是我的代码:

#include <stdio.h>
#include <iostream>
#include <Windows.h>

using namespace std;

bool should_click = false;
char in;

int main()
{

INPUT ip;

ip.type = INPUT_MOUSE;
ip.ki.wScan = 0x01; //code for left click ^.^
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;

while (!should_click)
{
cin >> in;
if (in == 'g')
should_click = true;
}
while (should_click)
{
// Press the key
ip.ki.wVk = 0x01; // virtual-key code for mouse left click
ip.ki.dwFlags = 0; // 0 for key press
SendInput(1, &ip, sizeof(INPUT));

// Release the key
ip.ki.dwFlags = MOUSEEVENTF_LEFTUP; // KEYEVENTF_KEYUP for key release
SendInput(1, &ip, sizeof(INPUT));

Sleep(100);
}

return 0;

}

当我启动该程序并按 g 时,Windows 逐渐变黑,然后进入我的屏幕保护程序,然后每 100 毫秒返回一次桌面。我试过只模拟按键一次,结果也一样(只有一次)。

有解决办法吗?

PS:不,我无法在 10 秒内击败 96 次点击
PPS:我设法做到了。但我仍然想知道一种解决方法来制作一般的垃圾邮件发送者。

最佳答案

SendInput()可用于实现恶意软件。这就是为什么,ars 在 MSDN 上评论说,它受制于 UIPI。 .所以你只能通过以管理权限运行来摆脱这种奇怪的行为。

编辑:这个 MSDN article有一个关于 UIPI 的部分以及如何赋予应用程序绕过它的权利。它不仅涉及以管理员身份运行代码,还涉及在可执行文件的 list 中设置 UIAccess 属性,并使用有效证书签署代码。

关于c++ - 在 Windows 8.1 中模拟按键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30415176/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com