QB64.org Forum

Active Forums => Programs => Topic started by: Richard Frost on December 18, 2021, 02:40:19 am

Title: Monitor CPU temperature in Windows
Post by: Richard Frost on December 18, 2021, 02:40:19 am
1) delete the first line if you don't download the icon file
2) needs liberati.ttf, a font that used to be included with QB64
3) works as is with XP, requires running as administrator in 10

Code: QB64: [Select]
  1. $ExeIcon:'temp2.ico'
  2. q$ = Chr$(34) '                             quote character
  3. Screen _NewImage(140, 64, 32)
  4. If _FileExists("liberati.ttf") = 0 Then System
  5. f& = _LoadFont("liberati.ttf", 60)
  6.  
  7. Open "ztemp.bat" For Output As #1
  8. Print #1, "@echo off"
  9. Print #1, "for /f " + q$ + "skip=1 tokens=2 delims==" + q$ + " %%A in ('wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature /value') do set /a " + q$ + "HunDegCel=(%%~A*10)-27315" + q$
  10. Print #1, "echo %HunDegCel:~0,-2%.%HunDegCel:~-2% Degrees Celsius"
  11.  
  12.     Shell _Hide "ztemp.bat > ztemp.dat"
  13.     If _FileExists("ztemp.dat") Then
  14.         Cls
  15.         Open "ztemp.dat" For Input As #1
  16.         Line Input #1, z$
  17.         Close #1
  18.         z& = Val(z$)
  19.         _Font f&: _PrintString (10 - (z < 100) * 20, 5), LTrim$(Str$(z&))
  20.         _Font 14: Locate 2, 15: Print Chr$(248); "C";
  21.     End If
  22. Shell "del ztemp*.*"
Title: Re: Monitor CPU temperature in Windows
Post by: DANILIN on December 18, 2021, 01:19:52 pm
cpu_temp.bat
Code: [Select]
@ wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature
@ pause
CurrentTemperature
3262
3030
Kelvin