Skip to content
This repository has been archived by the owner on Dec 23, 2018. It is now read-only.

Commit

Permalink
Merge pull request #30 from sdias/release-0.10.0
Browse files Browse the repository at this point in the history
Release 0.10.0
  • Loading branch information
sdias authored Feb 26, 2017
2 parents ed64650 + 567a3a4 commit 1180cff
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 75 deletions.
73 changes: 36 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,18 @@ Here are some examples with different configs:
With this config:
<pre>
[KeyboardShortcutsModifiers]
SwitchDesktop=LAlt
MoveWindowToDesktop=LAlt, Shift, Ctrl
MoveWindowAndSwitchToDesktop=LAlt, Shift
SwitchDesktop=Win, Ctrl
MoveWindowToDesktop=
MoveWindowAndSwitchToDesktop=Win, Ctrl, Shift
NextTenDesktops=

[KeyboardShortcutsIdentifiers]
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=
Expand All @@ -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 <u>window</u> | Left Alt + Shift + Ctrl + Q |
| Pin/unpin (toggle) current <u>app</u> | Left Alt + Shift + Ctrl + A |
| Pin/unpin (toggle) current <u>window</u> | Win + Ctrl + Shift + Q |
| Pin/unpin (toggle) current <u>app</u> | 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:
<pre>
[KeyboardShortcutsModifiers]
SwitchDesktop=LWin
MoveWindowToDesktop=
MoveWindowAndSwitchToDesktop=LWin, Alt
NextTenDesktops=LShift
SwitchDesktop=LAlt
MoveWindowToDesktop=LAlt, Shift
MoveWindowAndSwitchToDesktop=LAlt, Ctrl, Shift
NextTenDesktops=Win

[KeyboardShortcutsIdentifiers]
PreviousDesktop=PgUp
Expand All @@ -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 <u>window</u> | Disabled |
| Pin/unpin (toggle) current <u>app</u> | 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 <u>window</u> | Disabled |
| Pin/unpin (toggle) current <u>app</u> | 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

Expand Down
10 changes: 5 additions & 5 deletions settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ TaskbarScrollSwitching=1
UseNativePrevNextDesktopSwitchingIfConflicting=0

[KeyboardShortcutsModifiers]
SwitchDesktop=LAlt
MoveWindowToDesktop=LAlt, Shift, Ctrl
MoveWindowAndSwitchToDesktop=LAlt, Shift
SwitchDesktop=Win, Ctrl
MoveWindowToDesktop=
MoveWindowAndSwitchToDesktop=Win, Ctrl, Shift
NextTenDesktops=

[KeyboardShortcutsIdentifiers]
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=
Expand Down
121 changes: 88 additions & 33 deletions virtual-desktop-enhancer.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
; ======================================================================
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -360,7 +395,7 @@ _GetNumberOfDesktops() {
}

_MoveCurrentWindowToDesktop(n:=1) {
activeHwnd := _GetCurrentWindow()
activeHwnd := _GetCurrentWindowID()
DllCall(MoveWindowToDesktopNumberProc, UInt, activeHwnd, UInt, n-1)
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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.")
}

0 comments on commit 1180cff

Please sign in to comment.