Advertisement

Getting the mouse button status in windows

Started by June 06, 2000 02:13 PM
1 comment, last by ao 24 years, 6 months ago
I would like to be able to retrieve the status of my mouse buttons ( just the left and right buttons, nothing more fancy than that ), but I can not use the standard windows message loop to wait for a WM_LBUTTONDOWN, etc... message. I know there is a GetCursorPos( .. ) function to retrieve the mouse position, is there a similar function to retrieve the buttons status? I can''t seem to find one, oh I can''t use DirectInput either. ao
Play free Java games at: www.infinitepixels.com
Hi!

To get the state of the mouse buttons, use the function GetAsyncKeyState(...) with the parameter VK_LBUTTON or VK_RBUTTON. If you want to check whether the left mouse button is currently down, do it like this:
if(GetAsyncKeyState(VK_LBUTTON) & 0x80){   //Do something...} 

Check out this link for more information. At the bottom of the page there are links to some other functions that may be of interest too.

Good luck

*Sparkle*
Advertisement
Hey, thanks alot

I never even thought to look at GetAsyncKeyState, the fact that it said KeyState in it automatically programmed me to think that I wouldn''t be able
to use it for the mouse.

ao
Play free Java games at: www.infinitepixels.com

This topic is closed to new replies.

Advertisement