diff --git a/desktop_switcher.ahk b/desktop_switcher.ahk index a719ecd..afeb4a0 100644 --- a/desktop_switcher.ahk +++ b/desktop_switcher.ahk @@ -9,6 +9,9 @@ DesktopCount := 2 ; Windows starts with 2 desktops at boot CurrentDesktop := 1 ; Desktop count is 1-indexed (Microsoft numbers them this way) LastOpenedDesktop := 1 +DesktopMiniCount := -1 ; keep desktop mini count at script boot. +DesktopInitSwitchTarget := -1 ; switch desktop to target number at script boot. + ; DLL hVirtualDesktopAccessor := DllCall("LoadLibrary", "Str", A_ScriptDir . "\VirtualDesktopAccessor.dll", "Ptr") global IsWindowOnDesktopNumberProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "IsWindowOnDesktopNumber", "Ptr") @@ -19,6 +22,9 @@ SetKeyDelay, 75 mapDesktopsFromRegistry() OutputDebug, [loading] desktops: %DesktopCount% current: %CurrentDesktop% +initDesktopMiniCount() +initDesktopSwitchTargetNumber() + #Include %A_ScriptDir%\user_config.ahk return @@ -221,3 +227,22 @@ deleteVirtualDesktop() CurrentDesktop-- OutputDebug, [delete] desktops: %DesktopCount% current: %CurrentDesktop% } + +initDesktopMiniCount() +{ + global DeskTopMiniCount, DesktopCount, CurrentDesktop + i := DeskTopMiniCount - DesktopCount + while (i-- > 0){ + createVirtualDesktop() + OutputDebug, [initCount] DeskTopMiniCount: %DeskTopMiniCount% desktops: %DesktopCount% current: %CurrentDesktop% + } +} + +initDesktopSwitchTargetNumber() +{ + global DesktopInitSwitchTarget, DesktopCount, CurrentDesktop + if(DesktopInitSwitchTarget > 0 && CurrentDesktop != DesktopInitSwitchTarget){ + _switchDesktopToTarget(DesktopInitSwitchTarget > DesktopCount ? DesktopCount : DesktopInitSwitchTarget) + OutputDebug, [initTarget] DesktopInitSwitchTarget: %DesktopInitSwitchTarget% desktops: %DesktopCount% current: %CurrentDesktop% + } +} diff --git a/user_config.ahk b/user_config.ahk index 560df6a..c89194b 100644 --- a/user_config.ahk +++ b/user_config.ahk @@ -113,3 +113,9 @@ CapsLock & o::MoveCurrentWindowToDesktop(9) ; ^#Numpad7::MoveCurrentWindowToDesktop(7) ; ^#Numpad8::MoveCurrentWindowToDesktop(8) ; ^#Numpad9::MoveCurrentWindowToDesktop(9) + +; Vim-like key config . If use this, suggest config DesktopMiniCount=4, DesktopInitSwitchTarget as well +; ^#j::switchDesktopByNumber(1) +; ^#k::switchDesktopByNumber(2) +; ^#l::switchDesktopByNumber(3) +; ^#i::switchDesktopByNumber(4)