Jump to content

WinSetOnTop - Taking Focus?


Go to solution Solved by Melba23,

Recommended Posts

I am writing another utility for my job that pulls data from a server and displays it on agent desktops.  It is critical that the information window remain on top of all other windows, including other windows that want to fight for "top position".

I placed my WinSetOnTop within my main loop.  It works nicely for me, 0 issues.  However, some of the agents have mentioned that since I deployed in beta, focus from their other application windows seems to get stolen.  Strange thing is it only seems to happen every once in a while.

Anyone have any ideas about this?

Link to comment
Share on other sites

  • Moderators

SlowCoder74,

Try using:

GUISetState(@SW_SHOWNOACTIVATE, $hWnd)
when you display your GUI - that way the focus is never taken. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators
  • Solution

SlowCoder74,

That GUISetState parameter just prevents the focus from bring stolen by the GUI when it appears - which should solve your problem. Of course you still need to use the TOPMOST style or WinSetOnTop to get your GUI to the top of the z-order - sorry for any confusion. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 1 year later...

I've experienced a situation with one of my scripts that seems very in line with the recommendations in this thread ... except that the pieces don't quite add up.

My script's GUI is created with $WS_POPUP and $WS_EX_TOPMOST ... which works in every instance when it runs amongst other programs.  It stays solidly on top ... EXCEPT when some embedded video is maximized from the browser.  The video takes over the screen and my GUI disappears behind it.  Even worse, the video overlays the taskbar, so I can't summon my GUI back.

What I've found, however, is that if I have another script running in background, that script can perform a WinSetOnTop($hMyGUI) and restore MyGUI to the top ... where is stays solidly, regardless of any click actions on the video ... even if the video is minimized and remaximized.

This leads me to believe that TopMost at creation is separate from the SetOnTop at runtime.

Is that the case?  And what is the prescribed GUISetState command for giving a GUI the best chance of staying on top following its initial display?  Should a script perform a SetOnTop() of itself?

Thanks in advance for clarifications.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...