[Tutor] Mouse clicking
elis aeris
hunter92383 at gmail.com
Sat Jun 30 23:00:15 CEST 2007
what module should be imported?
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/2f306d10/attachment.html
More information about the Tutor
mailing list