C++不存在从输入到LPINPUT的合适转换功能
我正在尝试获取鼠标的坐标,然后将鼠标相对移动到这些坐标。
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
int main() {
SHORT f5;
POINT pt{};
MOUSEINPUT _mi{};
INPUT mm{};
mm.type = 0;
for (;;) {
f5 = GetAsyncKeyState(0x74);
if (f5 > 0) {
GetCursorPos(&pt);
_mi.dx = pt.x + 100;
_mi.dy = pt.y + 100;
mm.mi = _mi;
SendInput(1, mm, sizeof(mm));
}
Sleep(50);
}
return 0;
}
我遇到了一个错误,说不存在从输入到LPINPUT的合适转换,但我也不知道如何创建“ LPINPUT”结构。
i'm trying to get the coordinates of the mouse, then move the mouse relative to those coordinates.
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
int main() {
SHORT f5;
POINT pt{};
MOUSEINPUT _mi{};
INPUT mm{};
mm.type = 0;
for (;;) {
f5 = GetAsyncKeyState(0x74);
if (f5 > 0) {
GetCursorPos(&pt);
_mi.dx = pt.x + 100;
_mi.dy = pt.y + 100;
mm.mi = _mi;
SendInput(1, mm, sizeof(mm));
}
Sleep(50);
}
return 0;
}
I'm getting an error saying that no suitable conversion from INPUT to LPINPUT exists, but I also have no idea how to create a "LPINPUT" struct.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
sendInput()
期望指向Input
结构的数组。由于您仅传递1输入
,请将其作为指针的地址作为指针,通过将结构与>&amp;
运算符相结合,只需就像getCursorPos()
一样:SendInput()
expects a pointer to an array ofINPUT
structures. Since you are passing only 1INPUT
, give it the address of yourINPUT
as a pointer by prefixing the structure with the&
operator, just as you did withGetCursorPos()
: