How to write a Python's module that acts like a user ?

Hi
The user start an application that has a GUI. Then the user press some keys
( for example: a b enter tab enter ...) to interact with the application's
GUI. How to write a python's module that acts like the user,i.e.: [1] start
the application (this is easy!) [2] "press" the keys the GUI is waiting for
(this is what i want to know how to do). [3]IMPORTANT: The application can
not be modifyed. It can be just executed.

baitelli,r.

···

_________________________________________________________________
     AVISO
   Esta mensagem é destinada exclusivamente a(s) pessoa(s) indicada(s)
   como destinatário(s), podendo conter informações confidenciais,
   protegidas por lei.
   A transmissão incorreta da mensagem não acarreta a perda de sua
   confidencialidade.
   Caso esta mensagem tenha sido recebida por engano, solicitamos que
   seja devolvida ao remetente e apagada imediatamente de seu sistema. É
   vedado a qualquer pessoa que não seja destinatário, usar, revelar,
   distribuir ou copiar ainda que parcialmente esta mensagem.
     _________________________________________________________________
     DISCLAIMER
   This message is destined exclusively to the intended receiver. It may
   contain confidential or legally protected information.
   The incorrect transmission of this message does not mean loss of its
   confidentiality.
   If this message is received by mistake, please send it back to the
   sender and delete it from your system immediately. It is forbidden to
   any person who is not the intended receiver to use, reveal,
   distribute, or copy any part of this message.
     _________________________________________________________________

I don't know how to do that with Python or how to do that
platform-independently, but on Win32 you can read certain properties of the
GUI elements and can send them messages. AutoIt3 (that's not Python)
provides a nice set of tools for facilitating exactly that.

Gerhard

···

On 2006-07-24 13:15:42, baitelli wrote:

The user start an application that has a GUI. Then the user press some keys
( for example: a b enter tab enter ...) to interact with the application's
GUI. How to write a python's module that acts like the user,i.e.: [1] start
the application (this is easy!) [2] "press" the keys the GUI is waiting for
(this is what i want to know how to do). [3]IMPORTANT: The application can
not be modifyed. It can be just executed.

With the Win32 API, you would use such methods as FindWindow, FindWindowEx, SendMessage, PostMessage, etc… but this won’t work anywhere else.

Check out the API Viewer that comes with VC++ and Spy++.

Best regards,

···

On 7/24/06, baitelli baitelli@cepel.br wrote:

Hi
The user start an application that has a GUI. Then the user press some keys
( for example: a b enter tab enter …) to interact with the application’s
GUI. How to write a python’s module that acts like the user,
i.e.: [1] start
the application (this is easy!) [2] “press” the keys the GUI is waiting for
(this is what i want to know how to do). [3]IMPORTANT: The application can
not be modifyed. It can be just executed.

baitelli,r.

 _________________________________________________________________
 AVISO

Esta mensagem é destinada exclusivamente a(s) pessoa(s) indicada(s)
como destinatário(s), podendo conter informações confidenciais,

protegidas por lei.
A transmissão incorreta da mensagem não acarreta a perda de sua
confidencialidade.
Caso esta mensagem tenha sido recebida por engano, solicitamos que
seja devolvida ao remetente e apagada imediatamente de seu sistema. É

vedado a qualquer pessoa que não seja destinatário, usar, revelar,
distribuir ou copiar ainda que parcialmente esta mensagem.
_________________________________________________________________
DISCLAIMER

This message is destined exclusively to the intended receiver. It may
contain confidential or legally protected information.
The incorrect transmission of this message does not mean loss of its
confidentiality.

If this message is received by mistake, please send it back to the
sender and delete it from your system immediately. It is forbidden to
any person who is not the intended receiver to use, reveal,
distribute, or copy any part of this message.

 _________________________________________________________________

To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org


-Richard Burton

Alternatively, one could hack up a VNC client to directly send keyboard
events, etc., to a running OS, with a little work to make sure that the
desired application has focus. This would work on any host platform
with a VNC server (Windows, Linux, Mac). It would certainly take some
work to get the VNC client set up to do such things, but it would be the
most cross-platform capable.

Personally, I have found that the Windows API functions available to
Python don't always work as expected. I had personally attempted to
script the DirectShow GraphEdt application using keyboard events
(hotkeys, menu navigation, toolbar buttons, etc.), but discovered that
none of it worked; only actually getting the menu item and activating it
directly worked for me.

- Josiah

···

"Richard Burton" <mrburton@gmail.com> wrote:

With the Win32 API, you would use such methods as FindWindow, FindWindowEx,
SendMessage, PostMessage, etc.. but this won't work anywhere else.

Check out the API Viewer that comes with VC++ and Spy++.

Best regards,

On 7/24/06, baitelli <baitelli@cepel.br> wrote:
>
> Hi
> The user start an application that has a GUI. Then the user press some
> keys
> ( for example: a b enter tab enter ...) to interact with the application's
> GUI. How to write a python's module that acts like the user,i.e.: [1]
> start
> the application (this is easy!) [2] "press" the keys the GUI is waiting
> for
> (this is what i want to know how to do). [3]IMPORTANT: The application can
> not be modifyed. It can be just executed.
>
> baitelli,r.
>
> _________________________________________________________________
> AVISO
> Esta mensagem é destinada exclusivamente a(s) pessoa(s) indicada(s)
> como destinatário(s), podendo conter informações confidenciais,
> protegidas por lei.
> A transmissão incorreta da mensagem não acarreta a perda de sua
> confidencialidade.
> Caso esta mensagem tenha sido recebida por engano, solicitamos que
> seja devolvida ao remetente e apagada imediatamente de seu sistema. É
> vedado a qualquer pessoa que não seja destinatário, usar, revelar,
> distribuir ou copiar ainda que parcialmente esta mensagem.
> _________________________________________________________________
> DISCLAIMER
> This message is destined exclusively to the intended receiver. It may
> contain confidential or legally protected information.
> The incorrect transmission of this message does not mean loss of its
> confidentiality.
> If this message is received by mistake, please send it back to the
> sender and delete it from your system immediately. It is forbidden to
> any person who is not the intended receiver to use, reveal,
> distribute, or copy any part of this message.
> _________________________________________________________________
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
>
>

--
-Richard Burton

baitelli wrote:

Hi
The user start an application that has a GUI. Then the user press some keys
( for example: a b enter tab enter ...) to interact with the application's
GUI. How to write a python's module that acts like the user,i.e.: [1] start
the application (this is easy!) [2] "press" the keys the GUI is waiting for
(this is what i want to know how to do). [3]IMPORTANT: The application can
not be modifyed. It can be just executed.

baitelli,r.http://www.openqa.org/pywinauto/

pywinauto home page

For windows, take a look at pywinauto (http://www.openqa.org/pywinauto/) and sendkeys (http://www.rutherfurd.net/python/sendkeys/index.html).

···

--
Pierre Rouleau