如何将 dwExtraInfo 与 SendInput 一起使用
How to use dwExtraInfo with SendInput
我正在使用 ::SendInput
发送鼠标点击事件:
void LeftDown (LONG x_cord, LONG y_cord)
{
INPUT Input={0};
// left down
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN;
Input.mi.dx = x_cord;
Input.mi.dy = y_cord;
Input.mi.dwExtraInfo = 0x12345; //Is this how to use it?
::SendInput(1,&Input,sizeof(INPUT));
}
我想将 dwExtraInfo
设置为某个自定义值并将其提取到目标应用程序的 WndProc
中。然后(例如)如果 dwExtraInfo
设置为某个特定值,我将忽略该点击:
LRESULT CALLBACK OSRWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if(message == WM_LBUTTONDOWN)
{
if(GetMessageExtraInfo() == 0x12345) //Is this how to use it?
//ignore
else
//do something
}
}
这种天真的方法是正确的使用方法吗 dwExtraInfo
还是有更好的做法?谢谢!
dwExtraInfo
An additional value associated with the mouse event. An application calls GetMessageExtraInfo to obtain this extra information.
所以是的,就像您在问题中显示的那样使用它。
我正在使用 ::SendInput
发送鼠标点击事件:
void LeftDown (LONG x_cord, LONG y_cord)
{
INPUT Input={0};
// left down
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN;
Input.mi.dx = x_cord;
Input.mi.dy = y_cord;
Input.mi.dwExtraInfo = 0x12345; //Is this how to use it?
::SendInput(1,&Input,sizeof(INPUT));
}
我想将 dwExtraInfo
设置为某个自定义值并将其提取到目标应用程序的 WndProc
中。然后(例如)如果 dwExtraInfo
设置为某个特定值,我将忽略该点击:
LRESULT CALLBACK OSRWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if(message == WM_LBUTTONDOWN)
{
if(GetMessageExtraInfo() == 0x12345) //Is this how to use it?
//ignore
else
//do something
}
}
这种天真的方法是正确的使用方法吗 dwExtraInfo
还是有更好的做法?谢谢!
dwExtraInfo
An additional value associated with the mouse event. An application calls GetMessageExtraInfo to obtain this extra information.
所以是的,就像您在问题中显示的那样使用它。