1

I am running Python inside Grasshopper which is a plug-in for Rhino3d. I can easily get the mouse position, but fail to just check whether a mouse button is currently pressed. How exactly the piece of software in which this script is running is organized is unknown, but I cannot setup any handlers using Python. enter image description here

1 Answers1

2

Use the GetAsyncKeyState for VK_LBUTTON or VK_RBUTTON. Or use GetKeyState depending on your requirements. Be sure to read the documentation in the GetAsyncKeyState link regarding mouse buttons. Here's the signature for it:

[DllImport("user32.dll")]
public static extern short GetAsyncKeyState(UInt16 virtualKeyCode);
Ton Plooij
  • 2,583
  • 12
  • 15
  • "This example requires that the MouseDown, MouseMove, and MouseUp events are connected to the event handlers defined in the example." I can't do this... –  May 05 '16 at 08:27