forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to keep down memory usage

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Miscellaneous
View previous topic :: View next topic  
Author Message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Fri Nov 19, 2004 6:50 pm    Post subject: How to keep down memory usage Reply with quote

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... Smile

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Fri Nov 19, 2004 7:49 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Fri Nov 19, 2004 7:57 pm    Post subject: Reply with quote

Thanks Bill, I'll look into it... Smile
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Fri Nov 19, 2004 8:17 pm    Post subject: Reply with quote

http://garrett.vdsworld.com/vds5.html#GT-API_GetTaskBarWindows
_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Nov 20, 2004 10:37 am    Post subject: Reply with quote

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... Sad 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... Smile

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Nov 20, 2004 7:01 pm    Post subject: Reply with quote

Ya might try @winpos([window], S) in your winlist loop.

It returns the window status (1 = normal; 2 = iconized; 3 = maximized).

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Nov 20, 2004 7:07 pm    Post subject: Reply with quote

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... Smile


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
View user's profile Send private message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Nov 20, 2004 7:35 pm    Post subject: Reply with quote

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. Sad

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. Smile

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Nov 20, 2004 7:44 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Nov 20, 2004 7:48 pm    Post subject: Reply with quote

That sounds like a good solution... Smile Together with the code Garrett linked to, I should be able to create a list of non-visible windows... Smile
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Nov 20, 2004 7:50 pm    Post subject: Reply with quote

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 Smile

_________________
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
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Nov 20, 2004 8:01 pm    Post subject: Reply with quote

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... Rolling Eyes

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
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sat Nov 20, 2004 8:48 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Miscellaneous All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group