Floppy Posted February 23, 2009 Share Posted February 23, 2009 (edited) Hi,I'm trying to get all opened windows.I tried this:$wins=WinList() For $i=1 To $wins[0][0] If $wins[$i][0]<>"" And BitAND(WinGetState($wins[$i][1]),4) Then MsgBox(0,"",$wins[$i][0]) NextThe problem is that it don't shows only the windows. It shows the Sidebar gadgets, the Tray icons, the Start menu...Is there a way to get only ALL windows?Thanks! Edited March 1, 2009 by FSoft Link to comment Share on other sites More sharing options...
Ascend4nt Posted February 23, 2009 Share Posted February 23, 2009 The problem is the definition of window in Windows doesn't always mean a 'visible' item. However, there are tricks.. _WinAPI_EnumWindowsTop() works pretty well, use WinGetTitle() with the handles it returns for the titles. I think you can achieve the same result as that with WinList by using this test: If _WinAPI_GetAncestor($wins[$i][1],3)==$wins[$i][1] And (BitAND(WinGetState($wins[$i][1]),2)==2) Then MsgBox(0,"",$wins[$i][0]) You'll still get a few Explorer 'unseen' window results like Progman and Shell_TrayWnd, so you might want to test for those, or just ignore all that have the same process ID as explorer.exe My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Floppy Posted February 23, 2009 Author Share Posted February 23, 2009 I get the same result. I can't ignore the windows that have the same PID of explorer.exe because if I open the My Documents folder, the script cannot "see" it. Any solution? Link to comment Share on other sites More sharing options...
Ascend4nt Posted February 23, 2009 Share Posted February 23, 2009 Open explorer windows would probably be listed as classname 'CabinetWClass', if you use WinList() then you can use _WinAPI_GetClassName() to get the class name. Basically it depends entirely on what you're looking for and why. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Floppy Posted February 23, 2009 Author Share Posted February 23, 2009 (edited) Open explorer windows would probably be listed as classname 'CabinetWClass', if you use WinList() then you can use _WinAPI_GetClassName() to get the class name.Basically it depends entirely on what you're looking for and why.I want to list in a combo-box all opened windows (listed in the taskbar).P.S.: Why in AutoIt isn't there a "directly" function to get only all windows? Edited February 23, 2009 by FSoft Link to comment Share on other sites More sharing options...
Robjong Posted February 23, 2009 Share Posted February 23, 2009 (edited) Hey,this almost gets its right$wins = WinList() For $i = 1 To $wins[0][0] If $wins[$i][0] <> "" And BitAND(WinGetState($wins[$i][1]), 2) Then ConsoleWrite($wins[$i][0] & @CRLF) Nextonly change i made wasBitAND(WinGetState($wins[$i][1]), 2) Edited February 23, 2009 by Robjong Link to comment Share on other sites More sharing options...
Floppy Posted February 23, 2009 Author Share Posted February 23, 2009 (edited) Hey, this almost gets its right $wins = WinList() For $i = 1 To $wins[0][0] If $wins[$i][0] <> "" And BitAND(WinGetState($wins[$i][1]), 2) Then ConsoleWrite($wins[$i][0] & @CRLF) Next only change i made was BitAND(WinGetState($wins[$i][1]), 2) I have the same problem!!! Here are the real opened windows: PowerEr, C:\Users\FSoft\Desktop\PowerEr\PowerEr.au3 - SciTE4AutoIt3, Get all windows - AutoIt Forums - Mozilla Firefox, Scrittura di lunedì 23 febbraio 2009 - Watchtower Library 2008 - Edizione italiana, Posta in arrivo - Windows Live Mail, Documento1 - Microsoft Word Here are the opened windows retrived by your script: Start PowerEr C:\Users\FSoft\Desktop\PowerEr\PowerEr.au3 - SciTE4AutoIt3 Get all windows - AutoIt Forums - Mozilla Firefox Calendario Misuratore CPU Orologio Note Meteo AppBar Bullet Windows Sidebar AMD:CCC-AEMCapturingWindow Scrittura di lunedì 23 febbraio 2009 - Watchtower Library 2008 - Edizione italiana Posta in arrivo - Windows Live Mail Documento1 - Microsoft Word Program Manager I need a script that gives me only the windows, not the Sidebar gadgets, the Start menu, etc... Edited February 23, 2009 by FSoft Link to comment Share on other sites More sharing options...
trancexx Posted February 23, 2009 Share Posted February 23, 2009 You don't know what window is. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Floppy Posted February 23, 2009 Author Share Posted February 23, 2009 You don't know what window is.Sorry, but I didn't understand the sense of your post Link to comment Share on other sites More sharing options...
Floppy Posted February 24, 2009 Author Share Posted February 24, 2009 Can anyone help me? Link to comment Share on other sites More sharing options...
BrettF Posted February 24, 2009 Share Posted February 24, 2009 Please google for what a window is, and remember only to bump your posts once in a 24 hour period. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Floppy Posted February 24, 2009 Author Share Posted February 24, 2009 Please google for what a window is, and remember only to bump your posts once in a 24 hour period.WINDOW: Section on computer screen: a rectangular frame on a computer screen in which images output by application programs can be displayed, moved around, or resized.I didn't understand what means your post. I know the meaning of window!I want only some help with my script... Link to comment Share on other sites More sharing options...
BrettF Posted February 24, 2009 Share Posted February 24, 2009 Well then you know what the side bar gadgets are don't you? Your script grabs almost all of the windows. So what exactly do you want? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Floppy Posted February 24, 2009 Author Share Posted February 24, 2009 (edited) Well then you know what the side bar gadgets are don't you?Your script grabs almost all of the windows. So what exactly do you want?Maybe I don't make myself clear...I want a script that lists in a combo-box ALL opened windows.In practice, I want all windows listed in the taksbar, in a combo-box. Edited February 24, 2009 by FSoft Link to comment Share on other sites More sharing options...
Authenticity Posted February 24, 2009 Share Posted February 24, 2009 Try this one: #include <Array.au3> #include <Constants.au3> #include <windowsConstants.au3> Dim $aWin = WinList(), $aWindows[1][1] Dim $hUser32 = DllOpen('user32.dll') Dim $iEx_Style, $iCounter = 0 For $i = 1 To $aWin[0][0] $iEx_Style = BitAND(GetWindowLong($aWin[$i][1], $GWL_EXSTYLE), $WS_EX_TOOLWINDOW) Local $iStyle = BitAND(WinGetState($aWin[$i][1]), 2) If $iEx_Style <> -1 And Not $iEx_Style And $iStyle Then ReDim $aWindows[$iCounter+1][1] $aWindows[$iCounter][0] = $aWin[$i][0] $iCounter += 1 EndIf Next _ArrayDisplay($aWindows) DllClose($hUser32) Func GetWindowLong($hWnd, $iIndex, $hUser = 'user32.dll') Local $Ret = DllCall($hUser, 'int', 'GetWindowLong', 'hwnd', $hWnd, 'int', $iIndex) If Not @error Then Return $Ret[0] Return SetError(-1, 0, -1) EndFunc Link to comment Share on other sites More sharing options...
Ascend4nt Posted February 24, 2009 Share Posted February 24, 2009 Authenticity, nice solution! Just one thought, this line can change: If $iEx_Style <> -1 And Not $iEx_Style And $iStyle Then to: If Not $iEx_Style And $iStyle Then as WS_EX_TOOLWINDOW is 0x80 (128), and BitAND()'ing it with -1 will result in 0x80 anyway, so if there is an error it will be set to 128 as if there was a WS_EX_TOOLWINDOW result.... but either way, the 'Not $iEx_Style' tests for a non-zero value so you're set. Definitely a neat technique to getting the 'alt-tabbable' windows! Kudos, Ascend4nt My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Authenticity Posted February 24, 2009 Share Posted February 24, 2009 (edited) Heh, Actually I wanted it to fail first in case of the returning -1 as the GetWindowLong SetError() call.Edit: ...but my poor math knowledge takes place again, BitAND(0x80, -1) = always 0x80.... Edited February 24, 2009 by Authenticity Link to comment Share on other sites More sharing options...
Kip Posted February 24, 2009 Share Posted February 24, 2009 Maybe I don't make myself clear...I want a script that lists in a combo-box ALL opened windows.Oh, you made yourself clear. (like three times)But you just can't see the difference between "ALL open windows" and windows showed on the taskbar. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Floppy Posted February 26, 2009 Author Share Posted February 26, 2009 (edited) Try this one: expandcollapse popup#include <Array.au3> #include <Constants.au3> #include <windowsConstants.au3> Dim $aWin = WinList(), $aWindows[1][1] Dim $hUser32 = DllOpen('user32.dll') Dim $iEx_Style, $iCounter = 0 For $i = 1 To $aWin[0][0] $iEx_Style = BitAND(GetWindowLong($aWin[$i][1], $GWL_EXSTYLE), $WS_EX_TOOLWINDOW) Local $iStyle = BitAND(WinGetState($aWin[$i][1]), 2) If $iEx_Style <> -1 And Not $iEx_Style And $iStyle Then ReDim $aWindows[$iCounter+1][1] $aWindows[$iCounter][0] = $aWin[$i][0] $iCounter += 1 EndIf Next _ArrayDisplay($aWindows) DllClose($hUser32) Func GetWindowLong($hWnd, $iIndex, $hUser = 'user32.dll') Local $Ret = DllCall($hUser, 'int', 'GetWindowLong', 'hwnd', $hWnd, 'int', $iIndex) If Not @error Then Return $Ret[0] Return SetError(-1, 0, -1) EndFuncoÝ÷ Ûú®¢×`åH$H=2TDXM1À4¦QQ`Å}÷ß}÷ßöÁºÒ!j÷azºk¡¹^8^±Êâ¦×hzÉ÷öÜ(®IèÁ«¢+Ø¥¹±Õ±ÐíÕ¥ ½¹ÍѹÑ̹ÔÌÐì(%¹±Õ±ÐíÕ¥ ½µ½ ½à¹ÔÌÐì(%¹±Õ±Ðí]¥¹A$¹ÔÌÐì(¥¹±Õ±ÐíÉÉä¹ÔÌÐì(¥¹±Õ±Ðí ½¹ÍѹÑ̹ÔÌÐì(¥¹±Õ±ÐíÝ¥¹½ÝÍ ½¹ÍѹÑ̹ÔÌÐì()¥´ÀÌØí]¥¸ô]¥¹1¥ÍÐ ¤°ÀÌØí]¥¹½ÝÍlÅulÅt)¥´ÀÌØí¡UÍÈÌÈô±±=Á¸ ÌäíÕÍÈÌȹ±°Ìäì¤)¥´ÀÌØí¥á}MÑå±°ÀÌØí¥ ½Õ¹ÑÈôÀ()U% ÉÑ ÅÕ½ÐíQÍÐÅÕ½Ðì°ÌÔÀ°ÈÔÀ¤)U% Ñɱ ÉÑ1° ÅÕ½ÐíAɽɴèÅÕ½Ðì°ÈÀ°ÐÔ°ÌÄÀ°ÈÀ¤(ÀÌØí½}½µ¼õU% Ñɱ ÉÑ ½µ¼ ÅÕ½ÐìÅÕ½Ðì°ÈÀ°ØÀ°ÌÄÀ°ÈÀ°ÁàÀÀÀ̤(ÀÌØíÑÍÐõU% Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½Ðí½¹±äÑÍÐÅÕ½Ðì°ÄÀÀ°ÄÔÀ¤)U%MÑMÑÑ ¤()]¡¥±Ä($ÀÌØí´õU%Ñ5Í ¤(%M±Ð(% ÍÀÌØí´ôÀÌØíU%}Y9Q} 1=M($%á¥Ð(% ÍÀÌØí´ôÀÌØíÑÍÐ($%½ÈÀÌØí¤ôÄQ¼ÀÌØí]¥¹lÁulÁt($$ÀÌØí¥á}MÑå±ô ¥Ñ9¡Ñ]¥¹½Ý1½¹ ÀÌØí]¥¹lÀÌØí¥ulÅt°ÀÌØí]1}aMQe1¤°ÀÌØí]M}a}Q==1]%9=¤($%1½°ÀÌØí¥MÑå±ô ¥Ñ9¡]¥¹ÑMÑÑ ÀÌØí]¥¹lÀÌØí¥ulÅt¤°È¤($%%ÀÌØí¥á}MÑå±±ÐìÐì´Ä¹9½ÐÀÌØí¥á}MÑå±¹ÀÌØí¥MÑå±Q¡¸(I¥´ÀÌØí]¥¹½ÝÍlÀÌØí¥ ½Õ¹ÑȬÅulÅt(ÀÌØí]¥¹½ÝÍlÀÌØí¥ ½Õ¹ÑÉulÁtôÀÌØí]¥¹lÀÌØí¥ulÁt(ÀÌØí¥ ½Õ¹ÑȬôÄ($%¹%($%9áÐ($$ÀÌØíÉÌõ}ÉÉåQ½MÑÉ¥¹ ÀÌØí]¥¹½ÝÌ°ÅÕ½ÐíðÅÕ½Ðì¤($%U% ÑɱMÑÑ ÀÌØí½}½µ¼°ÀÌØíÉ̤(($%±± ±½Í ÀÌØí¡UÍÈÌȤ(%¹M±Ð)]¹()Õ¹Ñ]¥¹½Ý1½¹ ÀÌØí¡]¹°ÀÌØí¥%¹à°ÀÌØí¡UÍÈôÌäíÕÍÈÌȹ±°Ìäì¤)1½°ÀÌØíIÐô±± ±° ÀÌØí¡UÍÈ°Ìäí¥¹ÐÌäì°ÌäíÑ]¥¹½Ý1½¹Ìäì°Ìäí¡Ý¹Ìäì°ÀÌØí¡]¹°Ìäí¥¹ÐÌäì°ÀÌØí¥%¹à¤)%9½ÐÉɽÈQ¡¸IÑÕɸÀÌØíIÑlÁt)IÑÕɸMÑÉÉ½È ´Ä°À°´Ä¤)¹Õ¹ Is there any error? Bye Edited February 26, 2009 by FSoft Link to comment Share on other sites More sharing options...
SpookMeister Posted February 26, 2009 Share Posted February 26, 2009 How is it not working? What is it not doing that you expect it to be doing? Is there an error code... or something in the scite console that might point to the error? [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
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