1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Modified "speedfan api control" - C++.

Discussion in 'Overclocking' started by ArtemGr, Jun 14, 2006.

  1. ArtemGr

    ArtemGr Guest

    Here is a modification of "speedfan api control" ActivePython script,
    written in C++.
    (SpeedFan does not detect when my bios changes fan speed, so i need to
    "touch" the SpeedFan speed in order for it to become normal again.
    SpeedFan is running in automatic mode, and will restore the speed after
    this program increases it.)

    #include <stdlib.h>
    #include <stdio.h>
    #include <windows.h>
    #include <winuser.h>

    int main(int argc, char** argv) {
    try {
    HWND hWnd = FindWindowEx(0, 0, "TForm1", "SpeedFan 4.29 beta 7");
    if (hWnd == 0) throw "Can't find a SpeedFan window.";
    hWnd = FindWindowEx(hWnd, 0, "TPageControl", "");
    if (hWnd == 0) throw "Can't find the TPageControl.";
    hWnd = FindWindowEx(hWnd, 0, "TTabSheet", "Readings");
    if (hWnd == 0) throw "Can't find TTabSheet \"Readings\".";
    HWND automatic = FindWindowEx(hWnd, 0, "TJvXPCheckbox", "Automatic
    fan speed");
    if (automatic == 0) throw "Can't find the TJvXPCheckbox \"Automatic
    fan speed\"";
    // Search for a TRxSpinEdit control having a TWinControl.
    HWND spin = 0;
    while ((spin = FindWindowEx(hWnd, spin, "TRxSpinEdit", 0)) != 0) {
    HWND tWinControl = FindWindowEx(spin, 0, "TWinControl", "");
    if (tWinControl != 0) {
    printf("Found TRxSpinEdit with TWinControl.\n");
    BOOL back = SetForegroundWindow(tWinControl);
    int position = 0x00040004; // 0x000e000e;
    LRESULT res = SendMessageTimeout(tWinControl, WM_LBUTTONDOWN,
    MK_LBUTTON, position, SMTO_ABORTIFHUNG, 175, 0);
    if (res == 0) throw "SendMessageTimeout WM_LBUTTONDOWN
    res = SendMessageTimeout(tWinControl, WM_LBUTTONUP, 0,
    position, SMTO_ABORTIFHUNG, 175, 0);
    if (res == 0) throw "SendMessageTimeout WM_LBUTTONUP failed.";
    res = SendMessageTimeout(tWinControl, WM_CAPTURECHANGED, 0, 0,
    SMTO_ABORTIFHUNG, 175, 0);
    if (res == 0) throw "SendMessageTimeout WM_CAPTURECHANGED
    } catch (const char* error) {
    DWORD errCode = GetLastError();
    LPVOID lpMsgBuf;
    &lpMsgBuf, 0, 0);
    fprintf(stderr, "Error: %s\nError code %d: %s\n", error, errCode,
    return 0;
    ArtemGr, Jun 14, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.