mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 04:55:39 +02:00
add snapshot id "`" for the last auto restore point
This commit is contained in:
parent
90b2a2f2c6
commit
00c277c814
3 changed files with 43 additions and 16 deletions
|
@ -34,7 +34,7 @@ namespace PersistentWindows.Common
|
||||||
private const int UserMoveLatency = 1000; // delay in milliseconds from user move/minimize/unminimize/maximize to capture, must < CaptureLatency
|
private const int UserMoveLatency = 1000; // delay in milliseconds from user move/minimize/unminimize/maximize to capture, must < CaptureLatency
|
||||||
private const int MaxUserMoves = 4; // max user window moves per capture cycle
|
private const int MaxUserMoves = 4; // max user window moves per capture cycle
|
||||||
private const int MinWindowOsMoveEvents = 12; // threshold of window move events initiated by OS per capture cycle
|
private const int MinWindowOsMoveEvents = 12; // threshold of window move events initiated by OS per capture cycle
|
||||||
private const int MaxSnapshots = 37; // 0-9, a-z, and final one for undo
|
private const int MaxSnapshots = 38; // 0-9, a-z, ` and final one for undo
|
||||||
private const int MaxHistoryQueueLength = 40; // must be bigger than MaxSnapshots + 1
|
private const int MaxHistoryQueueLength = 40; // must be bigger than MaxSnapshots + 1
|
||||||
|
|
||||||
private const int PauseRestoreTaskbar = 3500; //cursor idle time before dragging taskbar
|
private const int PauseRestoreTaskbar = 3500; //cursor idle time before dragging taskbar
|
||||||
|
@ -510,6 +510,13 @@ namespace PersistentWindows.Common
|
||||||
Log.Event("Restore finished in pass {0} with {1} windows recovered for display setting {2}", restorePass, numWindowRestored, curDisplayKey);
|
Log.Event("Restore finished in pass {0} with {1} windows recovered for display setting {2}", restorePass, numWindowRestored, curDisplayKey);
|
||||||
sessionActive = true;
|
sessionActive = true;
|
||||||
|
|
||||||
|
if (!wasRestoringSnapshot)
|
||||||
|
{
|
||||||
|
if (!snapshotTakenTime.ContainsKey(curDisplayKey))
|
||||||
|
snapshotTakenTime[curDisplayKey] = new Dictionary<int, DateTime>();
|
||||||
|
snapshotTakenTime[curDisplayKey][MaxSnapshots - 2] = lastUserActionTime[curDisplayKey];
|
||||||
|
}
|
||||||
|
|
||||||
if (wasRestoringSnapshot || noRestoreWindowsTmp.Count > 0)
|
if (wasRestoringSnapshot || noRestoreWindowsTmp.Count > 0)
|
||||||
CaptureApplicationsOnCurrentDisplays(curDisplayKey, immediateCapture: true);
|
CaptureApplicationsOnCurrentDisplays(curDisplayKey, immediateCapture: true);
|
||||||
else
|
else
|
||||||
|
|
|
@ -25,6 +25,8 @@ namespace PersistentWindows.SystrayShell
|
||||||
public static bool Gui = true;
|
public static bool Gui = true;
|
||||||
public static bool hotkey_window = true;
|
public static bool hotkey_window = true;
|
||||||
|
|
||||||
|
private const int MaxSnapshots = 38; // 0-9, a-z, ` and final one for undo
|
||||||
|
|
||||||
static PersistentWindowProcessor pwp = null;
|
static PersistentWindowProcessor pwp = null;
|
||||||
static SystrayForm systrayForm = null;
|
static SystrayForm systrayForm = null;
|
||||||
static bool silent = false; //suppress all balloon tip & sound prompt
|
static bool silent = false; //suppress all balloon tip & sound prompt
|
||||||
|
@ -514,6 +516,8 @@ namespace PersistentWindows.SystrayShell
|
||||||
c = '0';
|
c = '0';
|
||||||
c += (char)id;
|
c += (char)id;
|
||||||
}
|
}
|
||||||
|
else if (id == MaxSnapshots - 2)
|
||||||
|
c = '`';
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
c = 'a';
|
c = 'a';
|
||||||
|
@ -525,6 +529,8 @@ namespace PersistentWindows.SystrayShell
|
||||||
|
|
||||||
static public int SnapshotCharToId(char c)
|
static public int SnapshotCharToId(char c)
|
||||||
{
|
{
|
||||||
|
if (c == '`')
|
||||||
|
return MaxSnapshots - 2;
|
||||||
if (c < '0')
|
if (c < '0')
|
||||||
return -1;
|
return -1;
|
||||||
if (c > 'z')
|
if (c > 'z')
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace PersistentWindows.SystrayShell
|
||||||
{
|
{
|
||||||
public partial class SystrayForm : Form
|
public partial class SystrayForm : Form
|
||||||
{
|
{
|
||||||
|
private const int MaxSnapshots = 38; // 0-9, a-z, ` and final one for undo
|
||||||
|
|
||||||
public bool restoreToolStripMenuItemEnabled;
|
public bool restoreToolStripMenuItemEnabled;
|
||||||
public bool restoreSnapshotMenuItemEnabled;
|
public bool restoreSnapshotMenuItemEnabled;
|
||||||
|
|
||||||
|
@ -70,11 +72,11 @@ namespace PersistentWindows.SystrayShell
|
||||||
|
|
||||||
pauseUpgradeCounter = true;
|
pauseUpgradeCounter = true;
|
||||||
|
|
||||||
int keyPressed = -1;
|
Keys keyPressed = Keys.None;
|
||||||
//check 0-9 key pressed
|
//check 0-9 key pressed
|
||||||
for (int i = 0x30; i < 0x3a; ++i)
|
for (Keys i = Keys.D0; i <= Keys.D9; ++i)
|
||||||
{
|
{
|
||||||
if (User32.GetAsyncKeyState(i) != 0)
|
if (User32.GetAsyncKeyState((int)i) != 0)
|
||||||
{
|
{
|
||||||
keyPressed = i;
|
keyPressed = i;
|
||||||
break;
|
break;
|
||||||
|
@ -82,16 +84,24 @@ namespace PersistentWindows.SystrayShell
|
||||||
}
|
}
|
||||||
|
|
||||||
//check a-z pressed
|
//check a-z pressed
|
||||||
if (keyPressed < 0)
|
if (keyPressed == Keys.None)
|
||||||
for (int i = 0x41; i < 0x5b; ++i)
|
for (Keys i = Keys.A; i <= Keys.Z; ++i)
|
||||||
{
|
{
|
||||||
if (User32.GetAsyncKeyState(i) != 0)
|
if (User32.GetAsyncKeyState((int)i) != 0)
|
||||||
{
|
{
|
||||||
keyPressed = i;
|
keyPressed = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (keyPressed == Keys.None)
|
||||||
|
{
|
||||||
|
if (User32.GetAsyncKeyState((int)Keys.Oem3) != 0)
|
||||||
|
{
|
||||||
|
keyPressed = Keys.Oem3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int totalSpecialKeyPressed = shiftKeyPressed + altKeyPressed;
|
int totalSpecialKeyPressed = shiftKeyPressed + altKeyPressed;
|
||||||
|
|
||||||
if (clickCount > 2)
|
if (clickCount > 2)
|
||||||
|
@ -104,7 +114,7 @@ namespace PersistentWindows.SystrayShell
|
||||||
else if (altKeyPressed == clickCount && altKeyPressed != 0 && ctrlKeyPressed == 0)
|
else if (altKeyPressed == clickCount && altKeyPressed != 0 && ctrlKeyPressed == 0)
|
||||||
{
|
{
|
||||||
//restore previous workspace (not necessarily a snapshot)
|
//restore previous workspace (not necessarily a snapshot)
|
||||||
Program.RestoreSnapshot(36); //MaxSnapShot - 1
|
Program.RestoreSnapshot(MaxSnapshots - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -128,12 +138,14 @@ namespace PersistentWindows.SystrayShell
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int snapshot;
|
int snapshot;
|
||||||
if (keyPressed < 0x3a)
|
if (keyPressed == Keys.Oem3)
|
||||||
snapshot = keyPressed - 0x30;
|
snapshot = MaxSnapshots - 2;
|
||||||
|
else if (keyPressed <= Keys.D9)
|
||||||
|
snapshot = keyPressed - Keys.D0;
|
||||||
else
|
else
|
||||||
snapshot = keyPressed - 0x41 + 10;
|
snapshot = keyPressed - Keys.A + 10;
|
||||||
|
|
||||||
if (snapshot < 0 || snapshot > 35)
|
if (snapshot < 0 || snapshot > MaxSnapshots - 2)
|
||||||
{
|
{
|
||||||
//invalid key pressed
|
//invalid key pressed
|
||||||
}
|
}
|
||||||
|
@ -407,15 +419,17 @@ namespace PersistentWindows.SystrayShell
|
||||||
Console.WriteLine("MouseClick");
|
Console.WriteLine("MouseClick");
|
||||||
|
|
||||||
// clear memory of keyboard input
|
// clear memory of keyboard input
|
||||||
for (int i = 0x30; i < 0x3a; ++i)
|
for (Keys i = Keys.D0; i <= Keys.D9; ++i)
|
||||||
{
|
{
|
||||||
User32.GetAsyncKeyState(i);
|
User32.GetAsyncKeyState((int)i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0x41; i < 0x5b; ++i)
|
for (Keys i = Keys.A; i <= Keys.Z; ++i)
|
||||||
{
|
{
|
||||||
User32.GetAsyncKeyState(i);
|
User32.GetAsyncKeyState((int)i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
User32.GetAsyncKeyState((int)Keys.Oem3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue