Sign in to follow this  
Basket Case

Mouse Input???

Recommended Posts

I have a program that is in console, and I want to be able to check if a user clicks in a certain rectangle on the screen. I'm using GDI to draw text to the screen, is there a certain function that allows me to check if someone clicks there? Since I don't have a window I can't use The win32 API, and for this size of project it really isn't necesarry to use DirectInput, so does anyone else have another soloution...an explanation, code, or a tutorial would be nice. Thanks in advance, and tell me if you need any other information.

Share this post


Link to post
Share on other sites
When you make a console project you can still use Win32 functions.
In a loop or timer check where the mouse cursor is located, use GetCursorPos ().
If the x and y of the mouse are inside the rect, you can check if the left mouse button is down, use GetAsyncKeyState (VK_LBUTTON).
The number that GetAsyncKeyState () returns contains not only the key state (or mouse button state) so to check only if the key is up or down you need to check the most significant bit as following:
(GetAsyncKeyState () & 0x8000).
For more informaion about this function look here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/getasynckeystate.asp

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this