-
Notifications
You must be signed in to change notification settings - Fork 0
/
toolkit.ahk
107 lines (95 loc) · 1.9 KB
/
toolkit.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
; 将data中的{pet}替换为粘贴板的内容并运行
Open(data) {
position := InStr(data, "{Pet}")
if (position > 0) {
value := A_Clipboard
data := StrReplace(data, "{Pet}", value)
}
Run data
}
CopyOpen(data) {
Send "^c"
Sleep 100
Open(data)
}
ToTop() {
; 参数A指定活动窗口
ExStyle := WinGetExStyle('A')
WinSetAlwaysOnTop(-1, 'A')
if (ExStyle & 0x8) {
ToolTip("取消置顶")
} else {
ToolTip("窗口置顶")
}
SetTimer(ToolTip, -1000)
}
PetLock() {
global
if (!A_IsAdmin) {
MsgBox("以管理员身份运行时才能启用锁")
return
}
KeyWait("CapsLock")
if (_PetLock) {
ToolTip("禁用锁")
BlockInput("Off")
_PetLock := 0
} else {
ToolTip("启用锁")
BlockInput("On")
_PetLock := 1
}
SetTimer(ToolTip, -1000)
}
Config() {
Run A_ScriptDir "\petconfig.ini"
}
OpenFilePath() {
Run A_ScriptDir
}
/**
* 切换托盘图标的显示并显示提示
*/
HideTray() {
if A_IconHidden {
A_IconHidden := 0
IniWrite(1, ConfigPath, "Pet", "TrayVisible")
ToolTip("显示托盘图标")
; Menu,Tray,UnCheck,%Tray_Visible%
} else {
A_IconHidden := 1
IniWrite(0, ConfigPath, "Pet", "TrayVisible")
ToolTip("隐藏托盘图标")
; Menu,Tray,Check,%Tray_Visible%
}
SetTimer(ToolTip, -1000)
}
/**
* 重启应用
*/
ReloadPet() {
try
{
if A_IsCompiled
Run '"' A_ScriptFullPath '" /restart'
else
Run "`"" A_AhkPath "`"" " /restart " "`"" A_ScriptFullPath "`""
}
catch as e
{
MsgBox e.Message
Exit
}
ExitApp
}
ExitPet(data) {
ToolTip("关闭脚本")
Sleep(1000)
ToolTip
ExitApp(data)
}
ShowMenu() {
myMenu := A_TrayMenu
; myMenu.AddStandard()
myMenu.show()
}