From 25c93b6ddadf5cb8b6da51e49a7f144dcd64e379 Mon Sep 17 00:00:00 2001 From: Sergio Dias Date: Sat, 25 Feb 2017 23:47:55 +0000 Subject: [PATCH 1/2] Added tooltips for pinning actions. Changed default hotkeys. --- settings.ini | 10 +-- virtual-desktop-enhancer.ahk | 121 +++++++++++++++++++++++++---------- 2 files changed, 93 insertions(+), 38 deletions(-) diff --git a/settings.ini b/settings.ini index fd6b801..5a4283d 100644 --- a/settings.ini +++ b/settings.ini @@ -4,9 +4,9 @@ TaskbarScrollSwitching=1 UseNativePrevNextDesktopSwitchingIfConflicting=0 [KeyboardShortcutsModifiers] -SwitchDesktop=LAlt -MoveWindowToDesktop=LAlt, Shift, Ctrl -MoveWindowAndSwitchToDesktop=LAlt, Shift +SwitchDesktop=Win, Ctrl +MoveWindowToDesktop= +MoveWindowAndSwitchToDesktop=Win, Ctrl, Shift NextTenDesktops= [KeyboardShortcutsIdentifiers] @@ -14,8 +14,8 @@ PreviousDesktop=Left NextDesktop=Right [KeyboardShortcutsCombinations] -TogglePinWindow=LAlt, Shift, Ctrl, Q -TogglePinApp=LAlt, Shift, Ctrl, A +TogglePinWindow=Win, Ctrl, Shift, Q +TogglePinApp=Win, Ctrl, Shift, A PinWindow= PinApp= UnpinWindow= diff --git a/virtual-desktop-enhancer.ahk b/virtual-desktop-enhancer.ahk index 97e2f33..bcfe991 100644 --- a/virtual-desktop-enhancer.ahk +++ b/virtual-desktop-enhancer.ahk @@ -2,6 +2,8 @@ #WinActivateForce #HotkeyInterval 20 #MaxHotkeysPerInterval 20000 +#MenuMaskKey vk07 +#UseHook ; Credits to Ciantic: https://github.com/Ciantic/VirtualDesktopAccessor #Include, %A_ScriptDir%\libraries\read-ini.ahk @@ -233,48 +235,72 @@ OnTaskbarScrollDown() { } OnPinWindowPress() { - _PinWindow() + windowID := _GetCurrentWindowID() + windowTitle := _GetCurrentWindowTitle() + _PinWindow(windowID) + _ShowTooltipForPinnedWindow(windowTitle) } OnUnpinWindowPress() { - _UnPinWindow() + windowID := _GetCurrentWindowID() + windowTitle := _GetCurrentWindowTitle() + _UnpinWindow(windowID) + _ShowTooltipForUnpinnedWindow(windowTitle) } OnTogglePinWindowPress() { - window := _GetCurrentWindow() - if (_GetIsWindowPinned(window)) { - _UnpinWindow(window) - } else { - _PinWindow(window) + windowID := _GetCurrentWindowID() + windowTitle := _GetCurrentWindowTitle() + if (_GetIsWindowPinned(windowID)) { + _UnpinWindow(windowID) + _ShowTooltipForUnpinnedWindow(windowTitle) + } + else { + _PinWindow(windowID) + _ShowTooltipForPinnedWindow(windowTitle) } } OnPinAppPress() { + windowID := _GetCurrentWindowID() + windowTitle := _GetCurrentWindowTitle() _PinApp() + _ShowTooltipForPinnedApp(windowTitle) } OnUnpinAppPress() { + windowID := _GetCurrentWindowID() + windowTitle := _GetCurrentWindowTitle() _UnpinApp() + _ShowTooltipForUnpinnedApp(windowTitle) } OnTogglePinAppPress() { - window := _GetCurrentWindow() - if (_GetIsAppPinned(window)) { - _UnpinApp(window) - } else { - _PinApp(window) + windowID := _GetCurrentWindowID() + windowTitle := _GetCurrentWindowTitle() + if (_GetIsAppPinned(windowID)) { + _UnpinApp(windowID) + _ShowTooltipForUnpinnedApp(windowTitle) + } + else { + _PinApp(windowID) + _ShowTooltipForPinnedApp(windowTitle) } } OnDesktopSwitch(n:=1) { if (TooltipsEnabled) { - _ShowTooltip(n) + _ShowTooltipForDesktopSwitch(n) } _ChangeAppearance(n) _ChangeBackground(n) _FocusIfRequested() } +Noop() { + Hotkey, LWin UP, Off +} + ; ====================================================================== ; Functions ; ====================================================================== @@ -323,11 +349,20 @@ _IsCursorHoveringTaskbar() { return (mouseHoveringID == taskbarID) } -_GetCurrentWindow() { +_GetCurrentWindowID() { WinGet, activeHwnd, ID, A return activeHwnd } +_GetCurrentWindowTitle() { + WinGetTitle, activeHwnd, A + return activeHwnd +} + +_TruncateString(string:="", n:=10) { + return (StrLen(string) > n ? SubStr(string, 1, n-3) . "..." : string) +} + _GetDesktopName(n:=1) { if (n == 0) { n := 10 @@ -360,7 +395,7 @@ _GetNumberOfDesktops() { } _MoveCurrentWindowToDesktop(n:=1) { - activeHwnd := _GetCurrentWindow() + activeHwnd := _GetCurrentWindowID() DllCall(MoveWindowToDesktopNumberProc, UInt, activeHwnd, UInt, n-1) } @@ -373,33 +408,33 @@ _ChangeDesktop(n:=1) { _CallWindowProc(proc, window:="") { if (window == "") { - window := _GetCurrentWindow() + window := _GetCurrentWindowID() } return DllCall(proc, UInt, window) } -_PinWindow(window:="") { - _CallWindowProc(PinWindowProc, window) +_PinWindow(windowID:="") { + _CallWindowProc(PinWindowProc, windowID) } -_UnpinWindow(window:="") { - _CallWindowProc(UnpinWindowProc, window) +_UnpinWindow(windowID:="") { + _CallWindowProc(UnpinWindowProc, windowID) } -_GetIsWindowPinned(window:="") { - return _CallWindowProc(IsPinnedWindowProc, window) +_GetIsWindowPinned(windowID:="") { + return _CallWindowProc(IsPinnedWindowProc, windowID) } -_PinApp(window:="") { - _CallWindowProc(PinAppProc, window) +_PinApp(windowID:="") { + _CallWindowProc(PinAppProc, windowID) } -_UnpinApp(window:="") { - _CallWindowProc(UnpinAppProc, window) +_UnpinApp(windowID:="") { + _CallWindowProc(UnpinAppProc, windowID) } -_GetIsAppPinned(window:="") { - return _CallWindowProc(IsPinnedAppProc, window) +_GetIsAppPinned(windowID:="") { + return _CallWindowProc(IsPinnedAppProc, windowID) } _ChangeBackground(n:=1) { @@ -451,12 +486,9 @@ _Focus() { SendEvent !{Esc} } -_ShowTooltip(n:=1) { - if (n == 0) { - n := 10 - } +_ShowTooltip(message:="") { params := {} - params.message := _GetDesktopName(n) + params.message := message params.lifespan := TooltipsLifespan params.position := TooltipsCentered params.fontSize := TooltipsFontSize @@ -465,3 +497,26 @@ _ShowTooltip(n:=1) { params.backgroundColor := TooltipsBackgroundColor Toast(params) } + +_ShowTooltipForDesktopSwitch(n:=1) { + if (n == 0) { + n := 10 + } + _ShowTooltip(_GetDesktopName(n)) +} + +_ShowTooltipForPinnedWindow(windowTitle) { + _ShowTooltip("Window """ . _TruncateString(windowTitle, 30) . """ pinned.") +} + +_ShowTooltipForUnpinnedWindow(windowTitle) { + _ShowTooltip("Window """ . _TruncateString(windowTitle, 30) . """ unpinned.") +} + +_ShowTooltipForPinnedApp(windowTitle) { + _ShowTooltip("App """ . _TruncateString(windowTitle, 30) . """ pinned.") +} + +_ShowTooltipForUnpinnedApp(windowTitle) { + _ShowTooltip("App """ . _TruncateString(windowTitle, 30) . """ unpinned.") +} From 7ced990fcb7f9f7924876366368f8426ec6e4444 Mon Sep 17 00:00:00 2001 From: Sergio Dias Date: Sun, 26 Feb 2017 00:00:22 +0000 Subject: [PATCH 2/2] Fixed documentation to match new default config. --- README.md | 73 +++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 3c3d913..4ded2f9 100644 --- a/README.md +++ b/README.md @@ -177,9 +177,9 @@ Here are some examples with different configs: With this config:
 [KeyboardShortcutsModifiers]
-SwitchDesktop=LAlt
-MoveWindowToDesktop=LAlt, Shift, Ctrl
-MoveWindowAndSwitchToDesktop=LAlt, Shift
+SwitchDesktop=Win, Ctrl
+MoveWindowToDesktop=
+MoveWindowAndSwitchToDesktop=Win, Ctrl, Shift
 NextTenDesktops=
 
 [KeyboardShortcutsIdentifiers]
@@ -187,8 +187,8 @@ PreviousDesktop=Left
 NextDesktop=Right
 
 [KeyboardShortcutsCombinations]
-TogglePinWindow=LAlt, Shift, Ctrl, Q
-TogglePinApp=LAlt, Shift, Ctrl, A
+TogglePinWindow=Win, Ctrl, Shift, Q
+TogglePinApp=Win, Ctrl, Shift, A
 PinWindow=
 PinApp=
 UnpinWindow=
@@ -201,32 +201,32 @@ The following shortcuts are available:
 
 | Description                                                                    | Keyboard Shortcut                            |
 | ------------------------------------------------------------------------------ | -------------------------------------------- |
-| Switch to desktop by number                                                    | Left Alt + (0-9)                             |
-| Switch to next/previous desktop                                                | Left Alt + (Left/Right Arrow)                |
-| Move the current window to desktop by number                                   | Left Alt + Shift + Ctrl + (0-9)              |
-| Move the current window to next/previous desktop                               | Left Alt + Shift + Ctrl + (Left/Right Arrow) |
-| Move the current window to desktop by number and switch to it                  | Left Alt + Shift + (0-9)                     |
-| Move the current window to next/previous desktop and switch to it              | Left Alt + Shift + (Left/Right Arrow)        |
+| Switch to desktop by number                                                    | Win + Ctrl + (0-9)                           |
+| Switch to next/previous desktop                                                | Win + Ctrl + (Left/Right Arrow)              |
+| Move the current window to desktop by number                                   | Disabled                                     |
+| Move the current window to next/previous desktop                               | Disabled                                     |
+| Move the current window to desktop by number and switch to it                  | Win + Ctrl + Shift + (0-9)                   |
+| Move the current window to next/previous desktop and switch to it              | Win + Ctrl + Shift + (Left/Right Arrow)      |
 | Switch to desktop by number (desktops 11-20)                                   | Disabled                                     |
 | Move the current window to desktop by number (desktops 11-20)                  | Disabled                                     |
 | Move the current window to desktop by number and switch to it (desktops 11-20) | Disabled                                     |
-| Pin/unpin (toggle) current window                                       | Left Alt + Shift + Ctrl + Q                  |
-| Pin/unpin (toggle) current app                                          | Left Alt + Shift + Ctrl + A                  |
+| Pin/unpin (toggle) current window                                       | Win + Ctrl + Shift + Q                       |
+| Pin/unpin (toggle) current app                                          | Win + Ctrl + Shift + A                       |
 | Pin current window to all desktops                                             | Disabled                                     |
 | Pin current app to all desktops                                                | Disabled                                     |
 | Unpin current window from all desktops                                         | Disabled                                     |
 | Unpin current app from all desktops                                            | Disabled                                     |
-| Open Desktop Manager                                                           | Left Alt + (key under Esc)                   |
+| Open Desktop Manager                                                           | Win + Ctrl + (key under Esc)                 |
 
 #### Behavior with custom config
 
 With this config:
 
 [KeyboardShortcutsModifiers]
-SwitchDesktop=LWin
-MoveWindowToDesktop=
-MoveWindowAndSwitchToDesktop=LWin, Alt
-NextTenDesktops=LShift
+SwitchDesktop=LAlt
+MoveWindowToDesktop=LAlt, Shift
+MoveWindowAndSwitchToDesktop=LAlt, Ctrl, Shift
+NextTenDesktops=Win
 
 [KeyboardShortcutsIdentifiers]
 PreviousDesktop=PgUp
@@ -244,25 +244,24 @@ OpenDesktopManager=
 
 The following shortcuts are available:
 
-| Description                                                                    | Keyboard Shortcut                    |
-| ------------------------------------------------------------------------------ | ------------------------------------ |
-| Switch to desktop by number                                                    | Left Win + (0-9)                     |
-| Switch to next/previous desktop                                                | Left Win + (Page Up/Page Down)       |
-| Move the current window to desktop by number                                   | Disabled                             |
-| Move the current window to next/previous desktop                               | Disabled                             |
-| Move the current window to desktop by number and switch to it                  | Left Win + Alt + (0-9)               |
-| Move the current window to next/previous desktop and switch to it              | Left Win + Alt + (Page Up/Page Down) |
-| Open Desktop Manager                                                           | Left Win + (key under Esc)           |
-| Switch to desktop by number (desktops 11-20)                                   | Left Win + Left Shift + (0-9)        |
-| Move the current window to desktop by number (desktops 11-20)                  | Disabled                             |
-| Move the current window to desktop by number and switch to it (desktops 11-20) | Left Win + Alt + Left Shift + (0-9)  |
-| Pin/unpin (toggle) current window                                       | Disabled                             |
-| Pin/unpin (toggle) current app                                          | Disabled                             |
-| Pin current window to all desktops                                             | Disabled                             |
-| Pin current app to all desktops                                                | Disabled                             |
-| Unpin current window from all desktops                                         | Disabled                             |
-| Unpin current app from all desktops                                            | Disabled                             |
-| Open Desktop Manager                                                           | Disabled                             |
+| Description                                                                    | Keyboard Shortcut                             |
+| ------------------------------------------------------------------------------ | --------------------------------------------- |
+| Switch to desktop by number                                                    | Left Alt + (0-9)                              |
+| Switch to next/previous desktop                                                | Left Alt + (Page Up/Page Down)                |
+| Move the current window to desktop by number                                   | Left Alt + Shift + (0-9)                      |
+| Move the current window to next/previous desktop                               | Left Alt + Shift + (Page Up/Page Down)        |
+| Move the current window to desktop by number and switch to it                  | Left Alt + Ctrl + Shift + (0-9)               |
+| Move the current window to next/previous desktop and switch to it              | Left Alt + Ctrl + Shift + (Page Up/Page Down) |
+| Switch to desktop by number (desktops 11-20)                                   | Left Alt + Win + (0-9)                        |
+| Move the current window to desktop by number (desktops 11-20)                  | Left Alt + Shift + Win (0-9)                  |
+| Move the current window to desktop by number and switch to it (desktops 11-20) | Left Alt + Ctrl + Shift + Win (0-9)           |
+| Pin/unpin (toggle) current window                                       | Disabled                                      |
+| Pin/unpin (toggle) current app                                          | Disabled                                      |
+| Pin current window to all desktops                                             | Disabled                                      |
+| Pin current app to all desktops                                                | Disabled                                      |
+| Unpin current window from all desktops                                         | Disabled                                      |
+| Unpin current app from all desktops                                            | Disabled                                      |
+| Open Desktop Manager                                                           | Disabled                                      |
 
 ### Mouse Shortcuts