@@ -686,6 +686,8 @@ RelativePath(Path) { ; Conver
686686
687687RunCommand (originCmd ) {
688688 UpdateRunCount()
689+ UpdateRank(originCmd)
690+ UpdateHistory(originCmd)
689691 MainGUI_Close()
690692 ParseArg()
691693 g_RUNTIME[" UseDisplay" ] := false
@@ -712,20 +714,6 @@ RunCommand(originCmd) {
712714 MsgBox (" Could not run command: " path " `n`nError message: " e.Message, g_TITLE, 48 )
713715 }
714716 }
715-
716- if (g_CONFIG[" SaveHistory" ]) {
717- g_HISTORYS.InsertAt(1 , originCmd " Arg=" g_RUNTIME[" Arg" ]) ; Adjust command history
718-
719- if (g_HISTORYS.Length > g_CONFIG[" HistoryLen" ]) {
720- g_HISTORYS.Pop()
721- }
722-
723- IniDelete (g_INI, g_SECTION[" HISTORY" ])
724- for index, element in g_HISTORYS
725- IniWrite (element, g_INI, g_SECTION[" HISTORY" ], index) ; Save command history
726- }
727-
728- g_CONFIG[" SmartRank" ] ? UpdateRank(originCmd) : ""
729717 return
730718}
731719
@@ -1016,6 +1004,9 @@ FuzzyMatch(Haystack, Needle) {
10161004
10171005; 更新命令权重函数
10181006UpdateRank (originCmd, showRank := false, inc := 1 ) {
1007+ if (g_CONFIG[" SmartRank" ] = false || originCmd = "" )
1008+ return
1009+
10191010 Sections := Array(g_SECTION[" DFTCMD" ],g_SECTION[" USERCMD" ],g_SECTION[" INDEX" ])
10201011
10211012 for index, section in Sections {
@@ -1056,6 +1047,22 @@ UpdateRunCount() {
10561047 g_LOG.Debug(" UpdateRunCount: RunCount update to..." g_CONFIG[" RunCount" ])
10571048}
10581049
1050+ UpdateHistory (originCmd ) {
1051+ if (g_CONFIG[" SaveHistory" ]) {
1052+ g_HISTORYS.InsertAt(1 , originCmd " Arg=" g_RUNTIME[" Arg" ]) ; Adjust command history
1053+
1054+ if (g_HISTORYS.Length > g_CONFIG[" HistoryLen" ]) {
1055+ g_HISTORYS.Pop()
1056+ }
1057+
1058+ IniDelete (g_INI, g_SECTION[" HISTORY" ])
1059+ for index, element in g_HISTORYS {
1060+ Section .= Index " =" element " `n"
1061+ }
1062+ IniWrite (Section , g_INI, g_SECTION[" HISTORY" ]) ; Save command history
1063+ }
1064+ }
1065+
10591066RankUp (* ) {
10601067 UpdateRank(g_RUNTIME[" CurrentCommand" ], true )
10611068}
@@ -1273,6 +1280,14 @@ UpdateStartMenu() {
12731280
12741281Reindex (* ) { ; Re-create Index section
12751282 IniDelete (g_INI, g_SECTION[" INDEX" ]) ; Clear old index section
1283+
1284+ ; Create ProgressGui at the start
1285+ ProgressGui := Gui (" -MinimizeBox +AlwaysOnTop" , " Reindex" )
1286+ ProgressGui.Add(" Text" , , " ReIndexing..." )
1287+ ProgressGui.Add(" Progress" , " vMyProgress w200" , 0 )
1288+ ProgressGui.Add(" Text" , " vMyFileName w200" , " Starting..." )
1289+ ProgressGui.Show()
1290+
12761291 for dirIndex, dir in StrSplit (g_CONFIG[" IndexDir" ], " ," ) {
12771292 searchPath := RegExReplace (AbsPath(dir), " \\+$" ) ; Remove trailing backslashes
12781293
@@ -1289,29 +1304,19 @@ Reindex(*) { ; Re-cre
12891304
12901305 IniWrite (" 1" , g_INI, g_SECTION[" INDEX" ], " File | " A_LoopFileFullPath ) ; Store file type for later use
12911306
1292- static ProgressGui := "" ; Static to persist GUI across loop iterations
1293- if (! ProgressGui) { ; Create GUI only once
1294- ProgressGui := Gui (" -MinimizeBox +AlwaysOnTop" , " Reindex" )
1295- ProgressGui.Add(" Text" , , " ReIndexing..." )
1296- ProgressGui.Add(" Progress" , " vMyProgress w200" , A_Index )
1297- ProgressGui.Add(" Text" , " vMyFileName w200" , A_LoopFileName )
1298- ProgressGui.Show()
1299- } else { ; Update existing GUI
1300- ProgressGui[" MyProgress" ].Value := A_Index
1301- ProgressGui[" MyFileName" ].Text := A_LoopFileName
1302- Sleep 30
1303- }
1307+ ; Update ProgressGui
1308+ ProgressGui[" MyProgress" ].Value := Mod (A_Index , 100 ) ; Simple progress animation
1309+ ProgressGui[" MyFileName" ].Text := A_LoopFileName
1310+ Sleep 30
13041311 }
13051312 }
1306- if (ProgressGui) { ; Destroy GUI after loop
1307- ProgressGui.Destroy()
1308- ProgressGui := ""
1309- }
13101313 }
13111314
13121315 ; Index Windows Store Apps
13131316 if (g_CONFIG[" IndexStoreApp" ]) {
13141317 try {
1318+ ProgressGui[" MyProgress" ].Value := 0
1319+ ProgressGui[" MyFileName" ].Text := " Indexing Store Apps..."
13151320 tempFile := A_Temp . " \ALTRun_StoreApps.csv"
13161321 RunWait ('powershell - Command " Get-StartApps | Select-Object Name, AppID | ConvertTo-Csv -NoTypeInformation" > " ' . tempFile . '" ', , " Hide" )
13171322 if FileExist (tempFile) {
@@ -1329,6 +1334,9 @@ Reindex(*) { ; Re-cre
13291334 appid := StrReplace (fields[2 ], '" ', '')
13301335 IniWrite (" 1" , g_INI, g_SECTION[" INDEX" ], " App | shell:AppsFolder\" . appid . " | " . name)
13311336 }
1337+ ProgressGui[" MyProgress" ].Value := A_Index
1338+ ProgressGui[" MyFileName" ].Text := name ? name : " Unknown App"
1339+ Sleep 10 ; Small delay to show progress
13321340 }
13331341 g_LOG.Debug(" Reindex: Indexed Windows Store apps successfully" )
13341342 } else {
@@ -1339,6 +1347,9 @@ Reindex(*) { ; Re-cre
13391347 }
13401348 }
13411349
1350+ ; Destroy ProgressGui at the end
1351+ ProgressGui.Destroy()
1352+
13421353 g_LOG.Debug(" Reindex: Indexing search database...OK" )
13431354 TrayTip (" ReIndex database finish successfully." , g_TITLE, 8 )
13441355 LoadCommands()
0 commit comments