if (i==0)
{
//Here I've to do MouseDown operation
}
else
{
//perform MouseUp operation
}
這是示例代碼我WANN做事端像上面......鼠標點擊操作VC++
我可以通過SetCursorPos移動鼠標()。所以,我怎麼能執行單擊事件
if (i==0)
{
//Here I've to do MouseDown operation
}
else
{
//perform MouseUp operation
}
這是示例代碼我WANN做事端像上面......鼠標點擊操作VC++
我可以通過SetCursorPos移動鼠標()。所以,我怎麼能執行單擊事件
可以使用SendInput
WinAPI的功能(也有過時的mouse_event
功能以及,我覺得這更容易使用,但不建議使用/替代標記)可以模擬任何形式的輸入。
取決於你正在做什麼,SendMessage
(阻塞)或PostMessage
(非阻塞)可能會更好/更易於使用,因爲這些送通過直接輸入事件產生的窗口消息。
那麼,對於highgui窗口,試試這個來代替:
void onmouse(int event, int x, int y, int d, void *ptr)
{
// cache coords for use in main()
cv::Point * p = (cv::Point *)ptr;
p->x = x;
p->y = y;
if (event != 0)
cout << event << " " << x << " " << y << " " << d << " " << endl;
}
int main()
{
cv::namedWindow("win",1);
cv::Point p;
cv::SetMouseCallback("win",onmouse,(void*)(&p));
...
// whenever someone clicks or moves, the coords will be in p now
爲什麼標記'opencv'?你究竟想達到什麼目的? – LihO 2013-03-27 14:44:40
我正在做類似使用Opencv庫的虛擬鼠標...... – 2013-03-27 15:00:36