akorx Posted January 31, 2015 Posted January 31, 2015 (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 January 31, 2015 by akorx AkorxMail akorx@yahoo.fr
water Posted January 31, 2015 Posted January 31, 2015 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
akorx Posted January 31, 2015 Author Posted January 31, 2015 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
water Posted January 31, 2015 Posted January 31, 2015 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted January 31, 2015 Posted January 31, 2015 BTW: The name of my account is "water". MVPs is the group I belong to. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
akorx Posted January 31, 2015 Author Posted January 31, 2015 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
water Posted January 31, 2015 Posted January 31, 2015 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
akorx Posted January 31, 2015 Author Posted January 31, 2015 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
water Posted January 31, 2015 Posted January 31, 2015 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
akorx Posted January 31, 2015 Author Posted January 31, 2015 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
water Posted January 31, 2015 Posted January 31, 2015 This >thread does the same. It excludes some windows by name or class. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
akorx Posted January 31, 2015 Author Posted January 31, 2015 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
TheSaint Posted January 31, 2015 Posted January 31, 2015 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). 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)
jguinch Posted January 31, 2015 Posted January 31, 2015 (edited) You can also try to skip windows having the $WS_EX_TOOLWINDOW style (it's just an idea, please do not hit me ) #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 February 3, 2015 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
akorx Posted February 2, 2015 Author Posted February 2, 2015 Oh nice work jguinch ! 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now