Jump to content
Sign in to follow this  
layer

A way to get CPU usage?

Recommended Posts

hello, is there a way to get the CPU usage via autoit? or is there some thing hwere you can divide the RAM by memory or something? thanks :idiot:

EDIT: after i abit of reasearch i may just wip up my own C++ one :D or just do a DllCall :lol:

Edited by layer

FootbaG

Share this post


Link to post
Share on other sites

hello, is there a way to get the CPU usage via autoit? or is there some thing hwere you can divide the RAM by memory or something? thanks :idiot:

EDIT: after i abit of reasearch i may just wip up my own C++ one :D or just do a DllCall :lol:

<{POST_SNAPBACK}>

Hello layer i hope it is wat you need) ;)

HotKeySet("{F1}", "_show")
HotKeySet("{F2}", "_hide")
HotKeySet("{ESC}", "_exit")
Opt ("TrayIconHide", 1)
#include <GuiConstants.au3>
Dim $WS_OVERLAPPEDWINDOW = 0xCF0000, $WS_VISIBLE = 0x10000000, $WS_CLIPSIBLINGS = 0x04000000
GUICreate("MemStat", 300, 140, (@DesktopWidth - 299) / 2, (@DesktopHeight - 192) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$Label_1 = GUICtrlCreateLabel("Memory Statistics:", 100, 10, 90, 20)
$Label_2 = GUICtrlCreateLabel("", 10, 40, 280, 150)
WinSetOnTop("MemStat", "", 1)
GUISetState()
While 1
   $msg = GUIGetMsg()
   $mem = MemGetStats()
   $mem[0] = "Memory Load (% of memory currently in use): " & $mem[0] & "%" & @CRLF
   $mem[1] = "Total Physical RAM: " & $mem[1] & " Kilobytes" & @CRLF
   $mem[2] = "Available Physical RAM: " & $mem[2] & " Kilobytes" & @CRLF
   $mem[3] = "Total Pagefile: " & $mem[3] & " Kilobytes" & @CRLF
   $mem[4] = "Available Pagefile: " & $mem[4] & " Kilobytes" & @CRLF
   $mem[5] = "Total virtual: " & $mem[5] & " Kilobytes" & @CRLF
   $mem[6] = "Available virtual: " & $mem[6] & " Kilobytes" & @CRLF
   GUICtrlSetData($Label_2, "" & $mem[0] & $mem[1] & $mem[2] & $mem[3] & $mem[4] & $mem[5] & $mem[6])
   If $msg = $GUI_EVENT_CLOSE Then
      Call(_exit())
   EndIf
Wend
Func _hide()
   WinSetOnTop("MemStat", "", 0)
   WinSetState("MemStat", "", @SW_HIDE)
EndFunc;==>_hide
Func _show()
   WinSetState("MemStat", "", @SW_SHOW)
   WinSetOnTop("MemStat", "", 1)
EndFunc;==>_show
Func _exit()
   Exit
EndFunc;==>_exit

Share this post


Link to post
Share on other sites

thanks dirtybanditios :idiot: but what im trying to do is find the CPU usage, not memory usage, actually i was working on a project like that myself :D

although it doesnt work, ive just been adding to it like once a week, so its going by really slooooowly

#include <GUIConstants.au3>
GUICreate ("Memory Checkup")
GUISetState ()
$list= GUICtrlCreateListView ("Time to scan", 10, 10, 200, 150)
$listitem= GUICtrlCreateListViewItem ("20 Minutes", $list)
$listitem2= GUICtrlCreateListViewItem ("15 Minutes", $list)
$listitem3= GUICtrlCreateListViewItem ("10 Minutes", $list)
$listitem4= GUICtrlCreateListViewItem ("5 Minutes", $list)
$label= GUICtrlCreateLabel ("Things to log:", 10, 180)
$check= GUICtrlCreateCheckBox ("Memory in use", 10, 210)
$check1= GUICtrlCreateCheckBox ("Total RAM", 10, 230)
$check2= GUICtrlCreateCheckBox ("Unused RAM", 10, 250)
$check3= GUICtrlCreateCheckBox ("Amount of pagefile", 10, 270)
$check4= GUICtrlCreateCheckBox ("Unused pagefile", 10, 290)
$check5= GUICtrlCreateCheckBox ("Total virtual memory", 10, 310)
$check6= GUICtrlCreateCheckBox ("Unused virtual memory", 10, 330)
$check7= GUICtrlCreateCheckBox ("All", 10, 350)
$scan= GUICtrlCreateButton ("Scan!", 300, 200)
While 1 
   $get= GUIGetMsg ()
      If $listitem= 1 Then 
      $scan20min= 1
   EndIf
   If $listitem= 0 Then
      $scan20min= 0
      EndIf
   If $listitem2= 1 Then
      $scan15min= 1
   EndIf
   If $listitem2= 0 Then
      $scan15min= 0
      EndIf
      If $listitem3= 1 Then
         $scan10min= 1
      EndIf
      If $listitem3= 0 Then
         $scan10min= 0
      EndIf
      If $listitem4= 1 Then
         $scan5min= 1
      EndIf
      If $listitem4= 0 Then
         $scan5min= 0
      EndIf
Select
Case $get= $listitem3
   IniWrite (@DeskTopDir & "\MemCheck.ini\", "Time", "Time2Scan", "10")
Case $get= $listitem4
   IniWrite (@DeskTopDir & "\MemCheck.ini\", "Time", "Time2Scan", "5")
Case $get= -3
   Exit
Case $check= $GUI_CHECKED
   $scanmem= 1
Case $check= $GUI_UNCHECKED
   $scanmem= 0
Case $check1= $GUI_CHECKED
   $scanram= 1
Case $check1= $GUI_UNCHECKED
   $scanram= 0
Case $check2= $GUI_CHECKED
   $scanunusedram= 1
Case $check2= $GUI_UNCHECKED
   $scanunusedram= 0
Case $check3= $GUI_CHECKED
   $scanpagefile= 1
Case $check3= $GUI_UNCHECKED
   $scanpagefile= 0
Case $check4= $GUI_CHECKED
   $scanunusedpagefile= 1
Case $check4= $GUI_UNCHECKED
   $scanunusedpagefile= 0
Case $check5= $GUI_CHECKED
   $scanvirtualmemory= 1 
Case $check5= $GUI_UNCHECKED
   $scanvirtualmemory= 0
Case $check6= $GUI_CHECKED
   $scanunusedvirtualmemory= 1
Case $check6= $GUI_UNCHECKED
   $scanunusedvirtualmemory= 0
Case $check7= $GUI_CHECKED
   $scanall= 1
Case $check7= $GUI_UNCHECKED
   $scanall= 0
Case $get= $scan
Scan ()
EndSelect
   WEnd

Func all ()
While 1
$getmem= MemGetStats ()
Sleep (60*15*1000)
FileWriteLine ("MemUsageLog.txt", "")
FileWriteLine ("MemUsageLog.txt", "Date= " & @MON & "/" & @MDAY & "/" & @YEAR & " -- " & "Time= " & @Hour & ":" & @Min & ":" & @Sec & ": " & "Memory percentage being used: " & $getmem[0] & "%")
FileWriteLine ("MemUsageLog.txt", "")
FileWriteLine ("MemUsageLog.txt", "Date= " & @MON & "/" & @MDAY & "/" & @YEAR & " -- " & "Time= " & @Hour & ":" & @Min & ":" & @Sec & ": " & "Total amount of RAM: " & $getmem[1] & " Kilobytes")
FileWriteLine ("MemUsageLog.txt", "")
FileWriteLine ("MemUsageLog.txt", "Date= " & @MON & "/" & @MDAY & "/" & @YEAR & " -- " & "Time= " & @Hour & ":" & @Min & ":" & @Sec & ": " & "Unused RAM: " & $getmem[2] & " Kilobytes")
FileWriteLine ("MemUsageLog.txt", "")
FileWriteLine ("MemUsageLog.txt", "Date= " & @MON & "/" & @MDAY & "/" & @YEAR & " -- " & "Time= " & @Hour & ":" & @Min & ":" & @Sec & ": " & "Total amount of PageFile: " & $getmem[3] & " Kilobytes")
FileWriteLine ("MemUsageLog.txt", "")
FileWriteLine ("MemUsageLog.txt", "Date= " & @MON & "/" & @MDAY & "/" & @YEAR & " -- " & "Time= " & @Hour & ":" & @Min & ":" & @Sec & ": " & "Unused PageFile: " & $getmem[4] & " Kilobytes")
FileWriteLine ("MemUsageLog.txt", "")
FileWriteLine ("MemUsageLog.txt", "Date= " & @MON & "/" & @MDAY & "/" & @YEAR & " -- " & "Time= " & @Hour & ":" & @Min & ":" & @Sec & ": " & "Total amount of Virtual Memory: " & $getmem[5] & " Kilobytes")
FileWriteLine ("MemUsageLog.txt", "")
FileWriteLine ("MemUsageLog.txt", "Date= " & @MON & "/" & @MDAY & "/" & @YEAR & " -- " & "Time= " & @Hour & ":" & @Min & ":" & @Sec & ": " & "Unused virtual memory: " & $getmem[6] & " Kilobytes")
FileWriteLine ("MemUsageLog.txt", @CRLF & @CRLF & @CRLF & @CRLF & @CRLF)
WEnd
EndFunc

Func Scan ()
      $get= GUIGetMsg ()
      If $listitem= 1 Then 
      Sleep (60*20*1000)
   EndIf
   If $listitem2= 1 Then
      Sleep (60*15*1000)
   EndIf
   If $listitem3= 1 Then
      Sleep (60*10*1000)
   EndIf
   If $listitem4= 1 Then
      Sleep (60*5*1000)
   EndIf
   
   
   
   
   EndFunc

it's very undeveloped as of now... i may decide to work on it later.. :lol:

thanks

P.S. (this actually gives me a chance to learn some C++ ;))!


FootbaG

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...