PyWinAuto Library

1,656 views
Skip to first unread message

Tim Alexander

unread,
Oct 28, 2009, 5:18:25 PM10/28/09
to robotframework-devel
Anyone wanna test this for me? I checked it out a bit, but running out of time today, and wanted to get it out there for others to look at.

It's a PyWinAuto library that automates a windows GUI. You'll need pywinauto and it's dependancies installed, and of course it only runs on windows (not linux/mac/solaris/et.c)

Oh, and any comments are welcome. I know there are some pieces missing (called out as TODO in the code) and there's some stuff I need to clean up, but it's a first look at what I'm doing.
winbot.py

Pekka Klärck

unread,
Oct 28, 2009, 5:42:41 PM10/28/09
to dragon...@gmail.com, robotframework-devel
2009/10/28 Tim Alexander <dragon...@gmail.com>:

> Anyone wanna test this for me? I checked it out a bit, but running out of
> time today, and wanted to get it out there for others to look at.

Awesome! I don't have any Windows machines at home but I could try to
do some very simple test tomorrow when I get to the office.

> Oh, and any comments are welcome. I know there are some pieces missing
> (called out as TODO in the code) and there's some stuff I need to clean up,
> but it's a first look at what I'm doing.

At least you might consider doing something like below so that you
don't need to check are self.app and self.dlg None in every method:

class winbot:
def __init__(self):
self._app = None
self._dlg = None
def ._get_app(self):
if not self._app:
raise RuntimeError('No application open')
return self._app
def ._get_dlg(self):
if not self._dlg:
raise RuntimeError('No dialog open')
return self._dlg
app = property(_get_app)
dlg = property(_get_dlg)


Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Pekka Klärck

unread,
Oct 30, 2009, 7:04:43 PM10/30/09
to dragon...@gmail.com, robotframework-devel
2009/10/28 Tim Alexander <dragon...@gmail.com>:

> Anyone wanna test this for me? I checked it out a bit, but running out of
> time today, and wanted to get it out there for others to look at.

Unfortunately I didn't have time to look at this while at office. Has
anyone else here tried this? Sending a note to the users list would
probably raise more interest as there are more people.

Have you planned starting a project around this library? That would be awesome!

Josu Rodriguez Vilda

unread,
Nov 7, 2009, 10:33:59 PM11/7/09
to dragon...@gmail.com, robotframework-devel
to prove this we need the following packages:

        * ctypes http://starship.python.net/crew/theller/ctypes/ (download from http://sourceforge.net/project/showfiles.php?group_id=71702)
        * Sendkeys http://www.rutherfurd.net/python/sendkeys/index.html
        * Optional PIL http://www.pythonware.com/products/pil/index.htm
        * Optional elementtree http://effbot.org/downloads/

but ... Do you know if they can install PIL and  SendKeys, in mode silences?


2009/10/28 Tim Alexander <dragon...@gmail.com>

Anyone wanna test this for me? I checked it out a bit, but running out of time today, and wanted to get it out there for others to look at.

It's a PyWinAuto library that automates a windows GUI. You'll need pywinauto and it's dependancies installed, and of course it only runs on windows (not linux/mac/solaris/et.c)

Oh, and any comments are welcome. I know there are some pieces missing (called out as TODO in the code) and there's some stuff I need to clean up, but it's a first look at what I'm doing.





--

Pablo Picasso  - "Computers are useless. They can only give you answers."

Gmail

unread,
Nov 8, 2009, 11:22:19 AM11/8/09
to Josu Rodriguez Vilda, robotframework-devel
It's not actually using PIL the way I'm calling it. And what do you mean mode silences? Silent install? 

 - Tim

Pekka Klärck

unread,
Nov 8, 2009, 6:00:59 PM11/8/09
to jrv...@gmail.com, dragon...@gmail.com, robotframework-devel
2009/11/8 Josu Rodriguez Vilda <jrv...@gmail.com>:

> to prove this we need the following packages:
>
>         * ctypes http://starship.python.net/crew/theller/ctypes/ (download
> from http://sourceforge.net/project/showfiles.php?group_id=71702)
>         * Sendkeys http://www.rutherfurd.net/python/sendkeys/index.html
>         * Optional PIL http://www.pythonware.com/products/pil/index.htm
>         * Optional elementtree http://effbot.org/downloads/

ElementTree and ctypes are both in the standard library starting from
Python 2.5. That release is over three years old so most systems
already have either that or Python 2.6. SendKeys is only one or two
files and has such a license that it's possible to just include it
into the library.

Cheers,
.peke

Tim Alexander

unread,
Nov 10, 2009, 10:53:51 AM11/10/09
to robotframework-devel
OK, now that I have a (short) breather at work, here's the pywinauto library for RF. If I package it up, I'll stick sendkeys in there with it, since that's the only dependancy beyond what's in python 2.5 and 2.6 standard.

Anywhere I should put this, special way I should package it, etc.? What's the process to submit a library to RF? And how should i do the example? You just want it in a single file? Any format you'd like? I figured I'd just do notepad...

Also, is there a program to document the keywords based on docstrings, or is that a manual process?
winbot.py

Pekka Klärck

unread,
Nov 10, 2009, 5:28:27 PM11/10/09
to dragon...@gmail.com, robotframework-devel
2009/11/10 Tim Alexander <dragon...@gmail.com>:

> OK, now that I have a (short) breather at work, here's the pywinauto library
> for RF. If I package it up, I'll stick sendkeys in there with it, since
> that's the only dependancy beyond what's in python 2.5 and 2.6 standard.

Sounds great!

> Anywhere I should put this, special way I should package it, etc.? What's
> the process to submit a library to RF? And how should i do the example? You
> just want it in a single file? Any format you'd like? I figured I'd just do
> notepad...

It's easiest if you simply start a new project for this purpose - no
need to ask permissions for that! We've been pretty happy with Google
Code hosting but if you prefer GitHub, SourceForge, or something else
that's fine too. Similarly you can pick the license freely (unless you
use GPL code directly in which case you must use GPL too) but I'd
recommend Apache 2. You are free to use 'robotframework-' prefix in
the project name but obviously not obliged to. You can also use
rf-users and rf-devel mailin lists for communication if you want but
you might want to create a separate commit mailing list. When you got
the project set up, we can link it from the main RF site and you
should also announce it on rf-users mailing list latest then.

This all may sound like a lot of work but shouldn't take more than
half an hour. If you need any help or have more questions just ask!
You might also want to take a look at great, and free, book Producing
Open Source Software (http://producingoss.com) for more information
related to running an open source project.

> Also, is there a program to document the keywords based on docstrings, or is
> that a manual process?

Yes there is: http://code.google.com/p/robotframework/wiki/LibraryDocumentationTool

Gmail

unread,
Nov 10, 2009, 11:11:37 PM11/10/09
to Pekka Klärck, robotframework-devel
I've actually done a handful of foss projects from the ground up
before, but never ran across that book before. Thanks!

My questions were mainly oriented towards "how do I work towards
getting this into RF mainline?". I realize I'll have to setup a
seperate project at first, but wondered if there was a preferred way
of packaging, or documenting, or if there's a set way of going about
this to increase chances/ease of integration into mainline, or even if
that is an option for this module.

Thanks for the info btw!

- Tim

Pekka Klärck

unread,
Nov 11, 2009, 10:37:26 AM11/11/09
to Gmail, robotframework-devel
2009/11/11 Gmail <dragon...@gmail.com>:

> I've actually done a handful of foss projects from the ground up before, but
> never ran across that book before. Thanks!

Cool! Then the book may not give that much new information but at
least you can refer others to it later.

> My questions were mainly oriented towards "how do I work towards getting
> this into RF mainline?". I realize I'll have to setup a seperate project at
> first, but wondered if there was a preferred way of packaging, or
> documenting, or if there's a set way of going about this to increase
> chances/ease of integration into mainline, or even if that is an option for
> this module.

I actually think it's better to keep libraries like this as separate
projects. We don't have any plans for integrating e.g. SeleniumLibrary
or SwingLibrary projects more closely with the core either. There are
some standard libraries that are distributed automatically with the
core framework, but they generally work on all platforms and don't
require any additional dependencies. External libraries can also have
their own release schedules and, as I wrote earlier, different
licenses, copyrights, etc. than the core framework.

External libs can obviously also handle packaging, documentation, etc.
using tools that suite their needs. We've normally used Python's
standard distutils module for packaging Python code and created
separate source distributions and Windows installers. Java libraries
(e.g. SwingLibrary) are typically packaged using JAR archives. For
documentation we tend to use the earlier mentioned libdoc.py tool.

dragonfyre13

unread,
Nov 11, 2009, 8:31:36 PM11/11/09
to robotframework-devel
> I actually think it's better to keep libraries like this as separate
> projects. We don't have any plans for integrating e.g. SeleniumLibrary
> or SwingLibrary projects more closely with the core either. There are
> some standard libraries that are distributed automatically with the
> core framework, but they generally work on all platforms and don't
> require any additional dependencies. External libraries can also have
> their own release schedules and, as I wrote earlier, different
> licenses, copyrights, etc. than the core framework.

Sounds good! I've setup a project here for this:
http://code.google.com/p/robotframework-winbot/

I won't announce it on the user side until I have more documentation
and such, but it's out there. Let's wait to put anything on the user's
list until I've added at the least an example and the library
documentation.

Oh, and for my packaging I'm using setuptools. It handles the sendkeys
and pywinauto dependancies for me, so I don't need to package those
along with it.

Pekka Klärck

unread,
Nov 12, 2009, 2:35:14 AM11/12/09
to dragon...@gmail.com, robotframework-devel
2009/11/12 dragonfyre13 <dragon...@gmail.com>:

>
>> I actually think it's better to keep libraries like this as separate
>> projects. We don't have any plans for integrating e.g. SeleniumLibrary
>> or SwingLibrary projects more closely with the core either. There are
>> some standard libraries that are distributed automatically with the
>> core framework, but they generally work on all platforms and don't
>> require any additional dependencies. External libraries can also have
>> their own release schedules and, as I wrote earlier, different
>> licenses, copyrights, etc. than the core framework.
>
> Sounds good! I've setup a project here for this:
> http://code.google.com/p/robotframework-winbot/

Great!

> I won't announce it on the user side until I have more documentation
> and such, but it's out there. Let's wait to put anything on the user's
> list until I've added at the least an example and the library
> documentation.

Sure. As the author you, of course, have the privilege to send the announcement.

> Oh, and for my packaging I'm using setuptools. It handles the sendkeys
> and pywinauto dependancies for me, so I don't need to package those
> along with it.

Sounds good.

Josu Rodriguez Vilda

unread,
Nov 12, 2009, 4:51:55 AM11/12/09
to robotframework-devel
I like!
I've tested and works quite well. Can I get suggestions? : o)

I am very interested in the management GUI on Windows.


Josu Rodriguez Vilda

unread,
Nov 12, 2009, 4:55:38 AM11/12/09
to robotframework-devel
I like!
I've tested and works quite well. Can I send suggestions? : o)

I am very interested in the management GUI in Windows.

My English is not very good.


2009/11/12 Josu Rodriguez Vilda <jrv...@gmail.com>

Gmail

unread,
Nov 12, 2009, 10:54:39 PM11/12/09
to jrv...@gmail.com, robotframework-devel
Absolutely! And thanks!

Which management GUI, and which version of windows?

 - Tim

Sinh Nguyen Duy

unread,
Nov 12, 2014, 9:44:15 PM11/12/14
to robotframe...@googlegroups.com
I got error when importing your library using PythonWin

Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:\Python27\lib\site-packages\winbot\__init__.py", line 26, in <module>
    from pywinauto import application as pwa
  File "C:\Python27\lib\site-packages\pywinauto\application.py", line 68, in <module>
    import controlactions
  File "C:\Python27\lib\site-packages\pywinauto\controlactions.py", line 37, in <module>
    import SendKeys  # typekeys action
ImportError: No module named SendKeys

I tried to install SendKeys (pip install SendKeys) but it could not be found. Could you please help me investigate the issue?
Many thanks
Reply all
Reply to author
Forward
0 new messages