[python-win32] pywinauto 0.1.1

Mark Mc Mahon mark.m.mcmahon at gmail.com
Sat Jan 14 15:51:43 CET 2006

On 1/14/06, Jeff Bauer <jbauer at rubic.com> wrote:

> from win32com.client import Dispatch
> AutoIt = Dispatch("AutoItX3.Control")
> ...
> AutoIt.WinActivate(title)
> AutoIt.WinWaitActive(title)
> AutoIt.Send(keystroke)
> ...
> AutoIt.ClipPut("")
> AutoIt.Send("{ALTDOWN}EL{ALTUP}") # Edit -> Copy All
> text = AutoIt.ClipGet().strip()
> if AutoIt.error:
>    self.log("AutoIt.error: nothing in the clipboard")

I have noticed that AutoIt seems to do everything through the keyboard
(at least in all the examples I have looked at). I feel that using the
keyboard only loses quite a lot of context information for example
   AutoIt.Send("{ALTDOWN}EL{ALTUP}") # Edit -> Copy All

I find must less expressive (is that the right word?) than:
   # using notepad as an example (notepad doesn't have a Copy All item)
   Notepad.MenuSelect("Edit->Select All")

I can also make it so that an exception is raised one of those menu
items are not enabled.

Currently I don't have any Clipboard access methods and I should fix that :-) .

import clipboard
if clipboard.owner != Notepad:
    raise RuntimeError("seems some other app has used the clipboard in between")

# get the data in the default format (is there such a thing as the
default format?)
data = clipboard.get_data(format)

# get it as text
text = clipboard.get_text()

These are just ideas - seeing as I haven't implemented the clipboard
code yet (and don't know enough about the relevant functions to be
sure that I am specify the right code layout above).

So I guess clipboard access is next on my todo list (after fixing the
readme file - which is confusing!)


> > Would you reccomend that I look at the AutoIt DLL exported functions?
> > I guess it provides a set of higher level functions then the windows
> > API - which I am currently using.
> I think it would give you some good ideas of the functionality that
> you'd want to reproduce in pywinauto.
> --
> Jeff Bauer      http://serpentaddiction.blogspot.com
> Rubicon, Inc.   http://www.rubic.com

More information about the Python-win32 mailing list