Sign in to follow this  
Followers 0
SoulBlade

Disk Information Monitor

5 posts in this topic

#1 ·  Posted (edited)

Hi!

I writing this small program that shows disk information (drive letter, drive type, total space, free size and a small picture).

In my code below i have only one disk but i use 5. If the system doesn't have 5 disks, the space will appear blank.

The information is updated each 3 seconds. I haven't managed to do three things:

- When a USB pen is inserted the info appears but if i remove it the rectangule created by GuiCtrlCreateGroup doesn't disappear.

- Everything blinks because is always updated. I tried to update only if there is changes but without results.

- I dont want to update Drive A:

Any help to add the 3 missing functions and tweak/improve my code is welcome!

:)

CODE
#include <GUIConstants.au3>

$Gui=GUICreate("GUI",514, 325)

$tab=GUICtrlCreateTab (0,0, 518,310)

$tab0=GUICtrlCreateTabitem ("a1")

$n=StringLeft(@WindowsDir,2)

$x=30

$y=43

$var = DriveGetDrive( "all" )

$n=StringLeft(@WindowsDir,2)

$i=1

$disk1a=GUICtrlCreatePic("antispyware\ic\blank.bmp",184, $y, 32, 32)

$disk1b=GUICtrlCreateGroup("",178,$x,128,52)

$disk1c=GUICtrlCreateLabel("",220, $y, 30, 14,$SS_LEFT)

$disk1d=GUICtrlCreateLabel("",250, $y, 52, 14,$SS_RIGHT)

$x=$x+54

$y=$y+19

$disk1e=GUICtrlCreateLabel("",220, $y, 30, 14,$SS_LEFT)

$disk1f=GUICtrlCreateLabel("",250, $y, 52, 14,$SS_RIGHT)

Adlibenable ("MEM",2000)

$tab1=GUICtrlCreateTabitem ("a2")

GUISetState ()

Do

$msg = GUIGetMsg()

Select

Case $msg=$tab

if GUICtrlRead($tab) = 0 then Adlibenable ("MEM",2000)

if GUICtrlRead($tab) <> 0 then AdlibDisable ()

EndSelect

Until $msg = $GUI_EVENT_CLOSE

Func MEM()

$var = DriveGetDrive( "all" )

$i=1

if $i<=$var[0] then

$dsf=Round(DriveSpaceFree( $var[$i] )/1024,2)

$dst=Round(DriveSpaceTotal( $var[$i] )/1024,2)

if GUICtrlRead($disk1a)="" and DriveGetType ($var[$i])="fixed" and $var[$i]=$n then GUICtrlSetImage($disk1a,"antispyware\ic\hd0.bmp")

if GUICtrlRead($disk1a)="" and DriveGetType ($var[$i])="fixed" and $var[$i]<>$n then GUICtrlSetImage($disk1a,"antispyware\ic\hd1.bmp")

if GUICtrlRead($disk1a)="" and DriveGetType ($var[$i])="cdrom" then GUICtrlSetImage($disk1a,"antispyware\ic\hd2.bmp")

if GUICtrlRead($disk1a)="" and DriveGetType ($var[$i])="removable" then GUICtrlSetImage($disk1a,"antispyware\ic\hd3.bmp")

if GUICtrlRead($disk1a)="" and DriveGetType ($var[$i])="unknown" then GUICtrlSetImage($disk1a,"antispyware\ic\hd4.bmp")

if GUICtrlRead($disk1a)="" and DriveGetType ($var[$i])="network" then GUICtrlSetImage($disk1a,"antispyware\ic\hd5.bmp")

if GUICtrlRead($disk1a)="" and DriveGetType ($var[$i])="ramdisk" then GUICtrlSetImage($disk1a,"antispyware\ic\hd6.bmp")

if GUICtrlRead($disk1a)<>"" then GUICtrlSetCursor($disk1a,0)

if GUICtrlRead($disk1b)="" then GUICtrlSetData($disk1b,"Disk " & stringupper ($var[$i]))

if GUICtrlRead($disk1c)="" then GUICtrlSetData($disk1c,"Total:")

if GUICtrlRead($disk1c)<>"" then GUICtrlSetColor($disk1c,0x0000FF)

if $dst<1 and $dst<>0 then GUICtrlSetData($disk1d,$dst*1024 & " MB")

if $dst<1 and $dst=0 then GUICtrlSetData($disk1d,"no disc")

if $dst>=1 then GUICtrlSetData($disk1d,$dst & " GB")

if GUICtrlRead($disk1e)="" then GUICtrlSetData($disk1e,"Free:")

if GUICtrlRead($disk1e)<>"" then GUICtrlSetColor($disk1e,0x0000FF)

if $dsf<1 and $dst<>0 then GUICtrlSetData($disk1f,$dsf*1024 & " MB")

if $dsf<1 and $dst=0 then GUICtrlSetData($disk1f,"no disc")

if $dsf>=1 then GUICtrlSetData($disk1f,$dsf & " GB")

if $dsf<=2 and DriveGetType ($var[$i])="fixed" then GUICtrlSetColor($disk1f,0xFF0000)

$y=$y+35

Else

GUICtrlSetImage($disk1a,"antispyware\ic\blank.bmp")

GUICtrlSetData($disk1b,"")

GUICtrlSetData($disk1c,"")

GUICtrlSetData($disk1d,"")

GUICtrlSetData($disk1e,"")

GUICtrlSetData($disk1f,"")

EndIf

EndFunc

Edited by SoulBlade

Share this post


Link to post
Share on other sites



You've got your process a little backwards.

1. First collect all the information required on the drives currently present.

2. Then create only the GUI elements needed for those drives.

3. Only update the gui if something changes.

4. If the number of drives changes (i.e. a USB stick is inserted), delete the GUI and redraw it to the new drive count.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You've got your process a little backwards.

1. First collect all the information required on the drives currently present.

2. Then create only the GUI elements needed for those drives.

3. Only update the gui if something changes.

4. If the number of drives changes (i.e. a USB stick is inserted), delete the GUI and redraw it to the new drive count.

:)

I'll try that but i cant delete the entire GUI because i have other information and items there.

My GUI uses several Tabs and this disk information is part of Tab0.

Anyway please feel free to post some code. :D

;)

Edited by SoulBlade

Share this post


Link to post
Share on other sites

Anyway please feel free to post some code. ;)

See the Rent-A-Coder link in my sig...

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

See the Rent-A-Coder link in my sig...

:)

Sorry but i prefer to learn from my mistakes. :|

I'm trying to improve my Autoit skills. Any help is apreciated.

Thanks!

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  
Followers 0