Hallo,
ich brauche mal wieder Hilfe bei einem Script:
Mein Sript soll einige Informationen zur Maus anzeigen und gleichzeitig die CPU-Auslastung anzeigen. Leider klappt bei mir immer nur eine der Beiden Aufgaben. Ich hab es schon mit einem zweiten AdlibEnable versucht, aber es klapp einfach nicht . Könnt ihr mir sagen, wo der Fehler ist?
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $wbemFlagReturnImmediately = 0x10
Global $wbemFlagForwardOnly = 0x20
Global $colItems = ""
Global $strComputer = "localhost"
Global $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
Global $dpi = _GetLogPixels()
Global $c = 0, $old = 0
GUICreate("Mouse Meter", 300, 80, 852, 0, $WS_POPUPWINDOW, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$Label1 = GUICtrlCreateLabel('Die Maus hat bisher 0 Zentimeter zurückgelegt!', 0, 0, 300, 20)
$Label2 = GUICtrlCreateLabel("X-Koordinate: - " & @LF & "Y-Koordinate: -", 0, 13, 300, 30)
$Label3 = GUICtrlCreateLabel("Farbe der Koordinaten: -", 0, 40, 300, 30)
$Label4 = GUICtrlCreateLabel("CPU-Auslastung: -", 0, 60, 300, 30)
GUISetState(@SW_SHOW)
[/autoit] [autoit][/autoit] [autoit]Func _GetLogPixels()
Local $LogPixels
Local $objWMIService = ObjGet('winmgmts:\\localhost\root\CIMV2')
Local $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_DisplayConfiguration', 'WQL', 0x30)
If IsObj($colItems) Then
For $objItem In $colItems
$LogPixels = $objItem.LogPixels
Next
Return $LogPixels
EndIf
Return SetError(1, 0, 0)
EndFunc ;==>_GetLogPixels
AdlibEnable("MouseUpdate", 10)
[/autoit] [autoit][/autoit] [autoit]While 1
ProzessorUp()
WEnd
Func MouseUpdate()
$pos = MouseGetPos()
$x1 = $pos[0]
$y1 = $pos[1]
Sleep(10)
$pos2 = MouseGetPos()
$x2 = $pos2[0]
$y2 = $pos2[1]
$a = Sqrt(($x2 - $x1) ^ 2 + ($y2 - $y1) ^ 2)
$b = Round($a, 0)
$c = $c + $b
If $c = $old Then Return
$old = $c
$cm = Round($c / $dpi * 2.54, 0)
$p = Hex(PixelGetColor($pos2[0], $pos2[1]), 6)
GUICtrlSetData($Label1, "Die Maus hat ungefähr " & $cm & " Zentimeter zurückgelegt!")
GUICtrlSetData($Label2, "X-Koordinate: " & $pos2[0] & @LF & "Y-Koordinate: " & $pos2[1])
GUICtrlSetData($Label3, "Farbe der Koordinaten: " & $p)
EndFunc ;==>MouseUpdate
Func ProzessorUp()
$colItems = $objWMIService.ExecQuery("SELECT LoadPercentage FROM Win32_Processor", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
$i = 0
For $objItem In $colItems
If $i = 0 Then
GUICtrlSetData($Label4, "CPU-Auslastung: " & $objItem.LoadPercentage & "%")
EndIf
Next
EndIf
EndFunc ;==>ProzessorUp