akorx

List of "windows" opened and not minimized

15 posts in this topic

#1 ·  Posted (edited)

Hi my friends,

I try to find all the windows opened and not minimized, but it includes the taskbar of windows which is not a "normal" window... I use winlist() but maybe it's not the best solution, so I can use another one.

Have you got a solution to find ONLY all windows opened by "normal" programs (like winword, notepad, firefox, etc) and that are not minimized ?

PS : sorry for my bad english

Edited by akorx

AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites



You could use WinGetState on every returned window to check if they are minimized or hidden etc.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi MVPs,

I've already tested this solution but windows taskbar appears like the others programs, so it's seems not to be the best solution... another idea? or perhaps I don't use WinGetState() correctly?


AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

Hi MVPs,

Or perhaps I don't use WinGetState() correctly?

Don't know. You need to post your code.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

BTW: The name of my account is "water". MVPs is the group I belong to.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Ok, this could be an example :

$var = WinList()

For $i = 1 to $var[0][0]
   ; Only display visble windows that have a title
   If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then ; AND WinGetState($var[$i][0],16)<>16 Then
   ConsoleWrite( "Title=" & $var[$i][0] & " - " & "Handle=" & $var[$i][1] & @CRLF)
   EndIf
Next


Func IsVisible($handle)
If BitAnd( WinGetState($handle), 2 ) Then
Return 1
Else
Return 0
EndIf
EndFunc

AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

This displays all windows which are visible and not minimized. The Desktop still seems to be included.

$aWinList = WinList()

For $i = 1 To $aWinList[0][0]
    ; Only display visble windows that have a title
    If $aWinList[$i][0] <> "" And IsVisible($aWinList[$i][0], $aWinList[$i][1]) Then
        ConsoleWrite("Title=" & $aWinList[$i][0] & " - " & "Handle=" & $aWinList[$i][1] & @CRLF)
    EndIf
Next

Func IsVisible($sTitle, $hHandle)
    If $sTitle = "Program Manager" Then Return 0
    $iState = WinGetState($hHandle)
    If BitAND($iState, 2) = 2 And _ ; Visible
    BitAND($iState, 16) <> 16 Then ; Not minimized
        Return 1
    Else
        Return 0
    EndIf
EndFunc   ;==>IsVisible

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

 

This displays all windows which are visible and not minimized. The Desktop still seems to be included.

$aWinList = WinList()

For $i = 1 To $aWinList[0][0]
    ; Only display visble windows that have a title
    If $aWinList[$i][0] <> "" And IsVisible($aWinList[$i][0], $aWinList[$i][1]) Then
        ConsoleWrite("Title=" & $aWinList[$i][0] & " - " & "Handle=" & $aWinList[$i][1] & @CRLF)
    EndIf
Next

Func IsVisible($sTitle, $hHandle)
    If $sTitle = "Program Manager" Then Return 0
    $iState = WinGetState($hHandle)
    If BitAND($iState, 2) = 2 And _ ; Visible
    BitAND($iState, 16) <> 16 Then ; Not minimized
        Return 1
    Else
        Return 0
    EndIf
EndFunc   ;==>IsVisible

Nice work, but I've got this result :

>"C:Program Files (x86)AutoIt3SciTE..autoit3.exe" /ErrorStdOut "D:DocumentsAutoitWindowsGridwindows.au3"    

Title=Démarrer - Handle=0x000100AE

Title=D:DocumentsAutoitWindowsGridwindows.au3 - SciTE-Lite [2 of 2] - Handle=0x00930466

Title=Sans titre - Bloc-notes - Handle=0x002A02D6

Title=Sans nom 1 - LibreOffice Writer - Handle=0x008903E4

>Exit code: 0    Time: 0.09789

and Title=Démarrer - Handle=0x000100AE is not a program like the others ! another idea ?


AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

I get the same (but in english: Start). Looks like the Window name for the desktop.

When using Alt+Tab to loop through the windows, Desktop seems to be the window named "Start" or "Démarrer" in your case.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

So I could use a filter to reject "start" or "démarrer" but it's not nice and furthermore imagine I want to publish my program to people that speak another language that yours and mine, how will I do ?

Antoher idea?


AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

This >thread does the same. It excludes some windows by name or class.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Yes I see... but I think there is necessarily a better solution, but which, that the question !

Perhaps a way with another autoit function? or with a windows dll?


AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

This >thread does the same. It excludes some windows by name or class.

I was just going to say, that Class is what I've used in the past, just getting it to skip known classes for things like the Program Manager (Explorer, etc).


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

You can also try to skip windows having the $WS_EX_TOOLWINDOW style (it's just an idea, please do not hit me o:) )

#include <WinAPI.au3>
#include <WindowsConstants.au3>

$aWinList = WinList()

For $i = 1 To $aWinList[0][0]
    ; Only display visble windows that have a title
    ; If $aWinList[$i][0] <> "" Then
    If $aWinList[$i][0] <> "" And IsVisible($aWinList[$i][0], $aWinList[$i][1]) Then
        ConsoleWrite("Title=" & $aWinList[$i][0] & " - " & "Handle=" & $aWinList[$i][1] & @CRLF)
    EndIf
Next

Func IsVisible($sTitle, $hHandle)
    If BitAND( _WinAPI_GetWindowLong($hHandle, $GWL_EXSTYLE), $WS_EX_TOOLWINDOW) Then Return 0
    
    $iState = WinGetState($hHandle)
    If BitAND($iState, 2) = 2 And _ ; Visible
    BitAND($iState, 16) <> 16  Then ; Not minimized
        Return 1
    Else
        Return 0
    EndIf
EndFunc   ;==>IsVisibl
Edited by jguinch

Share this post


Link to post
Share on other sites

Oh nice work jguinch  :thumbsup:  ! Congratulations !

Thank you very much for your help !

Thank you to the others to for theirs answers too.

And finally thank for "Je suis Charlie" panel, I'm french...


AkorxMail akorx@yahoo.fr

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