@@ -10,7 +10,7 @@ import (
10
10
"github.com/lxn/win"
11
11
)
12
12
13
- //LogoutStatus logout status.
13
+ // LogoutStatus logout status.
14
14
type LogoutStatus int
15
15
16
16
const (
@@ -24,7 +24,7 @@ const (
24
24
ENTERING
25
25
)
26
26
27
- //Logout control Wow window status.
27
+ // Logout control Wow window status.
28
28
type Logout struct {
29
29
prevTime time.Time
30
30
subTime time.Duration
@@ -33,7 +33,7 @@ type Logout struct {
33
33
count int
34
34
}
35
35
36
- //Update should be invoke by period.
36
+ // Update should be invoke by period.
37
37
func (l * Logout ) Update () {
38
38
switch l .currentState {
39
39
case NORMAL :
@@ -131,7 +131,7 @@ func (l *Logout) enter() {
131
131
}
132
132
}
133
133
134
- //Reset should be invoke by reset status.
134
+ // Reset should be invoke by reset status.
135
135
func (l * Logout ) Reset () {
136
136
l .currentState = NORMAL
137
137
l .subTime = 0
@@ -174,12 +174,12 @@ func (l *Logout) logout() bool {
174
174
return true
175
175
}
176
176
177
- //IsValid check the windows is valid.
177
+ // IsValid check the windows is valid.
178
178
func (l * Logout ) IsValid () bool {
179
179
return win .IsWindowVisible (l .hwnd )
180
180
}
181
181
182
- //CheckWindow check the window if in the foreground and in focus.
182
+ // CheckWindow check the window if in the foreground and in focus.
183
183
func (l * Logout ) CheckWindow () bool {
184
184
// 检查窗口
185
185
if ! l .IsValid () {
@@ -197,18 +197,24 @@ func (l *Logout) CheckWindow() bool {
197
197
return true
198
198
}
199
199
200
- //TryGetWindow try focus window.
200
+ // TryGetWindow try focus window.
201
201
func (l * Logout ) TryGetWindow () bool {
202
202
focus := win .GetForegroundWindow ()
203
203
if focus != l .hwnd {
204
204
win .ShowWindow (l .hwnd , win .SW_NORMAL )
205
- randomSleep (11 , 22 )
205
+ randomSleep (500 , 1000 )
206
206
win .SetActiveWindow (l .hwnd )
207
- randomSleep (11 , 22 )
207
+ randomSleep (500 , 1000 )
208
208
win .BringWindowToTop (l .hwnd )
209
- randomSleep (11 , 22 )
209
+ randomSleep (500 , 1000 )
210
210
win .SetForegroundWindow (l .hwnd )
211
- randomSleep (11 , 22 )
211
+ randomSleep (500 , 1000 )
212
+ focus = win .GetForegroundWindow ()
213
+ if focus != l .hwnd {
214
+ log .Println ("当前窗口不是wow,小退过程中不要动游戏窗口" , focus , l .hwnd )
215
+ randomSleep (500 , 1000 )
216
+ return l .TryGetWindow ()
217
+ }
212
218
return false
213
219
}
214
220
return true
0 commit comments