Jump to content
Ascend4nt

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

Recommended Posts

Jack:

Hmm.. I run Win 7 x64 mostly nowadays, and there is no problem with that code on my machine.

This message shouldn't show up if pdh.dll is working as it should, and the network counters are reporting performance information as they should:

There are still * wildcards left after a call to PdhExpandWildCardPathW!

*Perhaps* there are no network adapters showing up in your virtual environment? That would make the most sense.

In any case, the code is working as it should, and returning an error where it should (and reporting that info to you in the console as well), so the code itself is fine. Most likely its the virtual OS you are using, or lack of any virtual adapters.

I would suggest 'VMWare Workstation' as the best O/S-emulator out there (or the free VMWare Player).. it works flawlessly in emulating most every O/S I've thrown at it, and I have done a lot of cross-O/S testing/debugging using it.

Edited by Ascend4nt

Share this post


Link to post
Share on other sites

I would suggest 'VMWare Workstation' as the best O/S-emulator out there (or the free VMWare Player).. it works flawlessly in emulating most every O/S I've thrown at it, and I have done a lot of cross-O/S testing/debugging using it.

Looks like your right , VMWare does simulate flawlessly as i installed win7 on this comp as a dual boot last night and im still getting the same problem as my VMWare win7x86 is showing.

I defiantly have a network adapter on all OS's installed on this comp. i have checked the .dll exists and that there are network adapters on all os's (Virtual or otherwise)

so far iv only tested on 1 comp, on a virtual os win7 x86 and a standard installation on win7 x86 , i'll try to get it tested on another comp with win7 x86 when i get the opportunity.

many thx for your quick response :unsure:

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

Hmm.. Jack, try running 'TestPDH_PerformanceCounters' and experiment with the different counters. Also see what shows up for "Network Interface" and what is reported.

Since I've tried this on multiple O/S's and haven't experienced the problems you are, I have no way of knowing what's really happening on your PC.. so thanks for experimenting with this.

Also.. do a search on 'Win32_PerfFormattedData_Tcpip_NetworkInterface' in the forums and try out the different UDF's people have written. That's using the same performance counters, but through the slower WMI interface.


Share this post


Link to post
Share on other sites

well iv had a little play with your first suggestions and found that the problem lays with the last network adapter on the list of instances of selected object. "Local area Connection*9". The other 2 work fine (which is a good sigh) but if i try with that adapter or "all" i get the "There are still * wildcards left after a call to PdhExpandWildCardPathW!" error. I really dont know what it means by connection*9 I dont know where it gets the "9" from ?

So heres a screen shot of what im talking about & the console output from trying to display that last instance.

Posted Image

CPU count result:1
_PDH_BrowseCounters() call, PDH DLL 'handle' (or just 'pdh.dll'):1
Selected Counter from _PDH_Browse_Counters:\Network Interface(Local Area Connection* 9)\*
_PDH_GetCounterList() call, $sCounterWildcardPath='\Network Interface(Local Area Connection* 9)\*', PDH DLL 'handle' (or just 'pdh.dll'):1
_PDH_GetCounterList: PdhExpandWildCardPathW 2nd Call successful, 1st reported Bufsize (adjusted+1 on Win2K systems):1520, 2nd call's Bufsize (should match):1520
There are still * wildcards left after a call to PdhExpandWildCardPathW!
Original wildcard path:\Network Interface(Local Area Connection* 9)\*
_PDH_GetCounterList() call time:9.36683293547085 ms

Many thx.


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

Huh, that is weird! Since '*' represents wildcards, and in Vista+, the wildcards can be placed within individual parts of the counter path, it doesn't quite make sense why a counter would be reported with a '*' in its name. But it does give us a reason why the code isn't working - my sanity-check on return from the API call needs to be removed, or changed to allow an 'ignore' parameter.

If you look for this in _PDH_PerformanceCounters.au3, you can comment out this section in _PDH_GetCounterList():

; Is there *still* wildcards left in the pattern?? Then it will not work, not even with further expansion
    If StringInStr($sCounterList,'*',1) Then
        ; DEBUG
        _PDH_DebugWrite("There are still * wildcards left after a call to PdhExpandWildCardPathW!"&@CRLF& _
            "Original wildcard path:"&$sCounterWildcardPath)    ;&", Results:"&@CRLF& _
            ;StringReplace($sCounterList,ChrW(0),@CRLF))
        Return SetError(1,0,$aCounterList)
    EndIf

After commenting that out, it should now work for you.

In the meantime, I'll have to think a bit on which conditions I should or shouldn't be checking for wildcard returns (if at all).

*edit: wildcard sanity-check fix is in the latest version (5/22/2011) - uses a more reliable method

Edited by Ascend4nt

Share this post


Link to post
Share on other sites

That got it working , thx,

Maybe i could get it to check if the "*" is in the name of the returned adapter list and then reject that adaptor as it shows up in the list on the netmeter im building , i didn't click on it to see what would happen (maybe i should have done).

I wonder why my comp causes this error , my VM win7 is a brand new installation so it cant really be anything to do with that must be the comps network card somehow.

I was wondering what problems could the removal of your filter cause on other comps ?

Anyhow , thx for your help and great work :unsure:

cheers.

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

New updates:

- New UDF: PDH_HardDiskUsageExample.au3

- _PDH_PerformanceCounters.au3 UDF changes:

- Added:

_PDH_RegistryCheck(), _PDH_RegistryEnable(), and _PDH_RegistryDisable() -> to allow checking & altering Performance Counter availability on local OR Remote PC. Note that ADMIN rights are req'd for making changes.

- Changed:

_PDH_Init() & _PDH_UnInit altered to work with new Registry modification code

_PDH_Init() now takes 3 optional parameters regarding Registry state (force registry on, restore on exit, PC Name)

_PDH_BrowseCounters() - added new parameters to allow customization, now allows multiple selections to be returned in an array

- Fixed:

_PDH_BrowseCounters() - default title was not showing for Win7

_PDH_GetCounterList() - Wildcard sanity-check fixed for special cases where a * is part of the Instance name


Share this post


Link to post
Share on other sites

Many thx Ascend4nt , your speedy work is highly appreciated :unsure:

Shall check out what you've done (with my particular problem) later today.

Thx.


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

hmmm ... don't know why but it's not showing the Memory used by a process right ... i'm using Windows 7 32x

You're going to have to be a bit more specific. Is one of the included modules not reporting memory, or your own code? If its the former, let me know which module & the output log from Scite. If its your own code, please post the relevant bits. Thanks


Share this post


Link to post
Share on other sites

That's because 'TestPDH_TaskManager.au3' takes a snapshot and is a static non-updating UDF. If you check the first post you'll see I commented a couple of times about that needing work, and this is one of the notes listed (in the 1st post) for that particular UDF:

NOTES:

- The screen does NOT update, and the UDF is a MESS. This is due to a number of reasons - the biggest one being laziness on my behalf. Plus I need to figure out how best to manage ListView changes.

Since Task Manager itself continually updates its stats, the memory will only match at the moment 'TestPDH_TaskManager' is run (or for processes that aren't actively doing anything requiring memory allocation).

You will see however, if you run TestPDH_PerformanceCounters, and choose 'Process\Working Set', that it reports real-time information for memory. Unfortunately, it doesn't convert the value into KB, so you'd have to do that bit of math yourself.

Maybe in a future release I'll leave the TaskManager example out, or put a MsgBox up stating this information.. or if I'm willing to rewrite it and tackle the management of list changes, I'll release an 'active' version.

Otherwise, for now its just there for a simple example of what can be done. Sorry!


Share this post


Link to post
Share on other sites

That's because 'TestPDH_TaskManager.au3' takes a snapshot and is a static non-updating UDF. If you check the first post you'll see I commented a couple of times about that needing work, and this is one of the notes listed (in the 1st post) for that particular UDF:

Since Task Manager itself continually updates its stats, the memory will only match at the moment 'TestPDH_TaskManager' is run (or for processes that aren't actively doing anything requiring memory allocation).

You will see however, if you run TestPDH_PerformanceCounters, and choose 'Process\Working Set', that it reports real-time information for memory. Unfortunately, it doesn't convert the value into KB, so you'd have to do that bit of math yourself.

Maybe in a future release I'll leave the TaskManager example out, or put a MsgBox up stating this information.. or if I'm willing to rewrite it and tackle the management of list changes, I'll release an 'active' version.

Otherwise, for now its just there for a simple example of what can be done. Sorry!

I figured it out that it's static but the difference is very big and I opened windows task manager and searched for a process whos memory doesn't change and the "TestPDH_TaskManager"was still showing it wrong.

For example:

BumpTop: (win) 37.388 K ... (test) 48.476 K

plugin-container.exe: (win) 8.064 K ... (test) 13.400 K

YahooMessenger.exe: (win) 31.968 K ... (test) 40.864 K

*win = Windows Task Manager

*test = TestPDH_TaskManager

Unfortunately, it doesn't convert the value into KB, so you'd have to do that bit of math yourself.

... i need to divide it by 1024?

Share this post


Link to post
Share on other sites

I figured it out that it's static but the difference is very big and I opened windows task manager and searched for a process whos memory doesn't change and the "TestPDH_TaskManager"was still showing it wrong.

As I said, it grabs memory usage at the time it runs, once. Make sure you are looking at 'Working Set (Memory)', not 'Memory (Private Working Set)' in Task manager on Windows 7.

... i need to divide it by 1024?

Yep (for the values you see in 'TestPDH_PerformanceCounters' when using memory counters). You can code this yourself, or look at some of the example code. _ProcessAll* functions allow adding automatic division for individual counters.

*edit: clarification on division info

Edited by Ascend4nt

Share this post


Link to post
Share on other sites

Hi Ascend4nt,

thanks for sharing this great code.

On my Win7 HP i'll get errors:

Error calling PdhGetFormattedCounterValue at index #11, Handle:0x040B5218, Return:C0000BC6 CStatus:C0000BBA

Error calling PdhGetFormattedCounterValue at index #12, Handle:0x04AB10B8, Return:C0000BC6 CStatus:C0000BBA

Error calling PdhGetFormattedCounterValue at index #13, Handle:0x04AB11C0, Return:C0000BC6 CStatus:C0000BBA

Error calling PdhGetFormattedCounterValue at index #14, Handle:0x04AB12C8, Return:C0000BC6 CStatus:C0000BBA

Error calling PdhGetFormattedCounterValue at index #15, Handle:0x04AB13D0, Return:C0000BC6 CStatus:C0000BBA

PdhCloseQuery DLL call successful

PdhCloseQuery DLL call successful

And the overall percent is not correct (as you can see in the screenshots).

Do you have an idea?

Greats

Dizzy

post-83-0-36996700-1306604257_thumb.png

post-83-0-23258600-1306604269_thumb.png

Share this post


Link to post
Share on other sites

And the overall percent is not correct (as you can see in the screenshots).

Do you have an idea?

Hmm, that does look wrong. It should read around '6 %' for the 1st and around '4 %' for the 2nd. I'm not sure why its reporting the wrong info for you. Try TestPDH_PerformanceCounters to see what it reports. Wait for the update though, as there is a bug in that module I found today.

Also, ignore those other errors - that's due to a call to gather performance #'s before the counters are ready. They need a little initialization time. The new update will include what I call a 'baseline-sleep' model before gathering info on certain performance counters. This is what I should have been following from the start, but I didn't like adding too long of a sleep in. It seems that 1/4 second is good enough, and that's what I'm setting all the examples to.


Share this post


Link to post
Share on other sites

Okay, UDFs are updated again. The console output should now be much cleaner due to differing Debug-output modes, and the 'baseline-sleep' model I should have been using since long ago (gets rid of alot of nagging error messages). Here's the whole list of changes:

5/28/2011:

- Fixed: Bug introduced in last version: Single-item selection in 'Browse Counters Dialog' returning cut-off strings.

- Fixed: _ProcessAll* UDF function had misspelling

- Fixed: The 'Browse Counters Dialog' doesn't display instances in some weird cases. TestPDH_PerformanceCounters now deals with this properly

- Change: TestPDH_TaskManager title reflects static nature of UDF.

- Change: Removed PC Name parameter from _PDH_Init(). Don't know what I was thinking.

- Change: DEBUG information defaults to error-only mode now. Set $PDH_DEBUG to 2 to show ALL Debug info

- Change: All examples (save for one) now follow the 'baseline-sleep' model for collecting data (not always needed)

- Added: _PDH_ObjectBaseCollectQueryData(), _PDH_ProcessObjectCollectQueryData(), & _PDH_ProcessAllCollectQueryData() (to better support baseline-sleep)


Share this post


Link to post
Share on other sites

Hi,

I have a problem looking for getting only full cpu usage. It works perfeclty, apart the script grow in ram approximately 20Ko per minute when executed every 2sec.

Any idea to stop this behavior ?

#include "..\PDHPerfCounters\_PDH_PerformanceCounters.au3"
Global $hPDHQuery,$hCPUCounter,$iCPUUsage

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
_PDH_UnInit($hPDHQuery)
;ConsoleWrite("CPU Usage = "&$iCPUUsage&@CRLF)
EndFunc
While 1
_PDH_countcpu()
Sleep(2000)
WEnd

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

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...