Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java.awt.Robot equivalent?

0 views
Skip to first unread message

Christopher Koppler

unread,
Dec 12, 2003, 7:19:25 AM12/12/03
to
I need to simulate mouseclicks (in Win2K) in another application's
window. Googling threw up java.awt.Robot, and a bit of trial and error
showed that it could do what I needed (simulate a mouseclick on an
open window). However, I don't want to use Java (or Jython) if I can
avoid it, as I already have a Python 2.3 app, which works quite
nicely, thank you, and which needs to click into a foreign window.

Is this capability available in any of the GUI toolkits (searching
Tkinter docs brought up nothing)? Is there a C library that I could
wrap? Or maybe I just need to use the Windows extensions. But if so,
how - I don't have the slightest idea how that would work.

Anyone have any pointers?


--
Christopher

Fredrik Lundh

unread,
Dec 12, 2003, 7:31:21 AM12/12/03
to pytho...@python.org
Christopher Koppler wrote:

> Is this capability available in any of the GUI toolkits (searching
> Tkinter docs brought up nothing)? Is there a C library that I could
> wrap? Or maybe I just need to use the Windows extensions. But if so,
> how - I don't have the slightest idea how that would work.
>
> Anyone have any pointers?

win32api's PostMessage might be useful. random google link:

http://mail.python.org/pipermail/python-win32/2002-December/000635.html

</F>


Thomas Heller

unread,
Dec 12, 2003, 8:36:55 AM12/12/03
to
"Fredrik Lundh" <fre...@pythonware.com> writes:

Other random resources:

Simon Brunning has written a 3-part details blog entry on
'automating the win32 gui'.

And there's a library named 'autoit' which can be driven by com.

Thomas

Christopher Koppler

unread,
Dec 12, 2003, 1:52:54 PM12/12/03
to
On Fri, 12 Dec 2003 14:36:55 +0100, Thomas Heller <the...@python.net>
wrote:

<accent type="fake Finnish rock'n'roll">
Thank you very many, Fredrik, Thomas!
</accent>

Autoit does exactly what I need (click on a specific coordinate in a
canvas-like window), and finally a reason to learn to use ctypes,
too...


--
Christopher

SBru...@trisystems.co.uk

unread,
Dec 15, 2003, 12:48:28 PM12/15/03
to pytho...@python.org, klap...@chello.at
> From: Christopher Koppler [SMTP:klap...@chello.at]

> Autoit does exactly what I need (click on a specific coordinate in a
> canvas-like window), and finally a reason to learn to use ctypes,
> too...

You don't really need to use ctypes to drive AutoIt - it's COM scriptable.
Give me a shout if you want some examples of driving it - I'm sure I have
some somewhere around here...

But I gave up using it in the end, 'cos it was so fragile. If the wrong
window gained focus, the script would die. Besides, there are some controls
that it won't drive unless you are willing to resort to mouse clicks on
absolute positions, which is also fragile.

In the end, I just drove the Windows API directly. Yes, using ctypes a lot
of the time. ;-) You can find my current work in progress here:

http://www.brunningonline.net/simon/blog/archives/winGuiAuto.py.html

It's not far from being ready to go, actually. It just needs a few more
tests, some introductory docs, and an installation script. It's quite
useable, though - the functions themselves are well documented, and the test
script gives you a good high level introduction. We use it a lot.

Cheers,
Simon Brunning,
http://www.brunningonline.net/simon/blog/
--LongSig


-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.

0 new messages