sendinput

i used double fScreenWidth = ::GetSystemMetrics( SM_CXSCREEN )-1;
double fScreenHeight = ::GetSystemMetrics( SM_CYSCREEN )-1;
double fx = pt.x*(65535.0f/fScreenWidth);
double fy = pt.y*(65535.0f/fScreenHeight);
INPUT Input={0};
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_LEFTDOWN;
Input.mi.dx = fx;
Input.mi.dy = fy;
::SendInput(1,&Input,sizeof(INPUT));to input a mouse click, but the code mouves the cursor. is there a way without moving the cursor?
[571 byte] By [dave2k] at [2007-11-19 22:48:18]
# 1 Re: sendinput
SendMessage allows you to send BN_CLICKED messages to a window that you have the handle of.
LooselyBased at 2007-11-10 23:32:58 >
# 2 Re: sendinput
i Didn't Get your Question. if you Simply want to Click Something through your code you can do by Following Example . Which will Generate a Click Event on a Button .

::SendMessage(hwndChild,WM_COMMAND,MAKELONG(00000002,BN_CLICKED),NULL);

//hwndChild handle of the Window
//id of Control to whom you want to click

That's all you have to do.

Thanx
humptydumpty at 2007-11-10 23:33:58 >
# 3 Re: sendinput
i used double fScreenWidth = ::GetSystemMetrics( SM_CXSCREEN )-1;
double fScreenHeight = ::GetSystemMetrics( SM_CYSCREEN )-1;
double fx = pt.x*(65535.0f/fScreenWidth);
double fy = pt.y*(65535.0f/fScreenHeight);
INPUT Input={0};
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_LEFTDOWN;
Input.mi.dx = fx;
Input.mi.dy = fy;
::SendInput(1,&Input,sizeof(INPUT));to input a mouse click, but the code mouves the cursor. is there a way without moving the cursor?

If you dont want to move the cursor why you are passing the MOUSEEVENTF_MOVE flag? :confused:
Simply omit it.

Anyway look at this FAQ (http://www.dev-archive.com/forum/showthread.php?t=377394).

Cheers
golanshahar at 2007-11-10 23:35:03 >
# 4 Re: sendinput
i did omit MOUSEEVENTF_MOVE, but it doesn't work! try it!
dave2k at 2007-11-10 23:36:04 >
# 5 Re: sendinput
Omit also MOUSEEVENTF_ABSOLUTE!
philkr at 2007-11-10 23:37:03 >
# 6 Re: sendinput
i did omit MOUSEEVENTF_MOVE, but it doesn't work! try it!

Look at the FAQ i posted you in my previous post.

Cheers
golanshahar at 2007-11-10 23:38:02 >
# 7 Re: sendinput
let me clarify, i need to click a window at point 10, 10, without moving the mouse cursor from it's current position. all your faq examples seem to involve either moving the cursor or clicking where it is currently.
dave2k at 2007-11-10 23:38:59 >
# 8 Re: sendinput
let me clarify, i need to click a window at point 10, 10, without moving the mouse cursor from it's current position. all your faq examples seem to involve either moving the cursor or clicking where it is currently.

So whats the problem?

Save current cursor position.
Move the cursor to the place you need to click.
Perform the click.
return the cursor back to the saved position in stage A

Cheers
golanshahar at 2007-11-10 23:40:02 >
# 9 Re: sendinput
my program needs to click buttons in the background when i am using the cursor for other stuff. is this a SendMessage job?
dave2k at 2007-11-10 23:41:05 >
# 10 Re: sendinput
Are you trying to make it click a control like a button, or trying to send a mouse click to the specific location of 10,10 in the window and there is no button there?
LooselyBased at 2007-11-10 23:42:06 >
# 11 Re: sendinput
Just Check out My Previous Post. this will help you in Sending a click event to any Button.

Thanx
humptydumpty at 2007-11-10 23:43:05 >