I am writing a library which uses a few functions from the windows user32.dll library, but I am compiling it with Mono to see how it fares on OS X. Unfortunately it cannot find the user32.dll library for obvious reasons.
But my question is this … is there a similar library on OS X which I can use? I am specifically looking for the following functions.
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
[DllImport("user32.dll")]
static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
[DllImport("user32.dll")]
static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
I think installing WINE would help, but I would prefer to avoid that if possible. Using the Ruby win32 wrapper is also an option?
From the Mono website:
And they also link to a page on Interop with Native Libraries.
Looking through pinvoke, one result is that
GetForegroundWindowreferences mwinapi — at first glance, that doesn’t look portable, so you might be out of luck in finding a managed solution.