-
Notifications
You must be signed in to change notification settings - Fork 1
/
切换游戏.ahk
157 lines (128 loc) · 2.05 KB
/
切换游戏.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
#Include 显示通知.ahk
#IfWinActive,ahk_class D3 Main Window Class
v_changeGame:=1
~+1::
{
setGame(1)
}
return
~+2::
{
setGame(2)
}
return
~+3::
{
setGame(3)
}
return
~1::
{
changeGame(1)
}
return
~2::
{
changeGame(2)
}
return
~3::
{
changeGame(3)
}
return
~4::
{
showMsg("加载PID文件")
loadFIle()
}
return
~5::
{
showMsg("删除PID文件")
v_game1:=0
v_game2:=0
v_game3:=0
FileDelete, gameId1.txt
FileDelete, gameId2.txt
FileDelete, gameId3.txt
}
return
~6::
{
v_changeGame:=!v_changeGame
if(v_changeGame = 1){
showMsg("切换游戏 开")
}else{
showMsg("切换游戏 关")
}
}
return
v_game1:=0
v_game2:=0
v_game3:=0
changeGame(index){
global v_game1
global v_game2
global v_game3
global v_changeGame
if(v_changeGame = 0){
return
}
v_current_game_pid:=0
if(index = 1){
v_current_game_pid:=v_game1
}else if (index = 2){
v_current_game_pid:=v_game2
} else if (index = 3){
v_current_game_pid:=v_game3
}
if(v_current_game_pid){
showMsg("跳转游戏" index)
WinActivate, ahk_id %v_current_game_pid%
}else{
WinGet, v_current_game_pid, ID, A
FileDelete, gameId%index%.txt
FileAppend, %v_current_game_pid%, gameId%index%.txt
loadFIle()
}
}
loadFIle(){
global v_game1
global v_game2
global v_game3
if FileExist("gameId1.txt"){
FileReadLine, line, gameId1.txt,1
v_game1:=line
showMsg("加载1 " v_game1, 100)
Sleep, 50
}
if FileExist("gameId2.txt"){
FileReadLine, line, gameId2.txt,1
v_game2:=line
showMsg("加载2 " v_game2, 200)
Sleep, 50
}
if FileExist("gameId3.txt"){
FileReadLine, line, gameId3.txt,1
v_game3:=line
showMsg("加载3 " v_game3, 300)
Sleep, 50
}
}
setGame(index){
global v_game1
global v_game2
global v_game3
showMsg("设置游戏" index)
WinGet, v_current_game_pid, ID, A
if(index = 1){
v_game1:=v_current_game_pid
}else if (index = 2){
v_game2:=v_current_game_pid
} else if (index = 3){
v_game3:=v_current_game_pid
}
FileDelete, gameId%index%.txt
FileAppend, %v_current_game_pid%, gameId%index%.txt
}