Search code examples
macosmonokeypresssimulate

How to simulate a Keyboard/Mouse key press?


I am working on a Mac OS X project. I am using Mono Mac. I want to simulate a keyboard key press and mouse key press and move just similar to the approach we were using in Windows forms ([DllImport("user32.dll")] ....)

I found some Obj-C solution but I cannot port it to Mono Mac. Some of them are in this stack link: Set the mouse location


Solution

  • I my self found the answer! You need to P/Invoke the required classes in the ObjC (in the CoreGraphics) which you can easily do this in Mono as the following code demonstrates:

    [DllImport(Constants.CoreGraphicsLibrary)]
    

    Regards, Peyman Mortazavi