Skip to content

Commit

Permalink
autostartup; ensure folder unique
Browse files Browse the repository at this point in the history
  • Loading branch information
potoo0 committed Mar 6, 2024
1 parent 4de0d6d commit b2cd127
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Libs/FileManager.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ GetAllFolder() {
DetectHiddenWindows DetectHiddenWindowsStateOld

; parse foler
folderMap := Map() ; ensure folder unique
for winId in windows {
winCls := WinGetClass("ahk_id " winId)
fileManager := ""
Expand All @@ -20,7 +21,12 @@ GetAllFolder() {

folders := fileManager.GetCurrentFolder(winId, true)
if (folders and folders.Length) {
allFolders.Push(folders*)
for folder in folders {
if (!folderMap.Has(folder)) {
allFolders.Push(folder)
folderMap.Set(folder, true)
}
}
}
}
return allFolders
Expand Down
19 changes: 19 additions & 0 deletions Libs/Settings.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; global config
#Include Config.ahk

; A_TrayMenu
SettingMenu := A_TrayMenu
SettingMenu.Insert("1&", "&AutoStartup Switch", onAutoStartupSwitch, "Radio")
SettingMenu.Add()

onAutoStartupSwitch(*) {
isAutoStartup := !CFG.GetConfig("AutoStartup", "Global")
CFG.UpdateConfig("AutoStartup", isAutoStartup, "Global")
autoStartupLnk := A_Startup "\QuickSwitch.lnk"
if (isAutoStartup and !FileExist(autoStartupLnk)) {
FileCreateShortcut(A_ScriptFullPath, autoStartupLnk, A_WorkingDir)
} else if (!isAutoStartup and FileExist(autoStartupLnk)) {
FileDelete(autoStartupLnk)
}
MsgBox(isAutoStartup ? "开机自动启动已允许" : "开机自动启动已禁止")
}
1 change: 1 addition & 0 deletions QuickSwitch.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ KeyHistory 0 ; disable key history
#Include Libs\Config.ahk
#Include Libs\FileDialog.ahk
#Include Libs\FolderSelector.ahk
#Include Libs\Settings.ahk

;_____________________________________________________________________________
;
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Modified based on [gepruts/QuickSwitch](https://github.com/gepruts/QuickSwitch):

1. Get path of active or all explorer tab
2. Fix menu close by escape/click-outside
3. Auto startup(TrayMenu)

### What does QuickSwitch do?

Expand Down

0 comments on commit b2cd127

Please sign in to comment.