[Tutor] Re: Mouseclick

Andrei project5 at redrival.net
Wed Apr 6 21:37:24 CEST 2005

Øyvind <python <at> kapitalisten.no> writes:

> and would like to click the left mousebutton at that position. Is that
> possible? I have just been able to find ways to click the button on
> buttons that I can name such as:
> def findAButtonCalledOK(hwnd, windowText, windowClass): # Define a
> function to find our button
>     return windowClass == "Button" and windowText == "OK"
> okButton = findControl(optDialog, findAButtonCalledOK)
> click(okButton)

Looking at the implementation of the click() function on the site you 
got that from:

  http://www.brunningonline.net/simon/blog/archives/000664.html ,

a click is a left button down followed by left button up. The docs:


state that the last parameter (lParam) is the position. This page shows 
how to construct it:


There's probably something available with ctypes or win32all to build 
the lParam, but if that's not the case, you can do something like:

    lParam = ypos * (2**16) + xpos

(with the positions being relative to the top/left of the control 
the handle of which you use in the SendMessage). If you pass that
parameter in the SendMessage calls, I think the mouse should click
on a certain position (although I haven't tested, as I'm not on 
Windows ATM).



More information about the Tutor mailing list