mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 13:05:38 +02:00
no snapshot action if more than one special keys are pressed
This commit is contained in:
parent
05c5f446e9
commit
0d0192a2d7
1 changed files with 24 additions and 10 deletions
|
@ -22,9 +22,9 @@ namespace Ninjacrab.PersistentWindows.SystrayShell
|
||||||
private bool pauseUpgradeCounter = false;
|
private bool pauseUpgradeCounter = false;
|
||||||
private bool foundUpgrade = false;
|
private bool foundUpgrade = false;
|
||||||
|
|
||||||
private bool shiftKeyPressed;
|
private int shiftKeyPressed;
|
||||||
private bool controlKeyPressed;
|
private int controlKeyPressed;
|
||||||
private bool altKeyPressed;
|
private int altKeyPressed;
|
||||||
private int clickCount;
|
private int clickCount;
|
||||||
private System.Threading.Timer clickDelayTimer;
|
private System.Threading.Timer clickDelayTimer;
|
||||||
|
|
||||||
|
@ -40,22 +40,28 @@ namespace Ninjacrab.PersistentWindows.SystrayShell
|
||||||
if (clickCount > 3)
|
if (clickCount > 3)
|
||||||
clickCount = 3;
|
clickCount = 3;
|
||||||
|
|
||||||
if (shiftKeyPressed)
|
int totalSpecialKeyPressed = shiftKeyPressed + controlKeyPressed + altKeyPressed;
|
||||||
|
|
||||||
|
if (totalSpecialKeyPressed > clickCount)
|
||||||
|
{
|
||||||
|
//no more than one key can be pressed
|
||||||
|
}
|
||||||
|
if (shiftKeyPressed >= clickCount)
|
||||||
{
|
{
|
||||||
// take counted snapshot
|
// take counted snapshot
|
||||||
Program.TakeSnapshot(clickCount);
|
Program.TakeSnapshot(clickCount);
|
||||||
}
|
}
|
||||||
else if (controlKeyPressed)
|
else if (controlKeyPressed >= clickCount)
|
||||||
{
|
{
|
||||||
//restore counted snapshot
|
//restore counted snapshot
|
||||||
Program.RestoreSnapshot(clickCount);
|
Program.RestoreSnapshot(clickCount);
|
||||||
}
|
}
|
||||||
else if (altKeyPressed)
|
else if (altKeyPressed >= clickCount)
|
||||||
{
|
{
|
||||||
//restore previous workspace (not necessarily a snapshot)
|
//restore previous workspace (not necessarily a snapshot)
|
||||||
Program.RestoreSnapshot(4);
|
Program.RestoreSnapshot(4);
|
||||||
}
|
}
|
||||||
else
|
else if (totalSpecialKeyPressed == 0)
|
||||||
{
|
{
|
||||||
if (clickCount == 1)
|
if (clickCount == 1)
|
||||||
//restore unnamed(default) snapshot
|
//restore unnamed(default) snapshot
|
||||||
|
@ -65,6 +71,9 @@ namespace Ninjacrab.PersistentWindows.SystrayShell
|
||||||
}
|
}
|
||||||
|
|
||||||
clickCount = 0;
|
clickCount = 0;
|
||||||
|
shiftKeyPressed = 0;
|
||||||
|
controlKeyPressed = 0;
|
||||||
|
altKeyPressed = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -189,9 +198,14 @@ namespace Ninjacrab.PersistentWindows.SystrayShell
|
||||||
{
|
{
|
||||||
clickCount++;
|
clickCount++;
|
||||||
|
|
||||||
shiftKeyPressed = (User32.GetKeyState(0x10) & 0x8000) != 0;
|
if ((User32.GetKeyState(0x10) & 0x8000) != 0)
|
||||||
controlKeyPressed = (User32.GetKeyState(0x11) & 0x8000) != 0;
|
shiftKeyPressed++;
|
||||||
altKeyPressed = (User32.GetKeyState(0x12) & 0x8000) != 0;
|
|
||||||
|
if ((User32.GetKeyState(0x11) & 0x8000) != 0)
|
||||||
|
controlKeyPressed++;
|
||||||
|
|
||||||
|
if ((User32.GetKeyState(0x12) & 0x8000) != 0)
|
||||||
|
altKeyPressed++;
|
||||||
|
|
||||||
clickDelayTimer.Change(500, System.Threading.Timeout.Infinite);
|
clickDelayTimer.Change(500, System.Threading.Timeout.Infinite);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue