winforms - Simulating mouse events? C# -


i'm trying create windows forms program makes computer act if pressed mouse-button. want control events manually (timing not decided in advance) , needs possible press , hold, mouse-button release should separate event.

the following information should not change code, further understand situation:

  • the purpose allow user input xbox 360 controller (compatible pc) steer/control computer connected to.
  • the best solution have far found "windows.forms.sendkeys" method works keyboard events.

thanks in advance! :d

i simulate mouse events this

    [dllimport("user32.dll", charset = charset.auto, callingconvention = callingconvention.stdcall)]     public static extern void mouse_event(uint dwflags, uint dx, uint dy, uint cbuttons, uint 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; 

usage example:

    public static void leftclick()     {         mouse_event(mouseeventf_leftdown | mouseeventf_leftup, 0, 0, 0, 0);     } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -