private static void MoveSndVolWindow(int SndVolId) { //Wait a little bit for the window to be created, with a max wait time of 100 * 10ms, or 1 second for (int i = 0; i < 100; i++) { System.Threading.Thread.Sleep(10); foreach (Process p in Process.GetProcessesByName("sndvol")) { if (p.Id == SndVolId && p.MainWindowHandle != IntPtr.Zero) { Unmanaged.RECT SndVolRect = new Unmanaged.RECT(); Unmanaged.GetWindowRect(p.MainWindowHandle, out SndVolRect); int margin = 10; int x = 0, y = 0; switch (Helper.GetTaskbarEdge()) { case DockStyle.Right: case DockStyle.Bottom: { x = Screen.PrimaryScreen.WorkingArea.Right - (SndVolRect.right - SndVolRect.left) - margin; y = Screen.PrimaryScreen.WorkingArea.Bottom - (SndVolRect.bottom - SndVolRect.top) - margin; } break; case DockStyle.Left: { x = Screen.PrimaryScreen.WorkingArea.Left + margin; y = Screen.PrimaryScreen.WorkingArea.Bottom - (SndVolRect.bottom - SndVolRect.top) - margin; } break; case DockStyle.Top: { x = Screen.PrimaryScreen.WorkingArea.Right - (SndVolRect.right - SndVolRect.left) - margin; y = Screen.PrimaryScreen.WorkingArea.Top + margin; } break; } Unmanaged.SetWindowPos(p.MainWindowHandle.ToInt32(), 0, x, y, 0, 0, 0x4000 | 0x0001); } } } }