Jump to content
Ascend4nt

Performance Counters in Windows - Measure Process, CPU, Network, Disk Usage

Recommended Posts

ok found a solution for the ram.

But pdh functions seems to works only in admin account :graduated: Script doesn't work as user that isn't in AD administrators. odd.

What was the memory problem? There shouldn't be any problems with memory usage... or was it some other part of your program? (Actually, there is an issue with PdhBrowseCounters loading DLL's that never get released - MS bug - but thats only if you call that _PDH_BrowserCounters() in your script)

As far as the PDH functions working only on Admin accounts - this is untrue. I just tested this on a limited user account. The only case where the PDH performance counters will fail is if it is disabled in the registry somewhere for non-admin accounts. Try calling _PDH_RegistryCheck() and seeing what it returns. Also, you can set $PDH_DEBUGLOG to 2 at the top of your script to get more information reported to the console.


Share this post


Link to post
Share on other sites

Thanks for support !

About memory, I don't anymore init/uninit pdh in the function, I init it at beginning of the script once.

Here is the new function :

Func _PDH_countcpu()
;_PDH_Init()
$hPDHQuery = _PDH_GetNewQueryHandle()
$hCPUCounter = _PDH_AddCounter($hPDHQuery,":238\6\(_Total)")
_PDH_CollectQueryData($hPDHQuery) ; collect the query information once (1st collection may fail, so we'll discard it)
Sleep(50)
While 1
  $iCPUUsage = _PDH_UpdateCounter($hPDHQuery,$hCPUCounter)  ; collect query info and then grab counter value
  If Not @error Then ExitLoop
  Sleep(50)
WEnd
Sleep(50)
_PDH_FreeQueryHandle($hPDHQuery)
;_PDH_UnInit($hPDHQuery)
EndFunc

About admin or not, thanks for the infos, I will check what you say, hope it will work cause your udf is just plenty amazing. I'm network admin also so no problem changing things in AD/GPOs if needed.


Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Share this post


Link to post
Share on other sites

I found this in toggle function :

"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib"

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfOS\Performance"

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance"

but which keys/values ?

Edited by kiboost

Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Share this post


Link to post
Share on other sites

Ok, here is the debug log on the nonworking machine (exact same script working on another one) :

working one : old Amd-DualCore 4600

unworking : Core i7 920 (multithreading)

both win7pro x64 french

registry keys seems the same for both machines

_PDH_GetNewQueryHandle Call succeeded, return:0,param1:0x0000000000000000,param2:0,handle:0x0000000003A512F0

_PDH_GetCounterNameByIndex() call, Index:238 [optional] Machine Name:, PDH DLL 'handle' (or just 'pdh.dll'):1

_PDH_GetCounterNameByIndex() call, Index:6 [optional] Machine Name:, PDH DLL 'handle' (or just 'pdh.dll'):1

Localized counter (from non-localized string):\(_Total)\

PdhAddCounterW error [path:'\(_Total)\'], return:C0000BB8

PdhCollectQueryData error, return:800007D5

Edited by kiboost

Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Share this post


Link to post
Share on other sites

Okay, it appears there's a problem in the _PDH_GetCounterNameByIndex() function. Try running this, it should return a string that is the french equivalent of 'Processor':

Local $iIndex=238
Local $aRet=DllCall('pdh.dll',"long","PdhLookupPerfNameByIndexW",'ptr',0,"dword",$iIndex,"wstr","","dword*",65536)
If @error Then Exit ConsoleWrite("Error on PdhLookupPerfNameByIndexW call:"&@error&@CRLF)
If $aRet[0] Then Exit ConsoleWrite("_PDH_GetCounterNameByIndex non-zero error code:" & Hex($aRet[0])&@CRLF)
ConsoleWrite("PdhLookupPerfNameByIndexW results: Index:"&$aRet[3]&@CRLF)

Share this post


Link to post
Share on other sites

with TestPDH_PerformanceCounters.au3 on unworking machine :

running processor information, the counters seems to work (counter numbers updates with activity) but when clicking on %processor time I got this in console :

New ID from ctListView:29

_PDHGetCounterIndex non-zero error code:C0000BD4


Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Share this post


Link to post
Share on other sites

Okay, 1 thing at a time... we need to figure out why it can't find the registry string corresponding to the index # given. Perhaps try the ANSI version of that function? (I don't know how well this would work on a French PC, but wth, give it a try):

Local $iIndex=238
Local $aRet=DllCall('pdh.dll',"long","PdhLookupPerfNameByIndexA",'ptr',0,"dword",$iIndex,"str","","dword*",65536)
If @error Then Exit ConsoleWrite("Error on PdhLookupPerfNameByIndex call:"&@error&@CRLF)
If $aRet[0] Then Exit ConsoleWrite("_PDH_GetCounterNameByIndex non-zero error code:" & Hex($aRet[0])&@CRLF)
ConsoleWrite("PdhLookupPerfNameByIndex results: Index string:"&$aRet[3]&", #chars:"&$aRet[4]&@CRLF)

If that still gives a blank string after Index, check the registry as outlined on MSDN in PdhLookupPerfNameByIndex. '009' is the English language key, so check the other keys. See which of them have a 'Counter' value with a REG_MULTI_SZ string consisting of "# String" pairs. Here's the branch as seen on MSDN (leading dots added):

HKEY_LOCAL_MACHINE

....\SOFTWARE

......\Microsoft

.........\Windows NT

............\CurrentVersion

...............\Perflib

..................Last Counter = highest counter index

..................Last Help = highest help index

..................\009

.....................Counters = 2 System 4 Memory...

.....................Help = 3 The System Object Type...

..................\supported language, other than English

.....................Counters = ...

.....................Help = ...

HMM.. now that I think about it - if you can put a '$PDH_DEBUGLOG = 2' in TestPDH_PerformanceCounters.au3 (after #include <_PDH_PerformanceCounters.au3>), we'll have an idea of what strings are being returned from the BrowseCounters dialog too.

Sorry to put ya to work on debugging this, but I've never seen this problem and don't have a French language PC. In the end we *might* look at PdhAddEnglishCounter (something I explored in an ).


Share this post


Link to post
Share on other sites

ok, no problem debugging, this is part of coding tasks. Thank you for your time.

Ansi debug :

working : PdhLookupPerfNameByIndex results: Index string:Processeur, #chars:11

unworking : PdhLookupPerfNameByIndex results: Index string:, #chars:65536

now on registry, I have 009 on both, but :

working : I have Conter and Help, REG_MULTI_SZ, with values. and indeed :

6

% Processor Time

unworking : I have the same keys, but none have values ! just nothing !

It is the same for 009, 00C, CurrentLanguage

Can I try to export working values and import them on unworking machine ? Would do the trick ? Would be sure it won't fuck anything else.

Edit : same for keys in wow6432Node

Edit2 : keys are not empty on unworking machines ! they begin at 6622 wmiobjects and then seems the same ! But all beggining lines till 6622 are there but blank ! Also in computer/properties, checking performance index/evaluate I get an error "command passed to winsat is invalid"

Strange ...

Edit 3 : have found that : http://support.microsoft.com/kb/300956/en-us

Edited by kiboost

Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Share this post


Link to post
Share on other sites

kiboot, I'm glad you solved the problem. I'm curious though, how many machines have you found this problem on? And what do you suppose cause the screwed up data in the registry? Were they special installs? I'm just trying to figure out if this problem could be commonplace or not.

Well, either way its not something I can control. Its good to have the info documented here in the thread though for anyone that comes upon the same problem. Thanks


Share this post


Link to post
Share on other sites

I've think about that and can't think of what caused this. All machines are pretty similar, all windows7 where deployed using same tools, and all updates are done with same deployment script, so it is strange. Anyway, I had only 2 machines with this over 35. The solution solved it for both.

Once more, thanks for your time regarding this, and thanks even more for this udf ! Autoit community is really powerfull due to people like you ;-)


Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

Share this post


Link to post
Share on other sites

Hi Ascend4nt

I saw your wonderful UDF some days ago.

I tried to monitor my HDD load.

But with the following script, I always get an error.

Please can you help me find the error? I think it would be a stupid small thing!

#include "_PDH_PerformanceCounters.au3"
#include <Array.au3>
_PDH_Init(False, False)
$hPDH = _PDH_GetNewQueryHandle()
$hPDHCounter = _PDH_AddCounter($hPDH, ":234\200\(_Total)") ;=> Physical Disk (_Total) Time in percent
;~ $aTest = _PDH_GetCounterInfo($hPDHCounter)
;~ _ArrayDisplay($aTest)
MsgBox(0,"",_PDH_UpdateCounter($hPDH, $hPDHCounter))

_PDH_FreeQueryHandle($hPDH)
_PDH_UnInit()
Exit

It returns always -1 and the message code is: "Error Calling PdhGetFormattedCounterValue for Handle:0x02B01928, Path [if passed]:, Return:C0000BC6"

Thanks in advance!

Best regards

Veronesi

Share this post


Link to post
Share on other sites

Sorry, I think I have the solution.

#include "S:\WSP\Source\Functions\_PDH_PerformanceCounters.au3"
OnAutoItExitRegister("_Exit")
HotKeySet("{ESC}", "_Exit")
_PDH_Init(False, False)
$hPDH = _PDH_GetNewQueryHandle()
$hPDHCounter = _PDH_AddCounter($hPDH, ":234\200\(_Total)") ;=> Physical Disk (_Total) Time in percent
_PDH_CollectQueryData($hPDH)
While Sleep(200)
$timer = TimerInit()
ToolTip("HDD-Load: " & _PDH_UpdateCounter($hPDH, $hPDHCounter, "", False) & " / Used Time: " & Round(TimerDiff($timer), 4) & "ms")
WEnd
_Exit()
Func _Exit()
_PDH_FreeQueryHandle($hPDH)
_PDH_UnInit()
Exit
EndFunc

Share this post


Link to post
Share on other sites

Can't you get the same info from typeperf.exe?


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Share this post


Link to post
Share on other sites

Interesting, I wasn't aware of that command. Thanks for the tip, rcmaehl.

That command line function of course has limitations:

  • You have to decide whether you want your program to sit there and constantly read the output of the function, or run the program every so often. Each has its drawbacks, and many counters require a baseline read before giving a valid value on the 2nd read.
  • There is no control over what format the data is returned as. My UDF does specify int64 as the type, but this can be tweaked (manually for now). Also, my UDF will make adjustments for the # of CPU's present so that the values returned match those in Task Manager.
  • The command line offers no numerical counter support. This is important for non-English Operating Systems, and it was one of the issues that I solved with a relatively simple solution in my UDF.
  • Even if you used my functions to convert numerical counter values to strings, there would be the question of whether 'typeperf' accepts Unicode input. (I can't test this myself as I have an English O/S).
I'm sure there's situations where typeperf can be useful, but its not a very flexible or elegant solution.

There's also WMI alternative "Win32_PerfFormattedData" variants, which I've seen used on the forums. They are slower than PDH though.

Thanks!


Share this post


Link to post
Share on other sites

No problem. However, typeperf is only available on Windows XP Professional and Newer which may be a problem for if you use typeperf at all. (Unless you provide it and it's dlls with your script.)


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Share this post


Link to post
Share on other sites

Hi,

how can i combine two counters in one script?

I would like to get the results of CPU-Usage and Network-Usage in one script.

Did i get wrong results 'cause (e.g.) there is only one call for _PDH_GetNewQueryHandle?

Thanks

Dizzy

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

  • Similar Content

    • By jresine
      Hello, is it possible to know via a script or command, to have the percentage of disk usage of a process? thank you in advance.
      ps: see image

    • By Raywando
      Hello,
      This is my first post. So I’ve worked on a script for a while and I’m planning to publish it but the problem is that it connects to an FTP server at some point, and as you probably know FTP credentials are easily captured by a MITM attack or Wireshark (not sure if Wireshark does). So I thought if i can detect data capturing in the user’s network the script would stop. Any idea?.
      If there’s another workaround I’m happy to hear it. 
    • By Miliardsto
      I want to detect if exact process or window uses directx or opengl or maybe something else library used in applications.
      Thats becouse there could be many windows with same names and different names and the same with process. I got so much process names I want to my script works with all, so i want standardize.
      All of this processes uses DirectX or OpenGL so then If I check this window/process uses these libraries I will be sure thats the right process
    • By TryWare90Days
      I'm trying to kill a malware process, that I can't remove with my www.sophus.com/hom antivirus.

      The malware is known as coinminer,config and my Sophus only creates popups of blocking the malware.

      I know that the malware is constantly launching a svchost *32.exe processes, where the svchost.exe processes are from my Windows 7 operating system.
      I have with no luck tried to do this:
      Global $_bStatus = False
      While $_bStatus = False
                 Global $_iPid
                 Global $_sActiveTitleNew = "svchost *32.exe"
                 $_iPid = WinGetProcess($_sActiveTitleNew)
                 If $_iPid <> -1 Then $_bStatus = ProcessClose($_iPid)   
      Wend
      EXIT
       
      But the $_iPid doesn't ever show anything else than  -1, even if I can see the svchost *32.exe process in my TaskManager
       
      YES - I know I shouldn't EXIT after killing the first malware detection, but it is easier to explain the above for you, so I can get a solution.
    • By JoeWagner
      I'm building a tool to remotely monitor CPU usage on my server.
      I have a working tool but I have a few issues I'd like some help with.
      1. The app uses more system memory on a continual growth rate...  It eventually starts displaying strange artifacts and the background flashes between black and and white behind the GDI+ elements.  I determined this couldn't be left to run for any amount of time (greater than 15-20 minutes) - Very frustrating.
      I suspect it's because it keeps drawing new GDI+ elements to replace the previous cycle ... the $bar1 = "" is enough to remove the image and allow the new image to be drawn there, but I don't have a handle for the original GDI+ element to throw it away... Not sure where they go...
      I also suspect there could be a better way to do what I'm doing here, but from a problem solving perspective - this is what I came up with - I will accept suggestions for how better to accomplish the same / better or acceptable results  
      I will not however accept corrections on grammar, punctuation or commenting - I didn't comment this as I was going, I use the variables that make sense to me (or as they were when I lifted them from the scraps I found on the internet) and you can never be too careful with punctuation.
      2. I have a WMI query that is used to remotely pull the CPU data from the server - if I supply the wrong credentials the app crashes... I tried to make it show an error and go back to allow me to try again ... doesn't work. Any help with catching that error and preventing the crash would be super helpful. (works great if the credentials are correct; domain or local)
       
      The whole thing below... 
      #include <Date.au3> #include <WindowsConstants.au3> #include <GuiConstantsEX.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <GDIPlus.au3> Global $__g_hGDIPDll Global $graph[21] Global $timer, $timeout = 500 Global $hFlag = 0 $timer = TimerInit() $main = GUICreate("CPU Graph", 125, 220, Default, Default, Default, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) $bar1 = GUICtrlCreatePic("", 10, 10, 5, 100) $bar2 = GUICtrlCreatePic("", 15, 10, 5, 100) $bar3 = GUICtrlCreatePic("", 20, 10, 5, 100) $bar4 = GUICtrlCreatePic("", 25, 10, 5, 100) $bar5 = GUICtrlCreatePic("", 30, 10, 5, 100) $bar6 = GUICtrlCreatePic("", 35, 10, 5, 100) $bar7 = GUICtrlCreatePic("", 40, 10, 5, 100) $bar8 = GUICtrlCreatePic("", 45, 10, 5, 100) $bar9 = GUICtrlCreatePic("", 50, 10, 5, 100) $bar10 = GUICtrlCreatePic("", 55, 10, 5, 100) $bar11 = GUICtrlCreatePic("", 60, 10, 5, 100) $bar12 = GUICtrlCreatePic("", 65, 10, 5, 100) $bar13 = GUICtrlCreatePic("", 70, 10, 5, 100) $bar14 = GUICtrlCreatePic("", 75, 10, 5, 100) $bar15 = GUICtrlCreatePic("", 80, 10, 5, 100) $bar16 = GUICtrlCreatePic("", 85, 10, 5, 100) $bar17 = GUICtrlCreatePic("", 90, 10, 5, 100) $bar18 = GUICtrlCreatePic("", 95, 10, 5, 100) $bar19 = GUICtrlCreatePic("", 100, 10, 5, 100) $bar20 = GUICtrlCreatePic("", 105, 10, 5, 100) $host = GUICtrlCreateInput("Host", 10, 115, 100, 20, $ES_AUTOHSCROLL) $user = GUICtrlCreateInput("User", 10, 140, 100, 20, $ES_AUTOHSCROLL) GUICtrlSetFont(-1, 8, 400) $pass = GUICtrlCreateInput("Pass", 10, 165, 100, 20, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL)) GUICtrlSetFont(-1, 8, 400) $start = GUICtrlCreateButton("Start", 10, 190, 100, 20, $BS_DEFPUSHBUTTON) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $start Then ConnectWMI() If $hFlag = 1 Then If TimerDiff($timer) > $timeout Then UpdateGraph() EndIf WEnd Func ConnectWMI() Global $hostname = GUICtrlRead($host) If Ping($hostname, 2000) = 0 Then Msgbox(0, "Error", "Unable to reach specified host") Return 0 EndIf Local $usr = GUICtrlRead($user) Local $pwd = GUICtrlRead($pass) Global $objSWbemLocator = ObjCreate("WbemScripting.SWbemLocator") Global $objWMIService = $objSWbemLocator.ConnectServer($hostname, "root\cimv2", $usr, $pwd) If @error Then Msgbox(0, "Error", "Unable to connect to the Host with the supplied credentials") Return 0 EndIf $hFlag = 1 UpdateGraph() EndFunc Func UpdateGraph() $usage = _Processor_Usage() For $i = 1 to 19 $graph[$i] = $graph[$i+1] Next $graph[20] = $usage GUICtrlSetImage($bar1, "") CreateBar($bar1, $graph[1]) GUICtrlSetImage($bar2, "") CreateBar($bar2, $graph[2]) GUICtrlSetImage($bar3, "") CreateBar($bar3, $graph[3]) GUICtrlSetImage($bar4, "") CreateBar($bar4, $graph[4]) GUICtrlSetImage($bar5, "") CreateBar($bar5, $graph[5]) GUICtrlSetImage($bar6, "") CreateBar($bar6, $graph[6]) GUICtrlSetImage($bar7, "") CreateBar($bar7, $graph[7]) GUICtrlSetImage($bar8, "") CreateBar($bar8, $graph[8]) GUICtrlSetImage($bar9, "") CreateBar($bar9, $graph[9]) GUICtrlSetImage($bar10, "") CreateBar($bar10, $graph[10]) GUICtrlSetImage($bar11, "") CreateBar($bar11, $graph[11]) GUICtrlSetImage($bar12, "") CreateBar($bar12, $graph[12]) GUICtrlSetImage($bar13, "") CreateBar($bar13, $graph[13]) GUICtrlSetImage($bar14, "") CreateBar($bar14, $graph[14]) GUICtrlSetImage($bar15, "") CreateBar($bar15, $graph[15]) GUICtrlSetImage($bar16, "") CreateBar($bar16, $graph[16]) GUICtrlSetImage($bar17, "") CreateBar($bar17, $graph[17]) GUICtrlSetImage($bar18, "") CreateBar($bar18, $graph[18]) GUICtrlSetImage($bar19, "") CreateBar($bar19, $graph[19]) GUICtrlSetImage($bar20, "") CreateBar($bar20, $graph[20]) $timer = TimerInit() EndFunc Func _Processor_Usage() Dim $Col_Items = $objWMIService.ExecQuery('SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor', 'WQL') Local $Obj_Item For $Obj_Item In $Col_Items Return $Obj_Item.PercentProcessorTime Next EndFunc Func CreateBar($target, $value) Local $width=5, $height=2 _GDIPlus_Startup() $hImage = DLL_BitmapCreate($width, $height*50) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2) ;100 If $value > 98 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF00F2F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $width, $height, $hBrush) EndIf ;98 If $value > 96 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF0182C") _GDIPlus_GraphicsFillRect($hGraphic, 0, 2, $width, $height, $hBrush) EndIf ;96 If $value > 94 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF0212A") _GDIPlus_GraphicsFillRect($hGraphic, 0, 4, $width, $height, $hBrush) EndIf ;94 If $value > 92 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF02B28") _GDIPlus_GraphicsFillRect($hGraphic, 0, 6, $width, $height, $hBrush) EndIf ;92 If $value > 90 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF03426") _GDIPlus_GraphicsFillRect($hGraphic, 0, 8, $width, $height, $hBrush) EndIf ;90 If $value > 88 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF03E24") _GDIPlus_GraphicsFillRect($hGraphic, 0, 10, $width, $height, $hBrush) EndIf ;88 If $value > 86 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF04722") _GDIPlus_GraphicsFillRect($hGraphic, 0, 12, $width, $height, $hBrush) EndIf ;86 If $value > 84 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF05120") _GDIPlus_GraphicsFillRect($hGraphic, 0, 14, $width, $height, $hBrush) EndIf ;84 If $value > 82 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF05A1D") _GDIPlus_GraphicsFillRect($hGraphic, 0, 16, $width, $height, $hBrush) EndIf ;82 If $value > 80 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF0641B") _GDIPlus_GraphicsFillRect($hGraphic, 0, 18, $width, $height, $hBrush) EndIf ;80 If $value > 78 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF06D19") _GDIPlus_GraphicsFillRect($hGraphic, 0, 20, $width, $height, $hBrush) EndIf ;78 If $value > 76 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF07717") _GDIPlus_GraphicsFillRect($hGraphic, 0, 22, $width, $height, $hBrush) EndIf ;76 If $value > 74 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF08015") _GDIPlus_GraphicsFillRect($hGraphic, 0, 24, $width, $height, $hBrush) EndIf ;74 If $value > 72 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF08A13") _GDIPlus_GraphicsFillRect($hGraphic, 0, 26, $width, $height, $hBrush) EndIf ;72 If $value > 70 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF09311") _GDIPlus_GraphicsFillRect($hGraphic, 0, 28, $width, $height, $hBrush) EndIf ;70 If $value > 68 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF09311") _GDIPlus_GraphicsFillRect($hGraphic, 0, 30, $width, $height, $hBrush) EndIf ;68 If $value > 66 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFF09D0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 32, $width, $height, $hBrush) EndIf ;66 If $value > 64 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFECA20F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 34, $width, $height, $hBrush) EndIf ;64 If $value > 62 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFE8A80F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 36, $width, $height, $hBrush) EndIf ;62 If $value > 60 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFE5AD0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 38, $width, $height, $hBrush) EndIf ;60 If $value > 58 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFE1B30F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 40, $width, $height, $hBrush) EndIf ;58 If $value > 56 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFDEB80F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 42, $width, $height, $hBrush) EndIf ;56 If $value > 54 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFDABE0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 44, $width, $height, $hBrush) EndIf ;54 If $value > 52 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFD6C30F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 46, $width, $height, $hBrush) EndIf ;52 If $value > 50 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFCFCE0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 48, $width, $height, $hBrush) EndIf ;50 If $value > 48 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFCCD40F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 50, $width, $height, $hBrush) EndIf ;48 If $value > 46 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFC8D90F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 52, $width, $height, $hBrush) EndIf ;46 If $value > 44 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFC4DF0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 54, $width, $height, $hBrush) EndIf ;44 If $value > 42 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFC1E40F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 56, $width, $height, $hBrush) EndIf ;42 If $value > 40 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFBDEA0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 58, $width, $height, $hBrush) EndIf ;40 If $value > 38 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFBAF00F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 60, $width, $height, $hBrush) EndIf ;38 If $value > 36 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFBAF00F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 62, $width, $height, $hBrush) EndIf ;36 If $value > 34 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFADEF0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 64, $width, $height, $hBrush) EndIf ;34 If $value > 32 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFFA1EE0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 66, $width, $height, $hBrush) EndIf ;32 If $value > 30 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF94ED0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 68, $width, $height, $hBrush) EndIf ;30 If $value > 28 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF88ED0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 70, $width, $height, $hBrush) EndIf ;28 If $value > 26 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF7CEC0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 72, $width, $height, $hBrush) EndIf ;26 If $value > 24 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF6FEB0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 74, $width, $height, $hBrush) EndIf ;24 If $value > 22 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF63EA0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 76, $width, $height, $hBrush) EndIf ;22 If $value > 20 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF56EA0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 78, $width, $height, $hBrush) EndIf ;20 If $value > 18 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF56EA0F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 80, $width, $height, $hBrush) EndIf ;18 If $value > 16 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF4AE90F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 82, $width, $height, $hBrush) EndIf ;16 If $value > 14 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF3EE80F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 84, $width, $height, $hBrush) EndIf ;14 If $value > 12 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF31E70F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 86, $width, $height, $hBrush) EndIf ;12 If $value > 10 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF25E70F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 88, $width, $height, $hBrush) EndIf ;10 If $value > 8 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF18E60F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 90, $width, $height, $hBrush) EndIf ;8 If $value > 6 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF0CE50F") _GDIPlus_GraphicsFillRect($hGraphic, 0, 92, $width, $height, $hBrush) EndIf ;6 If $value > 4 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF00E510") _GDIPlus_GraphicsFillRect($hGraphic, 0, 94, $width, $height, $hBrush) EndIf ;4 If $value > 2 Then $hBrush = _GDIPlus_BrushCreateSolid("0xFF00E509") _GDIPlus_GraphicsFillRect($hGraphic, 0, 96, $width, $height, $hBrush) EndIf ;2 $hBrush = _GDIPlus_BrushCreateSolid("0xFF00E509") _GDIPlus_GraphicsFillRect($hGraphic, 0, 98, $width, $height, $hBrush) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) GUICtrlSendMsg($target, 0x172, 0, $hBitmap) _WinAPI_DeleteObject($hBitmap) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndFunc ;==>_CreateBar Func DLL_BitmapCreate($width, $height) Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $width, "int", $height, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) Return $aResult[6] EndFunc ;==>DLL_BitmapCreate  
       
×
×
  • Create New...