Joined: 24 Dec 2007 Posts: 2276 Location: Minnesota
Posted: Fri Dec 26, 2008 10:42 am Post subject: [vb.net] Get mouse press down and up
I used getkeyasync(keys.Lbutton) but it will only get it when it is pressed then released? How will I use getkeystate(keys.Lbutton) to check if its pressed or released??? _________________
If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down
Quote:
The GetAsyncKeyState function works with mouse buttons. However, it checks on the state of the physical mouse buttons, not on the logical mouse buttons that the physical buttons are mapped to. For example, the call GetAsyncKeyState(VK_LBUTTON) always returns the state of the left physical mouse button, regardless of whether it is mapped to the left or right logical mouse button. You can determine the system's current mapping of physical mouse buttons to logical mouse buttons by calling
GetSystemMetrics(SM_SWAPBUTTON)
which returns TRUE if the mouse buttons have been swapped.
GetKeyState is not going to work for a 'global' hotkey kind of effect, if that is what you are going for. If you're just trying to query for keys within your own application when it is in focus, use the message loop.
Joined: 24 Dec 2007 Posts: 2276 Location: Minnesota
Posted: Fri Dec 26, 2008 3:53 pm Post subject:
slovach wrote:
Quote:
If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down
Quote:
The GetAsyncKeyState function works with mouse buttons. However, it checks on the state of the physical mouse buttons, not on the logical mouse buttons that the physical buttons are mapped to. For example, the call GetAsyncKeyState(VK_LBUTTON) always returns the state of the left physical mouse button, regardless of whether it is mapped to the left or right logical mouse button. You can determine the system's current mapping of physical mouse buttons to logical mouse buttons by calling
GetSystemMetrics(SM_SWAPBUTTON)
which returns TRUE if the mouse buttons have been swapped.
GetKeyState is not going to work for a 'global' hotkey kind of effect, if that is what you are going for. If you're just trying to query for keys within your own application when it is in focus, use the message loop.
not in my application, system wide. Ooo I found out now. _________________
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum