Skip to content

Commit

Permalink
examples: wowjump optimize for win11
Browse files Browse the repository at this point in the history
  • Loading branch information
whtiehack committed Jul 4, 2024
1 parent 54bf11d commit 0c6d682
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
10 changes: 7 additions & 3 deletions examples/wowjump/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,20 @@ func (l *Logout) TryGetWindow() bool {
if focus != l.hwnd {
win.ShowWindow(l.hwnd, win.SW_NORMAL)
randomSleep(500, 1000)
win.SetActiveWindow(l.hwnd)
randomSleep(500, 1000)
win.BringWindowToTop(l.hwnd)
randomSleep(500, 1000)
win.SetForegroundWindow(l.hwnd)
winapi.SwitchToWindow(l.hwnd, 1)
randomSleep(500, 1000)
focus = win.GetForegroundWindow()
if focus != l.hwnd {
log.Println("当前窗口不是wow,小退过程中不要动游戏窗口", focus, l.hwnd)
randomSleep(500, 1000)
hwnd := config.flashHwnd
if hwnd == 0 {
hwnd = focus
}
winapi.SwitchToWindow(hwnd, 1)
randomSleep(500, 1000)
return l.TryGetWindow()
}
return false
Expand Down
18 changes: 12 additions & 6 deletions winapi/user32.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ const (
)

var (
libuser32 = windows.NewLazySystemDLL("user32.dll")
findWindowEx = libuser32.NewProc("FindWindowExW")
getNextWindow = libuser32.NewProc("GetNextWindow ")
flashWindow = libuser32.NewProc("FlashWindow")
libuser32 = windows.NewLazySystemDLL("user32.dll")
findWindowEx = libuser32.NewProc("FindWindowExW")
getNextWindow = libuser32.NewProc("GetNextWindow ")
flashWindow = libuser32.NewProc("FlashWindow")
switchToWindow = libuser32.NewProc("SwitchToThisWindow")
)

//FindWindowEx user32 API FindWindowEx
// FindWindowEx user32 API FindWindowEx
func FindWindowEx(hWndParent win.HWND, hWndChildAfter win.HWND, lpClassName, lpWindowName *uint16) win.HWND {
ret, _, _ := findWindowEx.Call(
uintptr(hWndParent),
Expand All @@ -33,7 +34,7 @@ func FindWindowEx(hWndParent win.HWND, hWndChildAfter win.HWND, lpClassName, lpW
return win.HWND(ret)
}

//GetNextWindow user32 API GetNextWindow
// GetNextWindow user32 API GetNextWindow
func GetNextWindow(hWnd win.HWND, wCmd uintptr) win.HWND {
ret, _, _ := getNextWindow.Call(uintptr(hWnd), wCmd)
return win.HWND(ret)
Expand All @@ -43,3 +44,8 @@ func FlashWindow(hWnd win.HWND, bInvert int) int {
ret, _, _ := flashWindow.Call(uintptr(hWnd), uintptr(bInvert))
return int(ret)
}

func SwitchToWindow(hWnd win.HWND, bInvert int) int {
ret, _, _ := switchToWindow.Call(uintptr(hWnd), uintptr(bInvert))
return int(ret)
}

0 comments on commit 0c6d682

Please sign in to comment.