user2790929
user2790929

Reputation: 21

LEAP Motion C# XAML WPF Application

I'm busy making a application where i can use the Leap as a mouse. I'm making a WPF application with C# and XAML. I allready can move the cursor, but i have problems making a function to activate the left mouse button. Can someone help me with this problem? I need to activate buttons created in XAML. Another solution could be a function that activates a button when de Leap cursor is on the button for like 3 seconds. I can't find any examples on the Internet. Does someone have a simple basic program or example for me? Please help!

Here is a link to the application i allready have. Maybe it helps https://www.dropbox.com/sh/kp51hdbhcacaky7/pdinDQpA-6

Upvotes: 2

Views: 1112

Answers (2)

Damian Legęza
Damian Legęza

Reputation: 64

About the "mouse over button" thing - u can try this solution (worked for me):

  1. create hover event for buttons (mouse entered / leave)
  2. create a bool flag for like "isHovered" (true if hovered, false if not)
  3. start a DispacherTimer, set it's Tick (3 sec?)
  4. on Tick do mouse click (previous answer)

hope it halped :)

Upvotes: 1

Damian Legęza
Damian Legęza

Reputation: 64

try this:

[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
    public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);

    private const int MOUSEEVENTF_LEFTDOWN = 0x02;
    private const int MOUSEEVENTF_LEFTUP = 0x04;
    private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
    private const int MOUSEEVENTF_RIGHTUP = 0x10;

    public static void DoMouseClick()
    {
            Point mousePoint = GetMousePosition();
            mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, (int)mousePoint.X, (int)mousePoint.Y, 0, 0);
    }

Upvotes: 0

Related Questions