|
-
June 17th, 2006, 04:24 PM
#1
sendinput
i used
Code:
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?
-
June 18th, 2006, 01:16 AM
#2
Re: sendinput
SendMessage allows you to send BN_CLICKED messages to a window that you have the handle of.
-
June 18th, 2006, 02:54 AM
#3
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 .
Code:
::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
-
June 18th, 2006, 03:00 AM
#4
Re: sendinput
 Originally Posted by dave2k
i used
Code:
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 don’t want to move the cursor why you are passing the MOUSEEVENTF_MOVE flag? 
Simply omit it.
Anyway look at this FAQ.
Cheers
-
June 18th, 2006, 04:18 AM
#5
Re: sendinput
i did omit MOUSEEVENTF_MOVE, but it doesn't work! try it!
-
June 18th, 2006, 05:31 AM
#6
Re: sendinput
Omit also MOUSEEVENTF_ABSOLUTE!
Please don't forget to rate users who helped you!
-
June 18th, 2006, 06:04 AM
#7
Re: sendinput
 Originally Posted by dave2k
i did omit MOUSEEVENTF_MOVE, but it doesn't work! try it!
Look at the FAQ i posted you in my previous post.
Cheers
-
June 18th, 2006, 06:09 AM
#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.
-
June 18th, 2006, 06:11 AM
#9
Re: sendinput
 Originally Posted by dave2k
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
-
June 18th, 2006, 06:28 AM
#10
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?
-
June 18th, 2006, 03:52 PM
#11
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?
-
June 18th, 2006, 11:35 PM
#12
Re: sendinput
Just Check out My Previous Post. this will help you in Sending a click event to any Button.
Thanx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|