Skip to content

Commit cad81ef

Browse files
committed
fix: fix OpenConfigFile when config file not existing
1 parent 04b8f27 commit cad81ef

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

winguake.ahk

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,8 @@
22
; Windows Quake - Multi-App Manager
33
; AutoHotkey v2 Script
44
; Author:Sean2077
5-
; Version:1.1
6-
; Changes:
7-
; 1.1 add tray menu: open config file, open script directory
8-
; 1.0 first release:
9-
; - supports toggle visibility of applications with hotkeys
10-
; - supports launching applications with hotkeys
11-
; - supports multi-window cycling activation with hotkeys
12-
; - supports configuration file (automatically reads the same filename ini file in the script directory)
13-
14-
VERSION := "1.1"
5+
6+
VERSION := "0.1.0"
157
SCRIPT_NAME := "winguake(v" . VERSION . ")"
168
SCRIPT_FULLNAME := "Windows Quake - Multi-App Manager (v" . VERSION . ")"
179

@@ -337,6 +329,16 @@ OpenScriptDirectory() {
337329
}
338330

339331
OpenConfigFile() {
332+
; 判断是否存在配置文件
333+
if !FileExist(configFile) {
334+
; 如果配置文件不存在,提示用户是否创建
335+
MsgBoxResult := MsgBox("Configuration file not found: " . configFile . "`nDo you want to create a new one?", "Configuration File Missing - " . SCRIPT_NAME, 4)
336+
if (MsgBoxResult = "No") {
337+
return ; 用户选择不创建,直接返回
338+
}
339+
; 创建新的配置文件
340+
FileAppend("", configFile)
341+
}
340342
Run(configFile)
341343
}
342344

@@ -615,9 +617,6 @@ ShowNotification(message) {
615617

616618
; ==================== 扩展功能 ====================
617619

618-
; 显示所有应用状态
619-
F12:: ShowAppStatus()
620-
621620
; 显示应用状态
622621
ShowAppStatus() {
623622
status := "Windows Quake - application status:`n`n"
@@ -680,7 +679,7 @@ CreateTrayMenu() {
680679
}
681680

682681
A_TrayMenu.Add() ; 分隔线
683-
A_TrayMenu.Add("Show app status (F12)", (*) => ShowAppStatus())
682+
A_TrayMenu.Add("Show app status", (*) => ShowAppStatus())
684683
A_TrayMenu.Add("Show current app config status", (*) => ShowCurrentConfig())
685684
A_TrayMenu.Add("Open directory of script and config file", (*) => OpenScriptDirectory())
686685
A_TrayMenu.Add("Open configuration file", (*) => OpenConfigFile())
@@ -689,7 +688,7 @@ CreateTrayMenu() {
689688
A_TrayMenu.Add("Exit", (*) => ExitApp())
690689

691690
; 设置默认菜单项
692-
A_TrayMenu.Default := "Show app status (F12)"
691+
A_TrayMenu.Default := "Show app status"
693692
}
694693

695694
; ==================== 帮助和管理 ====================

0 commit comments

Comments
 (0)