Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Mono to Click the Mouse in C# - Mac OS

I have written an application (wpf - will Mono translate this for a Mac?) that I wish to somehow port across to Mac OS X. This application involves using user32.dll to perform a mouse click (something like this):

[DllImport("user32.dll")]
    static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);

I have heard Mono is useful for making applications for multiple platforms - is there a way that I can use this to make my code compatible with a Mac?

If not, is there a way that I can invoke a mouse click using the Mac equivalent of user32.dll? And a way to detect whether the program is running in Windows or Mac OS to choose which bit of code to run?

like image 510
Jack Avatar asked Nov 05 '22 03:11

Jack


2 Answers

Mono currently does not plan to support WPF see Link.
Take a look at this SO question to see if it helps and you may want to look into using Silverlight since it is supported by Microsoft on the Mac.

like image 109
Mark Hall Avatar answered Nov 10 '22 15:11

Mark Hall


Also you are calling a Win32 native function - those are not supported on Mac. Your best bet would be using cross-platform .NET-strict code.

like image 27
Den Delimarsky Avatar answered Nov 10 '22 13:11

Den Delimarsky