Expanding Python as a macro language

Mike Meyer mwm at mired.org
Sat Oct 29 21:18:37 EDT 2005


qwweeeit at yahoo.it writes:
> My answer is the same as that given to Michael about low level
> programming.
> But I must thank anyway Alex for giving informations to such a level
> (I didn't know that under Linux there was such a level of
> sophistication with the possibility for an application to discover fake
> keystrokes...).
>
> If this fake keystroke is used to fire an event (like pressing a
> button), the fake flag is propagated to the action taken by the button?

The action is internal to the application, so whether or not it
propogates the "fake" flag is up to the application. In between the X
event and the action is the GUI library, which may also choose to not
propogate the flag.

> For the other Alex observations (about Mac OsX and my examples of
> automation centered on web automation) I have a PC, and the fact that
> Python is very good at dealing with the web, doesn't help too much
> in this case...
> In any case a macro language like AutoIt is a general purpose
> application.
>
> At last I must thank  Mike Meyer for his suggestion to use python-xlib
> to avoid low level programming...

Just to clarify - python-xlib will let you avoid the need for C
functions to do things like send X events. In that sense, it helps you
avoid low-level programming. On the other hand, you're still sending X
events, so in *that* sense, you're not avoiding low-level programming.

In general, application scripting facilities are one thing that Unix
hasn't dealt with well. Windows and OS X both do better (but neither
do as well later versions of AmigaDOS). Whereas those systems come
with a (or a selection) mechanism that applications can use to allow
macro programming, Unix doesn't, so each application is left up to
it's own devices. The most popular solution is to embed a custom
language for scripting - which is where something like Python comes
in. Some of them now export APIs that can be hooked up to a variety of
languages.  IIRC, Gnome has embraced CORBA as an interface for such,
but it didn't seem well supported the last time I looked. The bottom
line is that when it comes to scripting applications on Unix, your
solution is going to be tailored to the application.

The Unix variant with the best system-provided scripting facility is
probably Plan 9. Some Linux variants are moving in that direction, but
I don't know of any Linux applications that provide support for it.

     <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list