public void BlockingProcessMessage() { MSG msg = new MSG(); int ret = WindowsNativeFunctions.GetMessage(ref msg, windowHandle, 0, 0); if (ret == -1) { throw new PlatformException(String.Format("An error happened while processing the message queue. Windows error: {0}", Marshal.GetLastWin32Error())); } WindowsNativeFunctions.TranslateMessage(ref msg); WindowsNativeFunctions.DispatchMessage(ref msg); }
public WindowsHelper(String windowTitleString) { // // Find the window handle // IntPtr windowTitle = Marshal.StringToHGlobalAuto(windowTitleString); this.windowHandle = WindowsNativeFunctions.FindWindow(IntPtr.Zero, windowTitle); if (windowHandle == IntPtr.Zero) { throw new ArgumentException(String.Format("Could not find window with title '{0}'", windowTitleString)); } }