Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,673 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,199 people online right now. Registration is fast and FREE... Join Now!




SendInput/Mouse event help

 
Reply to this topicStart new topic

SendInput/Mouse event help, Need some help

jpw1991
post 19 Sep, 2007 - 01:55 AM
Post #1


New D.I.C Head

*
Joined: 13 Aug, 2007
Posts: 33


My Contributions


Hello. I'm trying to make a program that performs a mouse click. I'm unsure why it isn't working.

I used MSDN for the structure of this code.

CODE
#include <windows.h>
#include <winuser.h>

int main()
{
    mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 757, 447, 0, 0);
    return 0;
}


The code compiles, but when I run it I don't think its performing the mouse click.

I've also heard that mouse_event() is the old way of doing it, and that I should be using SendInput(), but I don't understand the structure MSDN has provided. If anyone could provide an example of code that performs a mouse click using SendInput() I'd be very grateful.

Thanks in advance,

jpw1991
User is offlineProfile CardPM

Go to the top of the page

skyHigh
post 1 Oct, 2007 - 07:30 PM
Post #2


D.I.C Head

**
Joined: 1 Oct, 2007
Posts: 87


My Contributions


QUOTE(jpw1991 @ 19 Sep, 2007 - 02:55 AM) *

Hello. I'm trying to make a program that performs a mouse click. I'm unsure why it isn't working.

I used MSDN for the structure of this code.

CODE
#include <windows.h>
#include <winuser.h>

int main()
{
    mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 757, 447, 0, 0);
    return 0;
}


The code compiles, but when I run it I don't think its performing the mouse click.

I've also heard that mouse_event() is the old way of doing it, and that I should be using SendInput(), but I don't understand the structure MSDN has provided. If anyone could provide an example of code that performs a mouse click using SendInput() I'd be very grateful.

Thanks in advance,

jpw1991



when I use the code below, it works.
mouse_event(MOUSEEVENT_LEFTDOWN, 100,100,0,0);
mouse_event(MOUSEEVENT_LEFTUP, 100,100,0,0);
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/23/08 06:22AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month