Esempio n. 1
0
def TempAware(DL):
    import clr  # the pythonnet module. You might need to install it 'pip install pythonnet'
    clr.AddReference(
        'TempAware\\OpenHardwareMonitorLib.dll')  #enter your dll path
    from OpenHardwareMonitor.Hardware import Computer
    tempature = 0
    colorplusdown = 0
    c = Computer()
    c.CPUEnabled = True  # get the Info about CPU
    c.GPUEnabled = True  # get the Info about GPU
    c.Open()
    for DName in range(0, len(c.Hardware)):
        if ("GPU" in str(c.Hardware[DName])) or ("gpu" in str(
                c.Hardware[DName])):
            while True:
                for Sen in range(0, (len(c.Hardware[DName].Sensors))):
                    if "temperature" in str(
                            c.Hardware[1].Sensors[Sen].Identifier):
                        tempature = (c.Hardware[1].Sensors[Sen].get_Value())
                        print(tempature)
                        c.Hardware[1].Update()
                        if 19 > tempature:
                            for Device in DL:
                                colorplusdown = (tempature) * 255 / 19
                                Device.set_color(
                                    RGBColor(int(0), int(0 + colorplusdown),
                                             int(255)))
                            time.sleep(1)
                        elif 38 > tempature >= 19:
                            for Device in DL:
                                colorplusdown = (tempature - 19) * 255 / 19
                                Device.set_color(
                                    RGBColor(int(0), int(255),
                                             int(255 - colorplusdown)))
                            time.sleep(1)
                        elif 57 > tempature >= 38:
                            for Device in DL:
                                colorplusdown = (tempature - 38) * 255 / 19
                                Device.set_color(
                                    RGBColor(int(0 + colorplusdown), int(255),
                                             int(0)))
                            time.sleep(1)
                        elif 76 >= tempature >= 57:
                            for Device in DL:
                                colorplusdown = (tempature - 57) * 255 / 10
                                Device.set_color(
                                    RGBColor(int(255),
                                             int(255 - colorplusdown), int(0)))
                            time.sleep(1)
Esempio n. 2
0
sensors = [
    '/intelcpu/0/temperature/0', '/intelcpu/0/temperature/1',
    '/intelcpu/0/temperature/2', '/intelcpu/0/temperature/3'
]

hardware = ['/intelcpu/0']

__sensors = []
__hw = []

comp = Computer()

comp.MainboardEnabled = False
comp.RAMEnabled = False
comp.CPUEnabled = True
comp.GPUEnabled = False
comp.HDDEnabled = False
comp.Open()

for hw in comp.Hardware:
    print(hw.Identifier, hardware)
    if str(hw.Identifier) in hardware:
        __hw.append(hw)

        hw.Update()
        for sensor in hw.Sensors:
            if str(sensor.Identifier) in sensors:
                __sensors.append(sensor)

while True:
Esempio n. 3
0
import sys
import time
import clr

sys.path.append(r"D:\Github\Repositories\arduino\cpuinfo")
clr.AddReference("OpenHardwareMonitorLib")
from OpenHardwareMonitor.Hardware import Computer

computer = Computer()
computer.CPUEnabled = True
computer.Open()
# print(computer.Hardware[0].Identifier)
# print(computer.Hardware[0].Sensors)

while True:
    for a in range(0, len(computer.Hardware[0].Sensors)):
        # print(a)
        # print(computer.Hardware[0].Sensors[a].Identifier)
        if str(computer.Hardware[0].Sensors[a].Identifier
               ) == "/intelcpu/0/temperature/4":
            print(computer.Hardware[0].Sensors[a].Value)
    computer.Hardware[0].Update()
    time.sleep(1)
    # print("=================")
Esempio n. 4
0
import time
import datetime
import wmi

if __name__ == "__main__":

    # w = wmi.WMI(namespace=r"D:\Tools\OpenHardwareMonitor")
    #
    # temperature_infos = w.Sensor()
    #
    # for sensor in temperature_infos:
    #     if sensor.SensorType == u'Temperature':
    #         print(sensor.Name)
    #         print(sensor.Value)

    import clr  # the pythonnet module.
    clr.AddReference(r'YourdllPath')
    # e.g. clr.AddReference(r'OpenHardwareMonitor/OpenHardwareMonitorLib'), without .dll

    from OpenHardwareMonitor.Hardware import Computer

    c = Computer()
    c.CPUEnabled = True  # get the Info about CPU
    c.GPUEnabled = True  # get the Info about GPU
    c.Open()
    while True:
        for a in range(0, len(c.Hardware[0].Sensors)):
            # print(c.Hardware[0].Sensors[a].Identifier)
            if "/temperature" in str(c.Hardware[0].Sensors[a].Identifier):
                print(c.Hardware[0].Sensors[a].get_Value())
                c.Hardware[0].Update()
Esempio n. 5
0
import clr
import time
clr.AddReference("C:/Users/63450/Desktop/毕业实习/day1/OpenHardwareMonitorLib.dll"
                 )  #加载C#的库这个库网上可以下载
from OpenHardwareMonitor.Hardware import Computer
computer_tmp = Computer()  #实例这这个类

computer_tmp.CPUEnabled = True
computer_tmp.GPUEnabled = True  #获取GPU温度时用
computer_tmp.HDDEnabled = True
computer_tmp.RAMEnabled = True  #获取内存温度时用

computer_tmp.Open()

print(computer_tmp.Hardware[0].Identifier)
print(computer_tmp.Hardware[0].Sensors)
while True:
    for a in range(0, len(computer_tmp.Hardware[0].Sensors)):
        #print computer_tmp.Hardware[0].Sensors[a].Identifier
        if str(computer_tmp.Hardware[0].Sensors[a].Identifier
               ) == "/intelcpu/0/temperature/4":
            print(computer_tmp.Hardware[0].Sensors[a].Value)
            computer_tmp.Hardware[0].Update()
    time.sleep(1)