Getting the desktop windows
Getting the desktop windows
I want to get the list of currently opened windows on the desktop. I am doing it with EnumWindows_(). The problem is that, instead of returning handles to the windows that I can see on the desktop, I get the handle of hundreds of windows. I guess that they are invisible windows or something created by the OS for different purposes. How can I get JUST the real Windows? I mean, I just want to get the windows that are listed on the taskbar.
==Jedive==
MacBook Core Duo 2Ghz, 2GB, Intel GMA950, Leopard
Celeron M 1.5, 512MB, Intel 915GM, WinXP/DX9, Ubuntu
MacBook Core Duo 2Ghz, 2GB, Intel GMA950, Leopard
Celeron M 1.5, 512MB, Intel 915GM, WinXP/DX9, Ubuntu
-
- Addict
- Posts: 1027
- Joined: Sun May 15, 2005 5:15 am
- Location: Australia
- Contact:
not sure if this will work, but you can try it:
and i emphasize the point that im not sure if it will work, this was wat i came up with from a quick search in my winapi help file!!! 
Code: Select all
procedure enumwindows(hwnd, lparam)
winplace.WINDOWPLACEMENT
getwindowplacement_(hwnd, @winplace)
if winplace\showCmd = #SW_HIDE
;do nothing
else
debug hwnd
endif
endprocedure
enumwindows_(@enumwindows(), 0)

Demonio Ardente
Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
Re: Getting the desktop windows
Code: Select all
Procedure GetDesktopWindows()
h=GetWindow_(GetDesktopWindow_(),#GW_CHILD)
Repeat
If IsWindowVisible_(h)=#True
c$=Space(999) : GetWindowText_(h,c$,999)
If c$<>""
Debug "Handle = "+Str(h)+", Caption = "+c$
EndIf
EndIf
h=GetWindow_(h,#GW_HWNDNEXT)
Until h=0
EndProcedure
GetDesktopWindows()
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Works good PB ...
I could not find a way to emulate the desktop button that minimizes all windows ... this seems to be that way.
But when I add a ShowWindow_() line to minimize all windows, it sometimes make a mess and explorer.exe burns the CPU until a kill it. I don't know exactly what is wrong there.
I could not find a way to emulate the desktop button that minimizes all windows ... this seems to be that way.
But when I add a ShowWindow_() line to minimize all windows, it sometimes make a mess and explorer.exe burns the CPU until a kill it. I don't know exactly what is wrong there.
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
> But when I add a ShowWindow_() line to minimize all windows, it sometimes
> make a mess and explorer.exe burns the CPU until a kill it.
I did a "Show Desktop" app like that once.
Do this:
Note: This might leave some windows still open -- I had to then parse them
all (with a loop like the above), and minimize them manually.
You could also do it like this, which should minimize all windows by simulating
the Windows+D key combination to show the Desktop:
> make a mess and explorer.exe burns the CPU until a kill it.
I did a "Show Desktop" app like that once.

Code: Select all
PostMessage_(FindWindow_("Shell_TrayWnd",0),#WM_COMMAND,419,0) ; 419 = #MIN_ALL
all (with a loop like the above), and minimize them manually.
You could also do it like this, which should minimize all windows by simulating
the Windows+D key combination to show the Desktop:
Code: Select all
keybd_event_(#VK_LWIN,0,0,0)
keybd_event_(#VK_D,0,0,0)
keybd_event_(#VK_D,0,#KEYEVENTF_KEYUP,0)
keybd_event_(#VK_LWIN,0,#KEYEVENTF_KEYUP,0)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
@PB ... I am a simpleton !!!
It so simple like this, and it works.
Thnx
It so simple like this, and it works.
Thnx
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
You might like to check the source of this little tool i made, it has a handy 'get all the opened windows' procedure. 
viewtopic.php?p=68261

viewtopic.php?p=68261
-
- Addict
- Posts: 1027
- Joined: Sun May 15, 2005 5:15 am
- Location: Australia
- Contact:
would this work:
i dont know if it will work...
Code: Select all
postmessage_(#hwnd_broadcast, #wm_command, #sc_minimize, 0)
Demonio Ardente
Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!