(win32) speedfan api control

T

tlviewer

hello,

If you run the Mainboard monitor, speedfan, here is
an ActivePython script to force automatic fan control.
        http://www.almico.com/speedfan.php

It's a great example of how clean the WinApi interface is
in ActivePython. The script sets focus to the checkbox of
interest and toggles the checkbox. AFAIK, speedfan will only
start without fan control, requiring the user to manually
check the checkbox to turn it on.

hope someone finds it useful,
tlviewer

#!/usr/bin/python
# author: (e-mail address removed)
# date: April 1, 2005
# description: turn on SpeedFan automatic fan speed
# keywords: speedfan readings
#import win32api as ap

import win32gui as wi
import win32ui as ui
import win32con as wc

# dialog class name
cl = "TJvXPCheckbox"

try:
    hWnd = wi.FindWindowEx( 0, 0, "TForm1", "SpeedFan 4.20") 
    print hWnd 
    hWnd = wi.FindWindowEx( hWnd, 0, "TPageControl", "")  
    print hWnd
    hWnd = wi.FindWindowEx( hWnd, 0, "TTabSheet", "Readings")
    print hWnd
    hWnd = wi.FindWindowEx( hWnd, 0, cl, "Automatic fan speed")
    
    print hWnd
    res = wi.SetForegroundWindow(hWnd)
    res=wi.SendMessageTimeout(hWnd,wc.WM_LBUTTONDOWN,wc.MK_LBUTTON,0,2,75)  
    res = wi.SendMessageTimeout( hWnd,wc.WM_LBUTTONUP, 0, 0, 2, 75 ) 
    print res
except:
    pass
#end code
 
C

Claudio Grondi

your script works ok on my W2K box :).

It makes me curious if I can get also the
temperatures into Python script for
further processing as easy as the setting
of the checkbox is done? (I have not
much experience with this kind of
programming yet)
May I ask how did you get the
"TJvXPCheckbox" and the other
values necessary to access the program
GUI ? (as I can see, there is no source
code of SpeedFan available) ?

Claudio
 
C

Cappy2112

Nice idea- getting the handle to a control.
But how do you know what to pass for wparam , lparam , flags ?

BTW- I don't see anything unique to Active Python here.
You can do all of this with the Python windows extensions, which can be
installed without Active Python.
 
C

Claudio Grondi

It makes me curious if I can get also the
Winspector is good for this kind of thing.

Thanks for the link to Winspector - with this
tool it's really easy to find out the names
required to get down to the window elements
of a running application.

In the special case of speedfan there seems
to be no way to get the temperatures shown
in Reading tab into a Python script, because
the texts with the temperature values are not
separate window elements. The only
message sent to "TJvPanel" (it's the class
of the element with the temperatures) is
WM_PAINT with 0, 0 values, so the actual
temperatures are "hidden" from beeing
accessed as easy as the value of the
checkbox.
Knowing the rectangle of the "TJvPanel"
it should be probably possible to OCR
the text shown, but this is another story.

By the way: is there a free tool (primary
for Windows, but best for both Linux
and Windows) able to get the text of the
word under the current mouse pointer
position like it is done e.g. by Babylon
translator?

Claudio
 
A

Almico

Claudio Grondi said:
your script works ok on my W2K box :).

It makes me curious if I can get also the
temperatures into Python script for
further processing as easy as the setting
of the checkbox is done? (I have not
much experience with this kind of
programming yet)
May I ask how did you get the
"TJvXPCheckbox" and the other
values necessary to access the program
GUI ? (as I can see, there is no source
code of SpeedFan available) ?

SpeedFan publishes a Shared Memory area. Drop SpeedFan's author (me
:)) an email to get its specs.
 
C

Claudio Grondi

I have got the specs for SpeedFan from
the SpeedFan author :) ,
but ...
inbetween I found, that full specs of the
shared memory access to
fan speeds, board, CPU temperature data
are also exposed by the MBM application
http://mbm.livewiredev.com
and already published online
(including C, VB, Delphi code examples).
but ...
I failed to get the data into
a Python script :-( .
For details see my other
"Problem with access to shared memory(W2K) /
ORIGINALLY (win32) speedfan api control"
posting.

Claudio
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,234
Messages
2,571,178
Members
47,811
Latest member
Adisty

Latest Threads

Top