https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setforegroundwindow

"The system restricts which processes can set the foreground window. A 
process can set the foreground window only if one of the following 
conditions is true:

   - The process is the foreground process.
   - The process was started by the foreground process.
   - The process received the last input event.
   - There is no foreground process.
   - The process is being debugged.
   - The foreground process is not a Modern Application or the Start Screen.
   - The foreground is not locked (see LockSetForegroundWindow 
   
<https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-locksetforegroundwindow>
   ).
   - The foreground lock time-out has expired (see 
   *SPI_GETFOREGROUNDLOCKTIMEOUT* in SystemParametersInfo 
   
<https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-systemparametersinfoa>
   ).
   - No menus are active.

An application cannot force a window to the foreground while the user is 
working with another window. Instead, Windows flashes the taskbar button of 
the window to notify the user."

https://stackoverflow.com/questions/19136365/win32-setforegroundwindow-not-working-all-the-time

This is more of a Windows API question than a Golang question, so you might 
do better to direct your questions to a Windows forum. The second link 
above does describe a workaround involving AttachThreadInput. I'm not sure 
if w32 has that function mapped or not - if not, you can 
try https://pkg.go.dev/github.com/xpzed/win32

Good luck!

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d7ebe7a4-c5c1-4164-a19e-4b4a614d3eaan%40googlegroups.com.

Reply via email to