-
Notifications
You must be signed in to change notification settings - Fork 6
/
Sogou.ahk
68 lines (58 loc) · 1.27 KB
/
Sogou.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
#NoEnv
#SingleInstance
#Persistent
Running = 1
Shown = 0
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
DetectHiddenWindows, On
Menu, Tray, Icon, Sogou.ico
Menu, Tray, Tip, Sogou Proxy
Menu, Tray, NoStandard
Menu, Tray, Add, &Show, ShowWindow
Menu, Tray, Add, &Hide, HideWindow
Menu, Tray, Add
Menu, Tray, Add, E&xit, CloseWindow
OnExit, CloseWindow
while (Running > 0)
{
if (Shown > 0)
{
Run, proxy.exe,,UseErrorLevel, procPid
Gosub MenusShow
}
else
{
Run, proxy.exe,,Hide UseErrorLevel, procPid
Gosub MenusHide
}
WinWait, ahk_pid %procPid% ahk_class ConsoleWindowClass
WinGet activeWindow, ID, ahk_pid %procPid% ahk_class ConsoleWindowClass
Process, WaitClose, %procPid%
}
return
ShowWindow:
WinShow, ahk_id %activeWindow%
WinActivate, ahk_id %activeWindow%
Shown = 1
Gosub MenusShow
return
MenusShow:
Menu, Tray, Disable, &Show
Menu, Tray, Enable, &Hide
Menu, Tray, Default, &Hide
return
HideWindow:
Shown = 0
WinHide, ahk_id %activeWindow%
Gosub MenusHide
return
MenusHide:
Menu, Tray, Disable, &Hide
Menu, Tray, Enable, &Show
Menu, Tray, Default, &Show
return
CloseWindow:
Running = 0
Process, Close, %procPid%
ExitApp, 0
return