Guest User

updown

a guest
Feb 14th, 2022
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.54 KB | None | 0 0
  1. #include <GUIConstantsEx.au3>
  2. #include <StaticConstants.au3>
  3. #include <WindowsConstants.au3>
  4.  
  5. Local $objWMIService = ObjGet("winmgmts:\\localhost\root\cimv2")
  6. ;- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
  7. ; window
  8. ;- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
  9. Local $iGUIWidth = 150, $iGUIHeight = 13
  10. Local $iRecBytes = 0, $iSenBytes = 0, $aItems
  11.  
  12. Local $hGUI = GUICreate("bps", $iGUIWidth, $iGUIHeight, (@DesktopWidth / 2) - ($iGUIWidth / 2), 1, _
  13.         $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
  14.  
  15. Local $idLabel = GUICtrlCreateLabel(" ", 0, 0, $iGUIWidth, $iGUIHeight, BitOR($SS_CENTER, $SS_CENTERIMAGE), $GUI_WS_EX_PARENTDRAG)
  16. GUISetState()
  17.  
  18. ;- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
  19. ; main loop
  20. ;- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
  21. While 1
  22.     get_bytes()
  23.     GUICtrlSetData($idLabel, "Down:"&Round($iRecBytes / 1024) & "Kbps  Up:" & Round($iSenBytes / 1024) & "Kbps")
  24.     Sleep(1000)
  25. WEnd
  26.  
  27. ;- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
  28. ; get bytes
  29. ;- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
  30. Func get_bytes()
  31.  
  32.     $aItems = $objWMIService.ExecQuery("SELECT BytesReceivedPersec,BytesSentPersec FROM Win32_PerfFormattedData_Tcpip_NetworkInterface", "WQL", 0x10 + 0x20)
  33.  
  34.     For $objItem In $aItems
  35.         $iRecBytes = $objItem.BytesReceivedPersec
  36.         $iSenBytes = $objItem.BytesSentPersec
  37.         ExitLoop
  38.     Next
  39.  
  40. EndFunc   ;==>get_bytes
  41.  
Advertisement
Add Comment
Please, Sign In to add comment