Last active
April 5, 2016 23:39
-
-
Save RyuaNerin/b38656708a11dc2dc402 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static class NativeMethods | |
| { | |
| [DllImport("user32.dll")] | |
| [return: MarshalAs(UnmanagedType.Bool)] | |
| public static extern bool PeekMessage( | |
| [In] ref MSG lpMsg, | |
| IntPtr hwnd, | |
| uint wMsgFilterMin, | |
| uint wMsgFilterMax, | |
| uint wRemoveMsg); | |
| [DllImport("user32.dll")] | |
| public static extern bool TranslateMessage( | |
| [In] ref MSG lpMsg); | |
| [DllImport("user32.dll")] | |
| public static extern IntPtr DispatchMessage( | |
| [In] ref MSG lpmsg); | |
| [StructLayout(LayoutKind.Sequential)] | |
| public struct MSG | |
| { | |
| public int hwnd; | |
| public int message; | |
| public int wParam; | |
| public int lParam; | |
| public int time; | |
| public POINTAPI pt; | |
| } | |
| [StructLayout(LayoutKind.Sequential)] | |
| public struct POINTAPI | |
| { | |
| public int x; | |
| public int y; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var msg = new NativeMethods.MSG(); | |
| while (true) | |
| { | |
| if (NativeMethods.PeekMessage(ref msg, IntPtr.Zero, 0, 0, NativeMethods.PM_REMOVE)) | |
| { | |
| NativeMethods.TranslateMessage(ref msg); | |
| NativeMethods.DispatchMessage(ref msg); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment