Advertisement
Guest User

mInfo.au3

a guest
Jun 14th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.42 KB | None | 0 0
  1. #include <Functions.au3>
  2. #include <GUIConstantsEx.au3>
  3. #include <WindowsConstants.au3>
  4. #include <GuiButton.au3>
  5.  
  6. $iState = _GetNetConnection()
  7. $iOldState = $iState
  8.  
  9. $cState = _Battery_IsCharging()
  10. $cOldState = $cState
  11. Switch $cState
  12.     Case True
  13.         $cStateText = "Lädt"
  14.     Case False
  15.         $cStateText = "Entlädt"
  16. EndSwitch
  17.  
  18. $Charge = _Battery_GetCharge()
  19. $OldCharge = _Battery_GetCharge()
  20.  
  21. $Voltage = _Battery_GetVoltage()
  22. $OldVoltage = $Voltage
  23.  
  24. $CPU = GetCPUUsage()
  25. $OldCPU = $CPU
  26.  
  27. $gui = GUICreate("mInfo", 161, 133, -1, -1, -1, -1)
  28. If ($iState == True) Then
  29.     $NetLabel = GUICtrlCreateLabel("Verbunden", 50, 110, 81, 15, -1, -1)
  30.     GUICtrlSetColor($NetLabel, "0x00FF00")
  31. Else
  32.     $NetLabel = GUICtrlCreateLabel("Nicht Verbunden", 50, 110, 81, 15, -1, -1)
  33.     GUICtrlSetColor($NetLabel, "0xFF0000")
  34. EndIf
  35. GUICtrlCreateLabel("Internet:", 10, 110, 41, 15, -1, -1)
  36. GUICtrlCreateLabel("Akkuladung: ", 10, 10, 83, 15, -1, -1)
  37. $cStateLabel = GUICtrlCreateLabel("Akkustatus: " & $cStateText, 10, 30, 91, 15, -1, -1)
  38. $ChargeLabel = GUICtrlCreateLabel(_Battery_GetCharge() & "%", 73, 10, 83, 15, -1, -1)
  39. $VoltageLabel = GUICtrlCreateLabel("Spannung: " & _Battery_GetVoltage() & "V", 10, 50, 98, 15, -1, -1)
  40. $CPULabel = GUICtrlCreateLabel("CPU: " & GetCPUUsage() & "%", 10, 80, 100, 15, -1, -1)
  41. GUISetState(@SW_SHOW, $gui)
  42.  
  43.  
  44. While 1
  45.     $nMsg = GUIGetMsg()
  46.     Switch $nMsg
  47.         Case $GUI_EVENT_CLOSE
  48.             Exit
  49.     EndSwitch
  50.    
  51.     $CPU = GetCPUUsage()
  52.     If $CPU <> $OldCPU Then
  53.         $OldCPU = $CPU
  54.         GUICtrlSetData($CPULabel, "CPU: " & $CPU & "%")
  55.     EndIf
  56.    
  57.     $Voltage = _Battery_GetVoltage()
  58.     If $Voltage <> $OldVoltage Then
  59.         $OldVoltage = $Voltage
  60.         GUICtrlSetData($VoltageLabel, "Spannung: " & $Voltage & "V")
  61.     EndIf
  62.    
  63.     $Charge = _Battery_GetCharge()
  64.     If $Charge <> $OldCharge Then
  65.         $OldCharge = $Charge
  66.         GUICtrlSetData($ChargeLabel, $Charge & "%")
  67.     EndIf
  68.    
  69.     $cState = _Battery_IsCharging()
  70.     If $cState <> $cOldState Then
  71.         $cOldState = $cState
  72.         If (_Battery_IsCharging() == True) Then
  73.             GUICtrlSetData($cStateLabel, "Akkustatus: Lädt")
  74.         Else
  75.             GUICtrlSetData($cStateLabel, "Akkustatus: Entlädt")
  76.         EndIf
  77.     EndIf
  78.    
  79.     $iState = _GetNetConnection()
  80.     If $iState <> $iOldState Then
  81.         $iOldState = $iState
  82.         If ($iState == True) Then
  83.             GUICtrlSetData($NetLabel, "Verbunden")
  84.             GUICtrlSetColor($NetLabel, 0x00FF00)
  85.         Else
  86.             GUICtrlSetData($NetLabel, "Nicht Verbunden")
  87.             GUICtrlSetColor($NetLabel, 0xFF0000)
  88.         EndIf
  89.     EndIf
  90. WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement