Last active
July 1, 2025 06:40
-
-
Save codeFlane/a69450789577f3503d2f93acf0d72ce0 to your computer and use it in GitHub Desktop.
Getting CPU temperature using WinTmp module, print using text2art, window editing using win32gui. Requirements: pywin32 art rich
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from art import text2art | |
import WinTmp | |
import pyuac | |
from rich import print | |
from time import sleep | |
from os import system | |
import win32gui | |
import win32con | |
if not pyuac.isUserAdmin(): | |
pyuac.runAsAdmin() | |
quit() | |
system('mode 47, 10') | |
def get_cpu_temp(): | |
# print(WinTmp.CPU_Temp()) | |
return round(WinTmp.CPU_Temp(), 2) | |
hwnd = win32gui.GetForegroundWindow() | |
win32gui.ShowWindow(hwnd, win32con.SW_SHOW) | |
style = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE) | |
style &= ~win32con.WS_THICKFRAME | |
style &= ~win32con.WS_MAXIMIZEBOX | |
style &= ~win32con.WS_MINIMIZEBOX | |
win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, style) | |
win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE) | |
while True: | |
temp = get_cpu_temp() | |
system('cls') | |
# print(temp) | |
print(f'CPU temp:\n{"[green]" if temp < 60 else "[yellow]" if temp < 80 else "[red]"} {text2art(str(temp), 'usa')}', end='\r', flush=True) | |
sleep(0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment