mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-12 05:25:37 +02:00
reliably restore full screen window by simulating double clicking
This commit is contained in:
parent
23fd772152
commit
a515bd6e6e
1 changed files with 16 additions and 3 deletions
|
@ -3364,6 +3364,7 @@ namespace PersistentWindows.Common
|
||||||
long style = User32.GetWindowLong(hwnd, User32.GWL_STYLE);
|
long style = User32.GetWindowLong(hwnd, User32.GWL_STYLE);
|
||||||
if ((style & (long)WindowStyleFlags.CAPTION) == 0L)
|
if ((style & (long)WindowStyleFlags.CAPTION) == 0L)
|
||||||
{
|
{
|
||||||
|
Log.Error("no need to restore full screen window {0}", GetWindowTitle(hwnd));
|
||||||
return;
|
return;
|
||||||
/*
|
/*
|
||||||
style |= (long)WindowStyleFlags.CAPTION;
|
style |= (long)WindowStyleFlags.CAPTION;
|
||||||
|
@ -3397,7 +3398,6 @@ namespace PersistentWindows.Common
|
||||||
int centerx = screenPosition.Left + screenPosition.Width / 8;
|
int centerx = screenPosition.Left + screenPosition.Width / 8;
|
||||||
|
|
||||||
int centery = screenPosition.Top + 15;
|
int centery = screenPosition.Top + 15;
|
||||||
//User32.SetActiveWindow(hwnd);
|
|
||||||
User32.SetCursorPos(centerx, centery);
|
User32.SetCursorPos(centerx, centery);
|
||||||
int double_clck_interval = System.Windows.Forms.SystemInformation.DoubleClickTime / 2;
|
int double_clck_interval = System.Windows.Forms.SystemInformation.DoubleClickTime / 2;
|
||||||
User32.mouse_event(MouseAction.MOUSEEVENTF_LEFTDOWN | MouseAction.MOUSEEVENTF_LEFTUP,
|
User32.mouse_event(MouseAction.MOUSEEVENTF_LEFTDOWN | MouseAction.MOUSEEVENTF_LEFTUP,
|
||||||
|
@ -3405,18 +3405,31 @@ namespace PersistentWindows.Common
|
||||||
Thread.Sleep(double_clck_interval);
|
Thread.Sleep(double_clck_interval);
|
||||||
User32.mouse_event(MouseAction.MOUSEEVENTF_LEFTDOWN | MouseAction.MOUSEEVENTF_LEFTUP,
|
User32.mouse_event(MouseAction.MOUSEEVENTF_LEFTDOWN | MouseAction.MOUSEEVENTF_LEFTUP,
|
||||||
0, 0, 0, UIntPtr.Zero);
|
0, 0, 0, UIntPtr.Zero);
|
||||||
Thread.Sleep(double_clck_interval);
|
Log.Error("restore full screen window {0}", GetWindowTitle(hwnd));
|
||||||
|
|
||||||
|
Thread.Sleep(3 * double_clck_interval);
|
||||||
style = User32.GetWindowLong(hwnd, User32.GWL_STYLE);
|
style = User32.GetWindowLong(hwnd, User32.GWL_STYLE);
|
||||||
if ((style & (long)WindowStyleFlags.CAPTION) == 0L)
|
if ((style & (long)WindowStyleFlags.CAPTION) == 0L)
|
||||||
{
|
{
|
||||||
Log.Error("restore full screen window {0}", GetWindowTitle(hwnd));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
User32.mouse_event(MouseAction.MOUSEEVENTF_LEFTDOWN | MouseAction.MOUSEEVENTF_LEFTUP,
|
User32.mouse_event(MouseAction.MOUSEEVENTF_LEFTDOWN | MouseAction.MOUSEEVENTF_LEFTUP,
|
||||||
0, 0, 0, UIntPtr.Zero);
|
0, 0, 0, UIntPtr.Zero);
|
||||||
|
Thread.Sleep(double_clck_interval);
|
||||||
|
User32.mouse_event(MouseAction.MOUSEEVENTF_LEFTDOWN | MouseAction.MOUSEEVENTF_LEFTUP,
|
||||||
|
0, 0, 0, UIntPtr.Zero);
|
||||||
|
|
||||||
Log.Error("double restore full screen window {0}", GetWindowTitle(hwnd));
|
Log.Error("double restore full screen window {0}", GetWindowTitle(hwnd));
|
||||||
|
|
||||||
|
Thread.Sleep(3 * double_clck_interval);
|
||||||
|
style = User32.GetWindowLong(hwnd, User32.GWL_STYLE);
|
||||||
|
if ((style & (long)WindowStyleFlags.CAPTION) == 0L)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Error("fail to restore full screen window {0}", GetWindowTitle(hwnd));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RestoreSnapWindow(IntPtr hwnd, RECT target_pos)
|
private void RestoreSnapWindow(IntPtr hwnd, RECT target_pos)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue