Jump to content
Sign in to follow this  
jazzyjeff

Resource hog

Recommended Posts

jazzyjeff

My application is a resource hog. Can anyone see what could be causing it to exhaust 50% of my CPU?

Thanks,

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIEx.au3>
Global $OutputAT, $OutputSN, $manufacturer, $model, $TItemInfo
$drvFree = DriveSpaceFree("C:")
$drvTotal = DriveSpaceTotal("C:")
$rDrvF = $drvFree / 1024
$rDrvT = $drvTotal / 1024
$rDrvU = $rDrvT - $rDrvF
_BIOSAT()
_BIOSSN()
_System()
Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu
Opt("TrayMenuMode", 3) ; Default tray menu items will not be shown.
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Desktop Splash", 380, 310, @DesktopWidth - 400, @DesktopHeight / 3, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW))
GUISetBkColor(0xABABAB)
$Label1 = GUICtrlCreateLabel("Computer Name", 24, 10, 120, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label2 = GUICtrlCreateLabel("IP Address", 24, 40, 110, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label3 = GUICtrlCreateLabel("Operating System", 24, 70, 130, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label4 = GUICtrlCreateLabel("Architecture", 24, 100, 110, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label5 = GUICtrlCreateLabel("Resolution", 24, 130, 95, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label6 = GUICtrlCreateLabel("Free Disk space", 24, 160, 95, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label13 = GUICtrlCreateLabel("Serial Number", 24, 190, 95, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label15 = GUICtrlCreateLabel("Asset tag", 24, 220, 95, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label13 = GUICtrlCreateLabel("Manufacturer", 24, 250, 105, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label15 = GUICtrlCreateLabel("Model", 24, 280, 95, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label7 = GUICtrlCreateLabel(@ComputerName, 190, 10, 190, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label8 = GUICtrlCreateLabel(@IPAddress1, 190, 40, 100, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label9 = GUICtrlCreateLabel(@OSVersion, 190, 70, 75, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label11 = GUICtrlCreateLabel(@OSArch, 190, 100, 85, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label11 = GUICtrlCreateLabel(@DesktopWidth & "x" & @DesktopHeight, 190, 130, 110, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label12 = GUICtrlCreateLabel(Round($rDrvF) & "GB", 190, 160, 140, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label14 = GUICtrlCreateLabel($OutputSN, 190, 190, 140, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label16 = GUICtrlCreateLabel($OutputAT, 190, 220, 110, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label14 = GUICtrlCreateLabel($manufacturer, 190, 250, 140, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
$Label16 = GUICtrlCreateLabel($model, 190, 280, 140, 17)
GUICtrlSetFont(-1, 11, 600, "", "", 5)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
_WinAPI_SetLayeredWindowAttributes($Form1, 0xABABAB, 255, BitOR($LWA_COLORKEY, $LWA_ALPHA))
;Global $TItemInfo = TrayCreateItem("System Information")
;TrayItemSetOnEvent(-1, "_SystemTray")
;TraySetState()
While 1
WEnd
Func _SystemTray()
MsgBox(0, "System Information", "Computer Name:  " & @ComputerName & @CR & _
   "IP Address:  " & @IPAddress1 & @CR & _
   "Operating System:  " & @OSVersion & @CR & _
   "Architecture:  " & @OSArch & @CR & _
   "Resolution:  " & @DesktopWidth & "x" & @DesktopHeight & @CR & _
   "Free Disk space:  " & Round($rDrvF) & "GB" & @CR & _
   "Serial Number:  " & $OutputSN & @CR & _
   "Asset tag:   " & $OutputAT & @CR & _
   "Manufacturer:  " & $manufacturer & @CR & _
   "Model:   " & $model)
EndFunc   ;==>_SystemTray
Func _BIOSAT()
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output = ""
$Output = $Output & "Computer: " & $strComputer & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_SystemEnclosure", "WQL", _
   $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
  For $objItem In $colItems
   $OutputAT = $objItem.SMBIOSAssetTag
  Next
EndIf
EndFunc   ;==>_BIOSAT
Func _BIOSSN()
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output = ""
$Output = $Output & "Computer: " & $strComputer & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", _
   $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
  For $objItem In $colItems
   $OutputSN = $objItem.SerialNumber
  Next
EndIf
EndFunc   ;==>_BIOSSN
Func _System()
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output = ""
$Output = $Output & "Computer: " & $strComputer & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _
   $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
  For $objItem In $colItems
   $manufacturer = $objItem.Manufacturer
   $model = $objItem.Model
  Next
EndIf
EndFunc   ;==>_System

Share this post


Link to post
Share on other sites
guinness

Add Sleep(100) in that while loop for starters.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
jazzyjeff

That was so stupid of me! :-) Thank you. That appears to have resolved my issue.

I was trying to make a BGInfo type application to put on the desktops of teachers at my school.

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  

×