dryper Posted March 24, 2008 Share Posted March 24, 2008 Hello im currently creating a System info dumper for my Web server but i dont know how to make a loop (so it repeat continiously) and how do i refresh a gui? Thanks for answers! This is what i have so far expandcollapse popup#include <GUIConstants.au3> $driveamount = DriveGetDrive( "all" ) $drivec = DriveSpaceTotal( "c:\" ) $drivefreec = DriveSpaceFree( "c:\" ) $drived = DriveSpaceTotal( "d:\" ) $drivefreed = DriveSpaceFree( "d:\" ) $mem = MemGetStats() GUICreate("Test",500,500) GUISetState (@SW_SHOW) GUICtrlCreateLabel("Minne Tilgjengelig: " & $mem[1] & "kb",90,1,500,50) GUICtrlCreateLabel("Brukt Minne: " & $mem[2] & "kb",90,20,500,50) GUICtrlCreateLabel("Minne i Prosent: " & $mem[0] & "kb",90,40,500,50) GUICtrlCreateLabel("Pagefile Tilgjengelig: " & $mem[4] & "kb",90,60,500,50) GUICtrlCreateLabel("Total Pagefile: " & $mem[3] & "kb",90,80,500,50) GUICtrlCreateLabel("Antall Harddisker: " & $driveamount[0] & " harddisker",90,100,500,50) GUICtrlCreateLabel("Total Plass C:\: " & $drivec & "kb",90,120,500,50) GUICtrlCreateLabel("Ledig Plass C:\: " & $drivefreec & "kb",90,140,500,50) GUICtrlCreateLabel("Total Plass D:\: " & $drived & "kb",90,160,500,50) GUICtrlCreateLabel("Ledig Plass D:\: " & $drivefreed & "kb",90,180,500,50) GUICtrlCreateLabel("OS Type: " & @OSType,90,210,500,50) GUICtrlCreateLabel("OS Version: " & @OSVersion,90,230,500,50) GUICtrlCreateLabel("OS Build: " & @OSBuild,90,250,500,50) GUICtrlCreateLabel("Processor Type: " & @ProcessorArch,90,270,500,50) GUICtrlCreateLabel("Computer Name: " & @ComputerName,90,290,500,50) FileDelete("stats.php") $file = FileOpen("stats.php", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, "<?" & @CRLF ) FileWrite($file, "$minnetilgjengelig = " & $mem[1] & ";" & @CRLF ) FileWrite($file, "$bruktminne = " & $mem[2] & ";" & @CRLF ) FileWrite($file, "$minneprosent = " & $mem[0] & ";" & @CRLF ) FileWrite($file, "$pagefiletilgjengelig = " & $mem[4] & ";" & @CRLF ) FileWrite($file, "$totalpagefile = " & $mem[3] & ";" & @CRLF ) FileWrite($file, "$antallharddisk = " & $driveamount[0] & ";" & @CRLF ) FileWrite($file, "$totalhddc = " & $drivefreec & ";" & @CRLF ) FileWrite($file, "$ledighddc = " & $mem[2] & ";" & @CRLF ) FileWrite($file, "$totalhddd = " & $drived & ";" & @CRLF ) FileWrite($file, "$ledighddd = " & $drivefreed & ";" & @CRLF ) FileWrite($file, "$ostype = " & @OSType & ";" & @CRLF ) FileWrite($file, "$osversion = " & @OSVersion & ";" & @CRLF ) FileWrite($file, "$osbuild = " & @OSBuild & ";" & @CRLF ) FileWrite($file, "$processortype = " & @ProcessorArch & ";" & @CRLF ) FileWrite($file, "$computername = " & @ComputerName & ";" & @CRLF ) FileWrite($file, "?>" & @CRLF ) FileClose($file) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Link to comment Share on other sites More sharing options...
Zedna Posted March 24, 2008 Share Posted March 24, 2008 You can optimize flickering by updating labels only when their value is different then written value - in UpdateGUI() expandcollapse popup#include <GUIConstants.au3> Global $driveamount,$drivec,$drivefreec,$drived,$drivefreed,$mem Global $start GUICreate("Test",500,500) GUISetState (@SW_SHOW) $label1 = GUICtrlCreateLabel("Minne Tilgjengelig: kb",90,1,500,50) $label2 = GUICtrlCreateLabel("Brukt Minne: kb",90,20,500,50) $label3 = GUICtrlCreateLabel("Minne i Prosent: kb",90,40,500,50) $label4 = GUICtrlCreateLabel("Pagefile Tilgjengelig: kb",90,60,500,50) $label5 = GUICtrlCreateLabel("Total Pagefile: kb",90,80,500,50) $label6 = GUICtrlCreateLabel("Antall Harddisker: harddisker",90,100,500,50) $label7 = GUICtrlCreateLabel("Total Plass C:\: kb",90,120,500,50) $label8 = GUICtrlCreateLabel("Ledig Plass C:\: kb",90,140,500,50) $label9 = GUICtrlCreateLabel("Total Plass D:\: kb",90,160,500,50) $label10 = GUICtrlCreateLabel("Ledig Plass D:\: kb",90,180,500,50) $label11 = GUICtrlCreateLabel("OS Type: " & @OSType,90,210,500,50) $label12 = GUICtrlCreateLabel("OS Version: " & @OSVersion,90,230,500,50) $label13 = GUICtrlCreateLabel("OS Build: " & @OSBuild,90,250,500,50) $label14 = GUICtrlCreateLabel("Processor Type: " & @ProcessorArch,90,270,500,50) $label15 = GUICtrlCreateLabel("Computer Name: " & @ComputerName,90,290,500,50) GetInfo() $start = TimerInit() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If TimerDiff($start) > 1000 Then ; once a second $start = TimerInit() GetInfo() EndIf Wend Func GetInfo() $driveamount = DriveGetDrive( "all" ) $drivec = DriveSpaceTotal( "c:\" ) $drivefreec = DriveSpaceFree( "c:\" ) $drived = DriveSpaceTotal( "d:\" ) $drivefreed = DriveSpaceFree( "d:\" ) $mem = MemGetStats() UpdateGUI() WriteInfo() EndFunc Func UpdateGUI() GUICtrlSetData($label1, "Minne Tilgjengelig: " & $mem[1] & "kb") GUICtrlSetData($label2, "Brukt Minne: " & $mem[2] & "kb") GUICtrlSetData($label3, "Minne i Prosent: " & $mem[0] & "kb") GUICtrlSetData($label4, "Pagefile Tilgjengelig: " & $mem[4] & "kb") GUICtrlSetData($label5, "Total Pagefile: " & $mem[3] & "kb") GUICtrlSetData($label6, "Antall Harddisker: " & $driveamount[0] & " harddisker") GUICtrlSetData($label7, "Total Plass C:\: " & $drivec & "kb") GUICtrlSetData($label8, "Ledig Plass C:\: " & $drivefreec & "kb") GUICtrlSetData($label9, "Total Plass D:\: " & $drived & "kb") GUICtrlSetData($label10, "Ledig Plass D:\: " & $drivefreed & "kb") EndFunc Func WriteInfo() FileDelete("stats.php") $file = FileOpen("stats.php", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, "<?" & @CRLF ) FileWrite($file, "$minnetilgjengelig = " & $mem[1] & ";" & @CRLF ) FileWrite($file, "$bruktminne = " & $mem[2] & ";" & @CRLF ) FileWrite($file, "$minneprosent = " & $mem[0] & ";" & @CRLF ) FileWrite($file, "$pagefiletilgjengelig = " & $mem[4] & ";" & @CRLF ) FileWrite($file, "$totalpagefile = " & $mem[3] & ";" & @CRLF ) FileWrite($file, "$antallharddisk = " & $driveamount[0] & ";" & @CRLF ) FileWrite($file, "$totalhddc = " & $drivefreec & ";" & @CRLF ) FileWrite($file, "$ledighddc = " & $mem[2] & ";" & @CRLF ) FileWrite($file, "$totalhddd = " & $drived & ";" & @CRLF ) FileWrite($file, "$ledighddd = " & $drivefreed & ";" & @CRLF ) FileWrite($file, "$ostype = " & @OSType & ";" & @CRLF ) FileWrite($file, "$osversion = " & @OSVersion & ";" & @CRLF ) FileWrite($file, "$osbuild = " & @OSBuild & ";" & @CRLF ) FileWrite($file, "$processortype = " & @ProcessorArch & ";" & @CRLF ) FileWrite($file, "$computername = " & @ComputerName & ";" & @CRLF ) FileWrite($file, "?>" & @CRLF ) FileClose($file) EndFunc Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
dryper Posted March 24, 2008 Author Share Posted March 24, 2008 thank you. this is what i needed! btw is there any way to show CPU load , free, total .ect? Link to comment Share on other sites More sharing options...
DarkMatter Posted March 24, 2008 Share Posted March 24, 2008 (edited) You could also do something like this (Pretty much the same as Zedna): expandcollapse popup#include <GUIConstants.au3> $driveamount = DriveGetDrive( "all" ) $drivec = DriveSpaceTotal( "c:\" ) $drivefreec = DriveSpaceFree( "c:\" ) $drived = DriveSpaceTotal( "d:\" ) $drivefreed = DriveSpaceFree( "d:\" ) $mem = MemGetStats() GUICreate("Test",500,500) GUISetState (@SW_SHOW) $TotalRAM = GUICtrlCreateLabel("Minne Tilgjengelig: " & $mem[1] & "kb",90,1,500,50) $AvaRAM = GUICtrlCreateLabel("Brukt Minne: " & $mem[2] & "kb",90,20,500,50) $PageFile = GUICtrlCreateLabel("Minne i Prosent: " & $mem[0] & "kb",90,40,500,50) $AvaPageFile = GUICtrlCreateLabel("Pagefile Tilgjengelig: " & $mem[4] & "kb",90,60,500,50) $Virtual = GUICtrlCreateLabel("Total Pagefile: " & $mem[3] & "kb",90,80,500,50) $AvaVirtual = GUICtrlCreateLabel("Antall Harddisker: " & $driveamount[0] & " harddisker",90,100,500,50) $DriveC = GUICtrlCreateLabel("Total Plass C:\: " & $drivec & "kb",90,120,500,50) $DriveCFree = GUICtrlCreateLabel("Ledig Plass C:\: " & $drivefreec & "kb",90,140,500,50) $DRiveD = GUICtrlCreateLabel("Total Plass D:\: " & $drived & "kb",90,160,500,50) $DRiveDFree = GUICtrlCreateLabel("Ledig Plass D:\: " & $drivefreed & "kb",90,180,500,50) $OS = GUICtrlCreateLabel("OS Type: " & @OSType,90,210,500,50) $OSVersion = GUICtrlCreateLabel("OS Version: " & @OSVersion,90,230,500,50) $OSBuild = GUICtrlCreateLabel("OS Build: " & @OSBuild,90,250,500,50) $PRocessorType = GUICtrlCreateLabel("Processor Type: " & @ProcessorArch,90,270,500,50) $ComputerName = GUICtrlCreateLabel("Computer Name: " & @ComputerName,90,290,500,50) $Timerstart = TimerInit() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If TimerDiff($Timerstart) > 1000 Then; once a second $Timerstart = TimerInit() GetStats() EndIf Wend Func GetStats() FileDelete("stats.php") $file = FileOpen("stats.php", 1) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $driveamount = DriveGetDrive( "all" ) $drivec = DriveSpaceTotal( "c:\" ) $drivefreec = DriveSpaceFree( "c:\" ) $drived = DriveSpaceTotal( "d:\" ) $drivefreed = DriveSpaceFree( "d:\" ) GUICtrlSetData($TotalRAM, "Minne Tilgjengelig: " & $mem[1] & "kb") GUICtrlSetData($AvaRAM, "Brukt Minne: " & $mem[2] & "kb") GUICtrlSetData($PageFile, "Minne i Prosent: " & $mem[0] & "kb") GUICtrlSetData($AvaPageFile, "Pagefile Tilgjengelig: " & $mem[4] & "kb") GUICtrlSetData($Virtual, "Total Pagefile: " & $mem[3] & "kb") GUICtrlSetData($AvaVirtual, "Antall Harddisker: " & $driveamount[0] & " harddisker") GUICtrlSetData($DriveC, "Total Plass C:\: " & $drivec & "kb") GUICtrlSetData($DriveCFree, "Ledig Plass D:\: " & $drivefreed & "kb") GUICtrlSetData($DRiveD , "Total Plass D:\: " & $drived & "kb") GUICtrlSetData($DRiveDFree, "Ledig Plass D:\: " & $drivefreed & "kb") GUICtrlSetData($OS, "OS Type: " & @OSType) GUICtrlSetData($OSVersion, "OS Version: " & @OSVersion) GUICtrlSetData($PRocessorType, "Processor Type: " & @ProcessorArch) GUICtrlSetData($ComputerName, "Computer Name: " & @ComputerName) FileWrite($file, "<?" & @CRLF ) FileWrite($file, "$minnetilgjengelig = " & $mem[1] & ";" & @CRLF ) FileWrite($file, "$bruktminne = " & $mem[2] & ";" & @CRLF ) FileWrite($file, "$minneprosent = " & $mem[0] & ";" & @CRLF ) FileWrite($file, "$pagefiletilgjengelig = " & $mem[4] & ";" & @CRLF ) FileWrite($file, "$totalpagefile = " & $mem[3] & ";" & @CRLF ) FileWrite($file, "$antallharddisk = " & $driveamount[0] & ";" & @CRLF ) FileWrite($file, "$totalhddc = " & $drivefreec & ";" & @CRLF ) FileWrite($file, "$ledighddc = " & $mem[2] & ";" & @CRLF ) FileWrite($file, "$totalhddd = " & $drived & ";" & @CRLF ) FileWrite($file, "$ledighddd = " & $drivefreed & ";" & @CRLF ) FileWrite($file, "$ostype = " & @OSType & ";" & @CRLF ) FileWrite($file, "$osversion = " & @OSVersion & ";" & @CRLF ) FileWrite($file, "$osbuild = " & @OSBuild & ";" & @CRLF ) FileWrite($file, "$processortype = " & @ProcessorArch & ";" & @CRLF ) FileWrite($file, "$computername = " & @ComputerName & ";" & @CRLF ) FileWrite($file, "?>" & @CRLF ) FileClose($file) EndFunc Edited March 24, 2008 by MattWise [sub]Quantum mechanics: The dreams stuff is made of[/sub] Link to comment Share on other sites More sharing options...
Zedna Posted March 24, 2008 Share Posted March 24, 2008 btw is there any way to show CPU load , free, total .ect?Look at Computer Info UDF Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
DarkMatter Posted March 24, 2008 Share Posted March 24, 2008 You could also create a process counter using the PDH.DLL that resides in C:\windows\system32. I'm unsure if you want to go with that complexity or if you would prefer using the Computer Info UDF. [sub]Quantum mechanics: The dreams stuff is made of[/sub] Link to comment Share on other sites More sharing options...
dryper Posted March 24, 2008 Author Share Posted March 24, 2008 if anyone can help me with the UDF think i can use that... i have no idea how it works.. ive placed all the files where it should be but i have NO idea how to code it :S Link to comment Share on other sites More sharing options...
LIMITER Posted March 24, 2008 Share Posted March 24, 2008 Here's a quick example expandcollapse popup#include "CompInfo.au3" Dim $OSs _ComputerGetOSs($OSs) For $i = 1 To $OSs[0][0] Step 1 MsgBox(0, "Test _ComputerGetOSs", "Name: " & $OSs[$i][0] & @CRLF & _ "Boot Device: " & $OSs[$i][1] & @CRLF & _ "Build Number: " & $OSs[$i][2] & @CRLF & _ "Build Type: " & $OSs[$i][3] & @CRLF & _ "Description: " & $OSs[$i][4] & @CRLF & _ "Code Set: " & $OSs[$i][5] & @CRLF & _ "Country Code: " & $OSs[$i][6] & @CRLF & _ "Creation Class Name: " & $OSs[$i][7] & @CRLF & _ "CSCreation Class Name: " & $OSs[$i][8] & @CRLF & _ "CSD Version: " & $OSs[$i][9] & @CRLF & _ "CS Name: " & $OSs[$i][10] & @CRLF & _ "Current Time Zone: " & $OSs[$i][11] & @CRLF & _ "Data Execution Prevention_32BitApplications: " & $OSs[$i][12] & @CRLF & _ "Data Execution Prevention_Available: " & $OSs[$i][13] & @CRLF & _ "Data Execution Prevention_Drivers: " & $OSs[$i][14] & @CRLF & _ "Data Execution Prevention_SupportPolicy: " & $OSs[$i][15] & @CRLF & _ "Debug: " & $OSs[$i][16] & @CRLF & _ "Distributed: " & $OSs[$i][17] & @CRLF & _ "Encryption Level: " & $OSs[$i][18] & @CRLF & _ "Foreground Application Boost: " & $OSs[$i][19] & @CRLF & _ "Free Physical Memory: " & $OSs[$i][20] & @CRLF & _ "Free Space In Paging Files: " & $OSs[$i][21] & @CRLF & _ "Free Virtual Memory: " & $OSs[$i][22] & @CRLF & _ "Install Date: " & $OSs[$i][23] & @CRLF & _ "Large System Cache: " & $OSs[$i][24] & @CRLF & _ "Last Boot Up Time: " & $OSs[$i][25] & @CRLF & _ "Local Date Time: " & $OSs[$i][26] & @CRLF & _ "Locale: " & $OSs[$i][27] & @CRLF & _ "Manufacturer: " & $OSs[$i][28] & @CRLF & _ "Max Number Of Processes: " & $OSs[$i][29] & @CRLF & _ "Max Process Memory Size: " & $OSs[$i][30] & @CRLF & _ "Number Of Licensed Users: " & $OSs[$i][31] & @CRLF & _ "Number Of Processes: " & $OSs[$i][32] & @CRLF & _ "Number Of Users: " & $OSs[$i][33] & @CRLF & _ "Organization: " & $OSs[$i][34] & @CRLF & _ "OS Language: " & $OSs[$i][35] & @CRLF & _ "OS Product Suite: " & $OSs[$i][36] & @CRLF & _ "OS Type: " & $OSs[$i][37] & @CRLF & _ "Other Type Description: " & $OSs[$i][38] & @CRLF & _ "Plus Product ID: " & $OSs[$i][39] & @CRLF & _ "Plus Version Number: " & $OSs[$i][40] & @CRLF & _ "Primary: " & $OSs[$i][41] & @CRLF & _ "Product Type: " & $OSs[$i][42] & @CRLF & _ "Quantum Length: " & $OSs[$i][43] & @CRLF & _ "Quantum Type: " & $OSs[$i][44] & @CRLF & _ "Registered User: " & $OSs[$i][45] & @CRLF & _ "Serial Number: " & $OSs[$i][46] & @CRLF & _ "Service Pack Major Version: " & $OSs[$i][47] & @CRLF & _ "Service Pack Minor Version: " & $OSs[$i][48] & @CRLF & _ "Size Stored In Paging Files: " & $OSs[$i][49] & @CRLF & _ "Status: " & $OSs[$i][50] & @CRLF & _ "Suite Mask: " & $OSs[$i][51] & @CRLF & _ "System Device: " & $OSs[$i][52] & @CRLF & _ "System Directory: " & $OSs[$i][53] & @CRLF & _ "System Drive: " & $OSs[$i][54] & @CRLF & _ "Total Swap Space Size: " & $OSs[$i][55] & @CRLF & _ "Total Virtual Memory Size: " & $OSs[$i][56] & @CRLF & _ "Total Visible Memory Size: " & $OSs[$i][57] & @CRLF & _ "Version: " & $OSs[$i][58] & @CRLF & _ "Windows Directory: " & $OSs[$i][59]) $os = StringSplit($OSs[$i][0], "|") MsgBox(32, "Computer Info", $os[1] & " v." & $OSs[$i][58] & @CRLF & $OSs[$i][9]) Next Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now