[Tutor] Mouse clicking
elis aeris
hunter92383 at gmail.com
Sat Jun 30 23:44:18 CEST 2007
win32gui <win32gui.html>.FindWindow
int = *FindWindow(className, WindowName *)
Retrieves a handle to the top-level window whose class name and window name
match the specified strings.
Parameters
*className* : int/string
*WindowName* : string
HWND FindWindow(
LPCTSTR lpClassName, // pointer to class name
LPCTSTR lpWindowName // pointer to window name
);
BOOL EnumWindows(
WNDENUMPROC lpEnumFunc, // pointer to callback function
LPARAM lParam // application-defined value
);
I am not sure what this is for @_@
BOOL PostMessage(
HWND hWnd, // handle of destination window
UINT Msg, // message to post
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
with pywin32, shouldn't
win32api.keybd_event
win32api.GetFocus
win32api.mouse_event
be used instead?
On 6/30/07, Alan Gauld <alan.gauld at btinternet.com> wrote:
>
>
> "Lisa Barrott" <lisa.barrott at btinternet.com> wrote
>
> > I was wondering if there was any way to force a mouse click at a set
> > location using python even when the another window is focussed.
> > I'm using Windows XP
>
> Yes, you can use the Win32 API.
> You need to get the target window handle with
>
> -------------
> HWND FindWindow(
> LPCTSTR lpClassName, // pointer to class name
> LPCTSTR lpWindowName // pointer to window name
> );
> ---------------
>
> or
>
> --------------------
> BOOL EnumWindows(
> WNDENUMPROC lpEnumFunc, // pointer to callback function
> LPARAM lParam // application-defined value
> );
> ----------------------
>
> Then you can use PostMessage() to generate a mouse event.
>
> BOOL PostMessage(
> HWND hWnd, // handle of destination window
> UINT Msg, // message to post
> WPARAM wParam, // first message parameter
> LPARAM lParam // second message parameter
> );
>
> You can get the full docs on these functions on MSDN and the winall
> package should provide access to them, or the ctypes module will
> allow direct access for a bit more work.
>
> There might be other more pythonic modules around that do the
> heavy lifting for you, but these are not too hard to use.
>
> HTH,
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.freenetpages.co.uk/hp/alan.gauld
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070630/63c6aca8/attachment.htm
More information about the Tutor
mailing list