Jump to content
Sign in to follow this  
Champak

Mem Stats Update Constantly.

Recommended Posts

Champak

I'm trying to get the memory to update constant real time like the CPU didsplay, but I can't get it. This is what I've tried:

#include <GUIconstants.au3>
If Not ProcessExists("taskmgr.exe") Then Run("taskmgr.exe", "", @SW_HIDE)
GUICreate("Memory",500,100,0,0)

$mem = MemGetStats()

$progress = GUICtrlCreateProgress(0,0,500,20)
GUICtrlSetData($progress, $mem); I've done this back and forwards. I forget which way it suppose to be

GUISetState()
WinSetOnTop("R","",1)

While 1
    $Msg = GUIGetMsg()
    Select
        Case $Msg = $GUI_EVENT_CLOSE
            Exit 
    EndSelect
WEnd

Is this possible and I'm just doing it wrong? Or is it just not possible? Thanks.

Share this post


Link to post
Share on other sites
CodeMaster Rapture

Try this:

While 1
    GUICtrlSetData($progress,MemGetStats())
    $Msg = GUIGetMsg()
    Select
        Case $Msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
    Sleep(10);Don't hog the CPU
Wend

Just so you know, the syntax is GUICtrlSetData($[ProgressBar/Button/Label/Etc],$NewData). You want to use this inside the loop so it will update in "Real-Time".

-CMR

Share this post


Link to post
Share on other sites
Champak

That doesn't work.....it doesn't have to be a prgress bar if that is possible, it can just be numerical indicator if that makes this easier.

Share this post


Link to post
Share on other sites
Champak

Should I take it that this is not possible?

Share this post


Link to post
Share on other sites
w0uter

you should read the helpfile.

Opt("GUIOnEventMode", 1)

$h_gui = GUICreate("Memory",500,100,0,0)
$h_bar = GUICtrlCreateProgress(0,0,500,20)

GUISetOnEvent(-3, "Close")
WinSetOnTop($h_gui,"",1)
GUISetState()


While 1
    $ai_mem = MemGetStats()
    GUICtrlSetData($h_bar, $ai_mem[0])
    Sleep(10)
Wend

Func Close()
    Exit
EndFunc
Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites
Champak

I've always been reading the help file, but just because I see something in the help file, doesn't mean I will necessarily know how to implement it to get what I want. Reading what I see in the help file about this, I wouldn't have figured I could use it in that way.

But a question on this though. It does update while nothing is happening, but once I activate a function, it stops monitoring until the function ends. Is that how it is suppose to be? Or can I have it monitoring while the function is in play?

Thanks.

Share this post


Link to post
Share on other sites
Valuater

Is that how it is suppose to be?

Thanks.

Yes,

however depending on your scipt, you can determine how often something is checked

one way is..

AdlibEnable

--------------------------------------------------------------------------------

Enables Adlib functionality.

AdlibEnable ( "function" [, time] )

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Champak

The adlib doesn't work for me because what I need it to work on resides in the "while" statement. Or is there something else I can do, or missing? I read the helpfile on adlib....didn't really learn anything from that besides it needs to be in a function.

Edit:

I would think it could go in a function, if I can activate it automatically when the GUI starts. Is there a way to do that? Or am I totally off?

Edited by Champak

Share this post


Link to post
Share on other sites
Valuater

The adlib doesn't work for me because what I need it to work on resides in the "while" statement. Or is there something else I can do, or missing? I read the helpfile on adlib....didn't really learn anything from that besides it needs to be in a function.

cant you put waht you want to do in a function?

the adlib with be like a while loop and you decide how often it checks

AdlibEnable ( "function" [, time] )

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Champak

I have two problems with that.

If I take it out of the while statement, it starts flickering something terrible. That I can deal with...just increase the time to 5 seconds.

However, when I take it out the "while" and put it in the "function", the progess bars show through ALL the child GUIs as well. So it looks like I have to leave it in the "while" and not the "function". Or is there something else?

Share this post


Link to post
Share on other sites
Valuater

ok... show me the script that worked so far

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Champak

It's a little over 2000 lines so I'm just attaching it with the ini as text. This is athe fully functioning version without the adlib.

The lines of concern are 838-845 and 888-895.

As a matter of fact, while you are looking at that, there was something else you wanted to see in relation to another post:

http://www.autoitscript.com/forum/index.php?showtopic=26136

I didn't bring that back up yet because there were more important things I wanted to take care of. But the lines affecting that function are on 3-6 and 1397-1398.

Thanks.

Edited by Champak

Share this post


Link to post
Share on other sites
Valuater

i think i got it

1

place this code above the

while loop

AdlibEnable("get_mem")

While 1; this is the existing while start

2

place the function just after the Wend

WEnd; existing code start

;///////////////////////////////////////////////////////////////////////////////////////
;///////////////////////////////While function ends/////////////////////////////////////
;///////////////////////////////////////////////////////////////////////////////////////
GUIDelete(); existing code end

Func get_mem()
    $ai_mem = MemGetStats()
    GUICtrlSetData($h_bar, $ai_mem[0])
EndFunc

and comment out this portion........... remove after checking that evrything is OK

;/////////////////////////////CPU and memory status begins; existing code
    
;$ai_mem = MemGetStats()
  ;GUICtrlSetData($h_bar, $ai_mem[0])

i got it to work just fine.... but i cant run your functions

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
Champak

Thanks, works great. I went ahead and put the cpu monitor in the function as well. I don't know if that's bad or not...but it works. If I shouldn't do that for whatever reason, let me know.

Share this post


Link to post
Share on other sites
Valuater

Welcome

... it should be fine

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.