Compare commits

...

3 Commits

2 changed files with 11 additions and 11 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
.idea .idea
obj obj
bin bin
.vs

View File

@@ -19,6 +19,9 @@ internal static class Program {
[DllImport("user32.dll")] [DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd); public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
private static extern short GetKeyState(int nVirtKey);
[DllImport("kernel32.dll", SetLastError = true)] [DllImport("kernel32.dll", SetLastError = true)]
[return:MarshalAs(UnmanagedType.Bool)] [return:MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole(); static extern bool AllocConsole();
@@ -202,6 +205,10 @@ internal static class Program {
} }
} }
private static bool IsScrollLockOn() {
return (GetKeyState(0x91) & 1) == 1;
}
[STAThread] [STAThread]
private static void Main() { private static void Main() {
// AllocConsole(); // AllocConsole();
@@ -216,8 +223,7 @@ internal static class Program {
Process.GetCurrentProcess().Kill(); Process.GetCurrentProcess().Kill();
} }
long delLast = 0; HotKeyManager.RegisterHotKey(Keys.Scroll, KeyModifiers.NoRepeat);
HotKeyManager.RegisterHotKey(Keys.End, KeyModifiers.NoRepeat);
// Register main number keys (0-9) // Register main number keys (0-9)
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
HotKeyManager.RegisterHotKey(Keys.D0 + i, KeyModifiers.Alt); HotKeyManager.RegisterHotKey(Keys.D0 + i, KeyModifiers.Alt);
@@ -235,10 +241,6 @@ internal static class Program {
return; return;
} }
long now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
if (e.Key == Keys.End)
delLast = now;
int index; int index;
if (e.Key >= Keys.D0 && e.Key <= Keys.D9) { if (e.Key >= Keys.D0 && e.Key <= Keys.D9) {
index = e.Key - Keys.D0; index = e.Key - Keys.D0;
@@ -248,12 +250,9 @@ internal static class Program {
return; return;
} }
long cocksucker = DateTime.Now.Second;
Console.WriteLine(cocksucker);
if (e.Modifiers == KeyModifiers.Alt) { if (e.Modifiers == KeyModifiers.Alt) {
if (now - delLast <= 1) { if (IsScrollLockOn()) {
Swap(index); Swap(index);
delLast = 0;
} else { } else {
TabTo(index); TabTo(index);
} }