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

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




Mysterious Mouseclick.

 
Reply to this topicStart new topic

Mysterious Mouseclick., Send a mouseclick to screen coords. Halp!!!!!!

C. Demming
19 May, 2008 - 06:39 PM
Post #1

New D.I.C Head
*

Joined: 19 May, 2008
Posts: 3

...........................................................................................................................................................
................................................. I'm writing a .dll with Visual C++ 2005 .................................................
............................................................................................................................................................

I'm trying to get my .dll to send a single mouseclick to the below coordinates when conditionY is met in functionX().

The following code is similar to example code I found on this forum. It DOES compile but DOESN'T work.
Function X mysteriously returns a value of "-48" constantly. Also: NO MOUSECLICK occurs.

Plz bear with me if I'm not even close here...I'm pretty new at coding (example: do the #include files need to be included in the .h file, or only in the .ccp file ??).

Halp Please!!! Thank you!!! crazy.gif

This is the .h file:

CODE

#include <windows.h>
#include <winable.h>


int left_click()
{
    // left mouse button down
    INPUT    Input={0};
    Input.type      = INPUT_MOUSE;
    Input.mi.dwFlags  = MOUSEEVENTF_LEFTDOWN;
    ::SendInput(1,&Input,sizeof(INPUT));
    
    // left mouse button up
    ::ZeroMemory(&Input,sizeof(INPUT));
    Input.type      = INPUT_MOUSE;
    Input.mi.dwFlags  = MOUSEEVENTF_LEFTUP;
    ::SendInput(1,&Input,sizeof(INPUT));

    return (-1);
}



This is the code in the .cpp:
CODE


#include <windows.h>
#include <winuser.h>
#include "mouseclick.h"

int mouseclick()
{
    
    mouse_event(MOUSEEVENTF_LEFTDOWN, 2857, 213, 0, 0);
    mouse_event(MOUSEEVENTF_LEFTUP,2857,213,0,0);

    return 0;
}

int functionX()
{
return(  
    conditionY==1     ?       mouseclick():  0);
}




This post has been edited by C. Demming: 20 May, 2008 - 01:36 PM
User is offlineProfile CardPM
+Quote Post

C. Demming
RE: Mysterious Mouseclick.
20 May, 2008 - 01:42 PM
Post #2

New D.I.C Head
*

Joined: 19 May, 2008
Posts: 3


ANYBODY ????


Thank you!!!!!!!!!!!!!!!!!!!!!!!!
User is offlineProfile CardPM
+Quote Post

gabehabe
RE: Mysterious Mouseclick.
20 May, 2008 - 02:06 PM
Post #3

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,539



Thanked: 98 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
There's a snippet on this website that you might find useful.

Take a look here smile.gif
User is offlineProfile CardPM
+Quote Post

C. Demming
RE: Mysterious Mouseclick.
20 May, 2008 - 02:30 PM
Post #4

New D.I.C Head
*

Joined: 19 May, 2008
Posts: 3

QUOTE(gabehabe @ 20 May, 2008 - 03:06 PM) *

There's a snippet on this website that you might find useful.

Take a look here smile.gif



Sweet. icon_up.gif I COULD use this snippet IF I knew how to tell my .dll how to send a keystroke to the numpad, but unfortunately I don't. icon_down.gif


User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 11:18PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month