diff options
Diffstat (limited to 'ui/raise.go')
-rw-r--r-- | ui/raise.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ui/raise.go b/ui/raise.go index f902546e..c4a45833 100644 --- a/ui/raise.go +++ b/ui/raise.go @@ -15,8 +15,6 @@ import ( "golang.org/x/sys/windows" ) -const wireguardUIClass = "WireGuard UI - MainWindow" - func raise(hwnd win.HWND) { if win.IsIconic(hwnd) { win.ShowWindow(hwnd, win.SW_RESTORE) @@ -30,10 +28,11 @@ func raise(hwnd win.HWND) { } func RaiseUI() bool { - hwnd := win.FindWindow(windows.StringToUTF16Ptr(wireguardUIClass), nil) + hwnd := win.FindWindow(windows.StringToUTF16Ptr(manageWindowWindowClass), nil) if hwnd == 0 { return false } + win.SendMessage(hwnd, selectCorrectTabMsg, 0, 0) raise(hwnd) return true } @@ -42,12 +41,13 @@ func WaitForRaiseUIThenQuit() { var handle win.HWINEVENTHOOK runtime.LockOSThread() handle, err := win.SetWinEventHook(win.EVENT_OBJECT_CREATE, win.EVENT_OBJECT_CREATE, 0, func(hWinEventHook win.HWINEVENTHOOK, event uint32, hwnd win.HWND, idObject int32, idChild int32, idEventThread uint32, dwmsEventTime uint32) uintptr { - class := make([]uint16, len(wireguardUIClass)+2) /* Plus 2, one for the null terminator, and one to see if this is only a prefix */ + class := make([]uint16, len(manageWindowWindowClass)+2) /* Plus 2, one for the null terminator, and one to see if this is only a prefix */ n, err := win.GetClassName(hwnd, &class[0], len(class)) - if err != nil || n != len(wireguardUIClass) || windows.UTF16ToString(class) != wireguardUIClass { + if err != nil || n != len(manageWindowWindowClass) || windows.UTF16ToString(class) != manageWindowWindowClass { return 0 } win.UnhookWinEvent(handle) + win.SendMessage(hwnd, selectCorrectTabMsg, 0, 0) raise(hwnd) os.Exit(0) return 0 |