KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In my C# console application, I am using SendMessage() to minimize all windows, effectively showing the Windows 8 Legacy Desktop. This works great, but I have to use a Thread.Sleep(1000) in order to wait for the Legacy Desktop to actually show before before I try to do anything else. IntPtr lHwnd = FindWindow("Shell_TrayWnd", null); SendMessage(lHwnd, WM_COMMAND, (IntPtr)MIN_ALL, IntPtr.Zero); Thread.Sleep(1000); I really want to replace the Thread.Sleep() with a more efficient way to detect that the Legacy Desktop is showing before continuing on. Any ideas? Edit: Here are the Interop wrappers and constants. just in case it helps.. [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll", EntryPoint = "SendMessage", SetLastError = true)] static extern IntPtr SendMessage(IntPtr hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam); const int WM_COMMAND = 0x111; const int MIN_ALL = 419; const int MIN_ALL_UNDO = 416;
Tags (comma-separated)
Save Edits
Cancel