Skip to content

overheat.py

LopeKinz edited this page Jul 6, 2023 · 1 revision

overheat.py

This module provides a function to turn off all fans using the wmi library.

Importing the Required Library

To use the overheat module, you need to import the wmi library. You can do this by adding the following code at the beginning of your script:

import wmi

Function: turn_off_all_fans()

This function turns off all fans in the system. It uses the wmi library to interact with the Windows Management Instrumentation (WMI) and control the fans.

Code

import wmi

def turn_off_all_fans():
    c = wmi.WMI()
    for fan in c.Win32_Fan():
        fan.SetSpeed(0)

Description

The turn_off_all_fans() function initializes the wmi object, which represents the WMI service on the local machine. It then iterates over all the fans in the system using the Win32_Fan class provided by the wmi library. For each fan, it calls the SetSpeed(0) method to set the fan speed to 0, effectively turning it off.

Make sure to call this function when needed to turn off all the fans in your system.

Example Usage

Here's an example of how you can use the turn_off_all_fans() function:

import overheat

overheat.turn_off_all_fans()

In this example, the overheat module is imported, and the turn_off_all_fans() function is called to turn off all the fans in the system.

Please note that this code is specific to Windows systems due to its reliance on the WMI library.

Clone this wiki locally