[hta] usage en pourcentage de votre cpu%

Description

Pour connaître le pourcentage de la charge de votre CPU en utilisant les couleurs suivant CPU% :

vert si CPU% < 20%
Orange si 20% < CPU% < 70%
Rouge si CPU% > 70%

Source / Exemple :


<html>
<head>
<title></title>
<HTA:APPLICATION 
    ID="CPU%-AutoRefresh"
    APPLICATIONNAME="Usage CPU en %"
    BORDER="dialog"
    BORDERSTYLE="complex"
    CONTEXTMENU="no"
    SYSMENU="no"
    MAXIMIZEBUTTON="no"
    SCROLL="no" 
    ICON="Verifier.exe"
>
</head>
<META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
<SCRIPT LANGUAGE="VBScript">
    Sub Window_OnLoad
        CenterWindow 100,100
        Refresh 
        iTimerID = window.setInterval("Refresh", 1000)
    End Sub
    
   Sub CenterWindow(x,y)
        window.resizeTo x, y
        iLeft = window.screen.availWidth/2 - x/2
        itop = window.screen.availHeight/2 - y/2
        window.moveTo ileft, itop
    End Sub
    Sub Refresh
       strHTML = ""
       strComputer = "."
       Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
       Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Processor")
       
       For Each objProcess in colProcesses
       Self.document.title = "Usage CPU "& objProcess.LoadPercentage & " %"
       If objProcess.LoadPercentage < 20 Then
           strHTML ="<center><b><font color='LightGreen' size='6'>"& objProcess.LoadPercentage & " %</font>"
       ElseIf objProcess.LoadPercentage < 70 Then
           strHTML ="<center><b><font color='Orange' size='6'>"& objProcess.LoadPercentage & " %</font>"
        Else
           strHTML ="<center><b><font color='Red' size='6'>"& objProcess.LoadPercentage & " %</font>"
           End if
       Next
       UsageCPU.InnerHTML = strHTML
    End Sub
    
Sub Fermer()
Question = MsgBox("Voulez-vous Fermer cette Application ?",VBYesNO+VbQuestion,"Fermeture de l'application")
If Question = VbYes Then
Window.close
Else
    Exit Sub
End If
End Sub
</SCRIPT>
<body Title="Double-cliquer ici pour fermer cette Application !" ondblclick="Fermer()" STYLE="font:14 pt arial; color:white;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')"<span id = "UsageCPU"></span></body>
</html>

Conclusion :


Vos remarques et vos commentaires sont les Bienvenues !

Codes Sources

A voir également