| View previous topic :: View next topic |
| Author |
Message |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Fri Nov 19, 2004 6:50 pm Post subject: How to keep down memory usage |
|
|
After playing a bit with some windows on my screen because I had to wait for various tasks, I found out a way to really optimize your computer when using lots of windows. If you open for example Internet Explorer, it uses about 20 MB of memory. When you minimize the window, it will reduce to 7 MB. So far no news. But, when you restore the window's state, it stays on that 7 MB until you've visit 4 of 5 new websites. And the same counts for various of other programs. This means that if you are able to write a program which minimizes all windows which are not visible on the screen, you can gain a enormous amount of memory. I just tried to create a program which minimizes windows which are not active, but then you can only use on window at a time. Does anybody know a trick to get a list of all visible windows, so I can filter out all others and to test if my theory works?
Thanks...  _________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Fri Nov 19, 2004 7:49 pm Post subject: |
|
|
The simplest method I can think of:
| Code: |
list create,1
list winlist,1,I
rem Loop thru list using API call 'IsWindowVisible(HWND)'
list close,1
|
Maybe this will help. I don't use VDS 5 but this does work in 'C'. _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Sat Nov 20, 2004 10:37 am Post subject: |
|
|
| MSDN Library wrote: | Syntax
BOOL IsWindowVisible(HWND hWnd);
Parameters
hWnd
[in] Handle to the window to test.
Return Value
If the specified window, its parent window, its parent's parent window, and so forth, have the WS_VISIBLE style, the return value is nonzero. Otherwise, the return value is zero.
Because the return value specifies whether the window has the WS_VISIBLE style, it may be nonzero even if the window is totally obscured by other windows. |
I'm afraid it won't work this way... Does anybody maybe know another API code to see which windows are visible on the screen, and which not?
Garrett: the code you linked to does only give a list of all windows which are in the taskbar, not the ones which are visible, but thank you just the same...  _________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Nov 20, 2004 7:01 pm Post subject: |
|
|
Ya might try @winpos([window], S) in your winlist loop.
It returns the window status (1 = normal; 2 = iconized; 3 = maximized).
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sat Nov 20, 2004 7:07 pm Post subject: |
|
|
| Skit3000 wrote: | Garrett: the code you linked to does only give a list of all windows which are in the taskbar, not the ones which are visible, but thank you just the same...  |
Sure, the whole code, but if you walk through the code, you'll see that
one can easily get what they need out of this. As many have noted, you
can use the @winpos([window], S) to check the status of each and every
window.
-Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Sat Nov 20, 2004 7:35 pm Post subject: |
|
|
Garrett and Mac, sorry if I was unclear, but I want to get a list of all windows which aren't (partially) visible on screen. The API function Bill mentioned does work, but unfortunately not with all programs.
What I am trying to do with this list, is to minimize all programs which the user can't see while he is working. This should reduce the memory Windows gives these programs, so that the others have more to run with.  _________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Nov 20, 2004 7:44 pm Post subject: |
|
|
Skit, the only way I can think of to do that is to scan the screen
xy in 10-15 pixel increments and use @winatpoint() to see what
is actually visible.
Actually ya could scan screen x in much larger increments
because windows are seldom less than 100 pixels wide.
Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Nov 20, 2004 7:50 pm Post subject: |
|
|
BTW, you prolly need to keep the x scan small too because
there may only be 10-15 pixels of an overlapped window visible.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Sat Nov 20, 2004 8:01 pm Post subject: |
|
|
This is the code I came up with. It gets about all window handles on the screen, but I don't know how to get the parent of these handles. I tried it with @window(<handle>,handle), but that doesn't work on programs like IE and Notepad...
| Code: | list create,1,sorted
%x = 1
repeat
%y = 1
repeat
%%handle = @winatpoint(%x,%y)
%%owner = @window(%%handle,owner)
if @not(@null(%%owner))
%%title = @wintext(%%owner)
else
%%title =
end
list add,1,Handle: %%handle@tab()Owner: %%owner@tab()Titletext: %%title
%y = @sum(%y,10)
until @greater(%y,@sysinfo(screenheight))
%x = @sum(%x,10)
until @greater(%x,@sysinfo(screenwidth))
info Done...@cr()@cr()@text(1)
list close,1 |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Sat Nov 20, 2004 8:48 pm Post subject: |
|
|
My spy tool ( http://www.vdsworld.com/forum/viewtopic.php?t=450 )
uses:
@window(@winatpoint(%x,%y),OWNER)
but it doesn't show a parent on everything either.
Ya can prolly assume those that show no parent aren't
child windows anyway...
Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
|