Jump to content
Sign in to follow this  
JusGellin

List all Windows that have WinSetOnTop set

Recommended Posts

JusGellin

I'm making an application that can set the active window to be on top or not using hotkeys. I know how to do this part.

But how can I list all the windows that have been set to always be on time? I want to be able list all of them and then put them back to normal mode using my code. Thanks

Share this post


Link to post
Share on other sites
covaks

Use GetWindowLong to get extended styles. Then go through with WinList and see which ones have $WS_EX_TOPMOST set. The help for WinList already does this almost, we just have to add the check for the extended style

#include <WinAPI.au3>
#include <Misc.au3>

$aWin = WinList()
$iExStyles = 0

For $x = 1 to $aWin[0][0]
    $iExStyles = _WinAPI_GetWindowLong($aWin[$x][1],$GWL_EXSTYLE)
    If $aWin[$x][0] <> "" AND IsVisible($aWin[$x][1]) Then
        If BitAND($iExStyles,$WS_EX_TOPMOST) Then
            msgbox(1,"",$aWin[$x][0] & " is Topmost")
        EndIf
    EndIf
Next
    
Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf

EndFunc

Share this post


Link to post
Share on other sites
JusGellin

Fantastic!! It works great. How did you know how to do this? Did you know this already or just know where to look?

Thanks so very much, I really appreciate it.

Share this post


Link to post
Share on other sites
covaks

Get familiar with the Windows API. It can be confusing at first, but once you figure out the basic concepts you can find some neato stuff. A lot of autoit functions are wrappers for these. And there's a bunch of _WinAPI functions in the help. ->

http://msdn2.microsoft.com/en-us/library/a...688(VS.85).aspx

http://msdn2.microsoft.com/en-us/library/a...686(VS.85).aspx

Share this post


Link to post
Share on other sites
JusGellin

Thanks for the encouragement and tips. This is really good stuff. I'm going to look into this.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.