Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Mouse control
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Raugrist




PostPosted: Tue Apr 13, 2004 4:07 pm   Post subject: Mouse control

Does anybody have any idea how I could make a program that controls the user's mouse and possibly simulate mouse clicks? You know how in a FPS when you move the mouse around to aim, the program understands that you moved the mouse in some direction, takes the necessary steps and then moves the mouse back (so you don't run into the edge of the screen).

How could I do that?
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Tue Apr 13, 2004 5:41 pm   Post subject: (No subject)

It's entirely dependent on what environment you're programming in. Is it an X Windows (Linux, FreeBSD, Solaris, etc.) environment, a Windows environment, or within the context of .NET?

I'd reccomend siccing Google on this problem. Smile
Raugrist




PostPosted: Tue Apr 13, 2004 7:45 pm   Post subject: (No subject)

I was thinking windows, because I only just started Linux and the school computers are still on windows. But yeah, I guess google will be the way to go.
scryed




PostPosted: Wed Apr 14, 2004 11:46 am   Post subject: (No subject)

If you are using MFC then just go to the class wizard, you will see events like WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MOUSEMOVE. If you map a message to these then Windows will pass in a CPoint object.

If you are doing it from scratch it is a little harder but the messages are the same.
Catalyst




PostPosted: Wed Apr 14, 2004 2:05 pm   Post subject: (No subject)

you could either check for the message in ur windows message loop
code:

case WM_MOUSEMOVE:
 {

     mouseX =(double) LOWORD(lParam); 
     mouseY =(double) HIWORD(lParam); 
}

// these are button states

   case WM_LBUTTONDOWN:                     
   case WM_LBUTTONUP:                     
   case WM_MBUTTONDOWN:                     
   case WM_MBUTTONUP:                     
    case WM_RBUTTONDOWN:                     
   case WM_RBUTTONUP:       

// etc ...



or you could access the mouse directly using the get cursor function (this doesnt always work well tho, in my experience)

code:

POINT point;
GetCursorPos(point)
mouseX=point.x;
mouseY=point.y;


There are probably some conversion to do there tho

heres an msdn link for that
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/cursors/cursorreference/cursorfunctions/getcursorpos.asp
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: