- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试做一个在游戏打开时自动按下按键的机器人。在记事本中这个程序运行良好,但在 Metin2 中它什么也不做。你有什么想法,有什么问题吗?
int main()
{
clock_t start = clock();
clock_t start_grab = clock();
HWND handle = NULL;
handle = FindWindow(0, "PandoraMT2.pl");
if (handle != 0)cout << "well";
for (int i = 0; i < i + 1; ++i)
{
handle = GetActiveWindow();
// SendMessage(handle, WM_CHAR, VK_SPACE, 0);
if ((clock() - start) / (double)CLOCKS_PER_SEC == 1)
{
keybd_event(VK_SPACE, 0, 0 , 0);
keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0);
start = clock();
}
if ((clock() - start_grab) / (double)CLOCKS_PER_SEC == 6)
{
keybd_event(VkKeyScan('Z'), 0, 0, 0);
keybd_event(VkKeyScan('Z'), 0, KEYEVENTF_KEYUP, 0);
start_grab = clock();
}
}
最佳答案
游戏的键状态/鼠标状态可能不依赖于 Windows 消息队列。例如Windows 中的两个可能的选择是:
GetKeyState
或
GetAsyncKeyState
https://msdn.microsoft.com/en-us/library/windows/desktop/ms646301(v=vs.85).aspx
来自 GetKeyState:
The key status returned from this function changes as a thread reads key messages from its message queue. The status does not reflect the interrupt-level state associated with the hardware. Use the GetAsyncKeyState function to retrieve that information.
因此,GetKeyState 是根据消息队列中发生的情况来读取状态,而 GetAsyncKeyState 是直接读取硬件中断(无论物理键是按下还是按下,包括鼠标键)。消息队列支持输入缓冲,例如队列中的键可能会滞后。出于这个原因,许多游戏开发者可能更喜欢将 GetAsyncKeyState 用于实时游戏,并且这些游戏不会收到您的假按键事件。
关于c++ - AutoclickerInGame - 为什么不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43938214/
我正在尝试做一个在游戏打开时自动按下按键的机器人。在记事本中这个程序运行良好,但在 Metin2 中它什么也不做。你有什么想法,有什么问题吗? int main() { clock_t start =
我是一名优秀的程序员,十分优秀!