Git Product home page Git Product logo

fanctrl's Introduction

fanCtrl

A C# program for controlling computer fan speed (Hardware).

image

Implementation Principle:

Initially, the plan was to use WMI for adjustments, but the WMI interface only provided monitoring capabilities without modification features. Therefore, OpenHardwareMonitorLib.dll is currently used as the interface, offering a range of commands for monitoring and adjusting hardware at a low level. To avoid issues with multiple instances running concurrently, the Mutex class is employed to ensure that only one instance of the program is running. Mutex is a synchronization primitive used to coordinate multiple threads' access to a shared resource.

The program tries to create a global mutex named "Global\OHWM_FanControl" when it runs. If the program is the first to attempt creating this mutex (i.e., createdNew is true), it gains initial ownership of the mutex and can continue executing. If an instance is already running (createdNew is false), the program outputs a message and exits. Running the program again will prompt the existing instance to adjust the fan speed. Any input in the main instance interface will close the main instance.

V0.51

The original program, written in C#, requires administrative rights to take control of the fan. Two instances were created to send acceleration and deceleration signals, but these also required administrative rights to operate.

To avoid constant UAC prompts for administrative permission when sending signals, Task Scheduler is used to bypass the UAC prompts. (Currently, users need to manually create tasks named fanSlow and fanFast in the Task Manager.)

The two C# programs in the function folder respectively trigger the fanSlow and fanFast tasks in the system. In theory, there is no need to write .exe files, as .vbs files could suffice. The main reason for creating .exe files is to allow third-party programs to assign shortcuts to run these executables, which is not feasible with .vbs scripts.

V0.51.1

Added functionality to control the speed of the water pump. The default is 25% (0.9L/min), and when the fan speed reaches above 70%, the water pump speed is adjusted to 35% (1.1L/min).

Precautions:

  • Files must be deployed on a local disk as network-connected disks cannot initiate administrative rights.
  • At least one main instance must be running to maintain the adjustment of fan speed.
  • Due to the involvement of hardware device performance and administrative rights operations, please ensure to enable administrative rights or run the program as an administrator, otherwise, errors will occur.
  • Manual operations are still needed after deployment to complete the automation setup. If time permits, future improvements will aim for a one-click lazy deployment.

Interface

  • Start
    image
  • After some commands executed
    image

Steps:

Compilation needs to be done using the VS command line: csc /out:fanSpeedFast.exe fanSpeedFast.cs Alternatively, use the dotnet build and publish commands to generate executable files for fast.exe or slow.exe.

Reducing Intrusiveness During Use

Q: Why not use PowerShell, Shortcut, or cmd? I personally tried all three and they would pop up a window briefly, but theoretically, it should be avoidable. However, vbs is simpler, so I used it.

Acknowledgements:

Thanks to all the open-source developers and the creators and maintainers of OpenHardwareMonitor.

fanctrl's People

Contributors

yifanwow avatar

Stargazers

 avatar  avatar Chengxiang Wu avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.