-
Notifications
You must be signed in to change notification settings - Fork 9
/
set.ahk
247 lines (192 loc) · 7.25 KB
/
set.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
;@Ahk2Exe-SetMainIcon %A_ScriptDir%\Icons\set.ico
/***********************************************************************************
Copyright:HX
Author: kzf
Date:2022-07-30
Description:设置
History:
2022-07-30:init
*/
;开头设置
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
#Persistent
#include <log4ahk>
#include <json>
log.is_log_open := false
run_as_admin()
;全局变量
global g_json_path := ""
global g_config := ""
;加载配置
g_json_path := A_ScriptDir . "/config/settings.json"
g_config := {}
if(!loadconfig(g_config))
{
MsgBox,% "Load config" g_json_path " failed! will exit!!"
ExitApp
}
;UI
Gui, Add, Text, xm, 打开搜索框:
Gui, Add, Edit, vkey_open_search_box section x+75 w80,% g_config.key_open_search_box
Gui, Add, Text, xm, 发送文件:
Gui, Add, Edit, vkey_send xs+0 yp+0 w80,% g_config.key_send
Gui, Add, Text, xm, 编辑当前指令:
Gui, Add, Edit, vkey_edit_now xs+0 yp+0 w80,% g_config.key_edit_now
Gui, Add, Text, xm, 增加一条指令:
Gui, Add, Edit, vkey_edit_new xs+0 yp+0 w80,% g_config.key_edit_new
Gui, Add, Text, xm, 打开命令添加界面:
Gui, Add, Edit, vkey_open_editor xs+0 yp+0 w80,% g_config.key_open_editor
Gui, Add, Text, xm, hook模式快捷键:
Gui, Add, Edit, vhook_open xs+0 yp+0 w80,% g_config.hook_open
;宽度
Gui, Add, Text, xm, 搜索框宽度:
Gui, Add, Edit, vwin_w xs+0 yp+0 w80,% g_config.win_w
Gui, Add, Text, xm, 搜索框背景颜色:
Gui, Add, Edit, vwin_search_box_back_color xs+0 yp+0 w80,% g_config.win_search_box_back_color
Gui, Add, Text, xm, 搜索框字体颜色:
Gui, Add, Edit, vwin_search_box_text_color xs+0 yp+0 w80,% g_config.win_search_box_text_color
Gui, Add, Text, xm, 搜索框字体大小:
Gui, Add, Edit, vwin_search_box_font_size xs+0 yp+0 w80,% g_config.win_search_box_font_size
Gui, Add, Text, xm, 列表背景颜色:
Gui, Add, Edit, vwin_list_back_color xs+0 yp+0 w80,% g_config.win_list_back_color
Gui, Add, Text, xm, 列表字体颜色:
Gui, Add, Edit, vwin_list_text_color xs+0 yp+0 w80,% g_config.win_list_text_color
Gui, Add, Text, xm, 列表焦点背景颜色:
Gui, Add, Edit, vwin_list_focus_back_color xs+0 yp+0 w80,% g_config.win_list_focus_back_color
Gui, Add, Text, xm, 列表焦点字体颜色:
Gui, Add, Edit, vwin_list_focus_text_color xs+0 yp+0 w80,% g_config.win_list_focus_text_color
Gui, Add, Text, xm, 列表字体大小:
Gui, Add, Edit, vwin_list_font_size xs+0 yp+0 w80,% g_config.win_list_font_size
Gui, Add, Text, xm, 列表高度:
Gui, Add, Edit, vwin_list_height xs+0 yp+0 w80,% g_config.win_list_height
Gui, Add, Text, xm, 预览背景颜色
Gui, Add, Edit, vtooltip_back_color xs+0 yp+0 w80,% g_config.tooltip_back_color
Gui, Add, Text, xm, 预览字体颜色
Gui, Add, Edit, vtooltip_text_color xs+0 yp+0 w80,% g_config.tooltip_text_color
Gui, Add, Text, xm, 预览字体大小
Gui, Add, Edit, vtooltip_font_size xs+0 yp+0 w80,% g_config.tooltip_font_size
Gui, Add, Text, xm, 是否预览随机颜色[0/1]
Gui, Add, Edit, vtooltip_random xs+0 yp+0 w80,% g_config.tooltip_random
Gui, Add, Text, xm, 窗口透明度
Gui, Add, Edit, vwin_trans xs+0 yp+0 w80,% g_config.win_trans
Gui, Add, Text, xm, 是否自动切换为英文[0/1]
Gui, Add, Edit, vauto_english xs+0 yp+0 w80,% g_config.auto_english
Gui, Add, Text, xm, 是否提示帮助信息[0/1]
Gui, Add, Edit, vtooltip_help xs+0 yp+0 w80,% g_config.tooltip_help
Gui, Add, Text, xm, python解释器路径
Gui, Add, Edit, vpython_path xs+0 yp+0 w160,% g_config.python_path
Gui, Add, Text, xm, 是否显示LOGO[0/1]
Gui, Add, Edit, vis_show_log xs+0 yp+0 w160,% g_config.is_show_logo
Gui, Add, Link, xm, 查询按键 <a href="https://www.autoahk.com/help/autohotkey/zh-cn/docs/Hotkeys.htm">按键列表</a>
Gui, Add, Button, xm gsetting default, 设置
Gui, Add, Button, x+10 greset, 重置
Gui Color, 0xC0C0C0
Gui, Show, autosize, setting
Gui, +AlwaysOnTop +hWndhMainWnd -DPIScale
return
GuiClose:
ExitApp
return
setting:
Gui, Submit,NoHide ; 保存用户的输入到每个控件的关联变量中.
g_config.key_open_search_box := key_open_search_box
g_config.key_edit_now := key_edit_now
g_config.key_edit_new := key_edit_new
g_config.key_open_editor := key_open_editor
g_config.hook_open := hook_open
g_config.win_w := win_w
g_config.win_search_box_back_color := win_search_box_back_color
g_config.win_search_box_text_color := win_search_box_text_color
g_config.win_search_box_font_size := win_search_box_font_size
g_config.win_list_back_color := win_list_back_color
g_config.win_list_text_color := win_list_text_color
g_config.win_list_focus_back_color := win_list_focus_back_color
g_config.win_list_focus_text_color := win_list_focus_text_color
g_config.win_list_font_size := win_list_font_size
g_config.win_list_height := win_list_height
g_config.tooltip_back_color := tooltip_back_color
g_config.tooltip_text_color := tooltip_text_color
g_config.tooltip_font_size := tooltip_font_size
g_config.tooltip_random := tooltip_random
g_config.auto_english := auto_english
g_config.tooltip_help := tooltip_help
g_config.win_trans := win_trans
g_config.python_path := python_path
g_config.is_show_logo := is_show_logo
saveconfig(g_config)
log.info(g_config)
save_script()
return
reset:
GuiControl,, key_open_search_box , +enter
GuiControl,, key_send , ~$^enter
GuiControl,, key_edit_now, ~$^e
GuiControl,, key_edit_now, ~$^d
GuiControl,, key_open_editor , ~$!c
GuiControl,, hook_open , +Space
GuiControl,, win_w , 600
GuiControl,, win_search_box_back_color , 1d1d1d
GuiControl,, win_search_box_text_color , 999999
GuiControl,, win_search_box_font_size, 16
GuiControl,, win_list_back_color , 1d1d1d
GuiControl,, win_list_text_color , 999999
GuiControl,, win_list_focus_back_color , 0x313131
GuiControl,, win_list_focus_text_color , 0x959595
GuiControl,, win_list_font_size, 14
GuiControl,, win_list_height, 30
GuiControl,, tooltip_back_color , 1d1d1d
GuiControl,, tooltip_text_color , 999999
GuiControl,, tooltip_font_size , 15
GuiControl,, tooltip_random , 1
GuiControl,, auto_english , 1
GuiControl,, tooltip_help , 1
GuiControl,, win_trans , 222
GuiControl,, python_path, C:\Python310\python.exe
GuiControl,, is_show_logo, 1
Gosub, setting
return
;函数
run_as_admin()
{
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
try
{
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
}
loadconfig(ByRef config)
{
Global g_json_path
config := ""
FileRead, OutputVar,% g_json_path
config := json_toobj(outputvar)
log.info(config)
if(config == "")
return false
return true
}
saveconfig(config)
{
global g_json_path
str := json_fromobj(config)
FileDelete, % g_json_path
FileAppend,% str,% g_json_path
}
save_script()
{
if(A_IsCompiled)
run, %A_ScriptDir%/super-command.exe
else
run,% A_ScriptDir "\v1\AutoHotkey.exe " A_ScriptDir "\super-command.ahk"
}