tag:blogger.com,1999:blog-73116624030114507772024-03-12T18:33:32.554-07:00GUI Automation with PythonVasily Ryabovhttp://www.blogger.com/profile/08731307684086415382noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-7311662403011450777.post-63245217537827055642015-11-01T02:04:00.000-08:002015-11-02T01:40:19.077-08:00New Code Generator in SWAPY<div dir="ltr" style="text-align: left;" trbidi="on">Pywinauto is a great tool for those who have some experience in Python. But what is about the beginners or those who are not yet familiar with Python and/or GUI automation?<br />
<div><br />
</div><div>SWAPY is a GUI helper for objects hierarchy inspection. Generally it looks like similar tools from Microsoft (Spy++, Inspect.exe), but it's designed specifically for Pywinauto users. It's especially helpful for getting started with Pywinauto library.</div><div><br />
</div><div>SWAPY can recognize every control that is visible to Pywinauto. So you may check quickly whether Pywinauto is suitable for your application. If this is the case, SWAPY can help with prototyping your automation scripts using the Code Generator feature.<br />
<br />
The Code Generator is significantly renovated in <a href="https://github.com/pywinauto/SWAPY/releases/tag/0.4.8"><span style="color: blue;">the SWAPY 0.4.8</span></a>.</div><div><br />
</div><div>How does it work? Just start looking for the controls hierarchy. If you want to do some action, right click on the control item in the tree and choose a method to call.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCUntjZM0YfyaS0e3ajOdEjorESpAZTPAfkHasG4BhSJSot5rYwELDY9liNnFh-kBmeMginUMnXuPxkw-3B1jKvyz5fjQHf1pnD417kyEX0875Yuj_0ihphm4wHwa5CxP4vL7ZAf7vhpcI/s1600/SWAPY_code_Tree_Expand.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCUntjZM0YfyaS0e3ajOdEjorESpAZTPAfkHasG4BhSJSot5rYwELDY9liNnFh-kBmeMginUMnXuPxkw-3B1jKvyz5fjQHf1pnD417kyEX0875Yuj_0ihphm4wHwa5CxP4vL7ZAf7vhpcI/s1600/SWAPY_code_Tree_Expand.jpg" /></a></div><br />
<br />
Code Generator automatically inserts the code into the Editor pane. The action is also performed simultaneously in the application. All the generated code can be saved to *.py file.</div><a name='more'></a><br />
<div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEic6OApTWjsV6gHJ8_qDBvCnyUqi0x3z1Sk6XSkKKG1KsfLl6eVsDwRXriYBkd4hyphenhyphenI2dOtAp-bbRPfhkIx17W1ZVid0A4G1IDsnGF-n83y3UA7TuaIPLGptqJF1LIGhCqdRZLGKVTI2vxPk/s1600/SWAPY_code_Tree_Expand_result.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEic6OApTWjsV6gHJ8_qDBvCnyUqi0x3z1Sk6XSkKKG1KsfLl6eVsDwRXriYBkd4hyphenhyphenI2dOtAp-bbRPfhkIx17W1ZVid0A4G1IDsnGF-n83y3UA7TuaIPLGptqJF1LIGhCqdRZLGKVTI2vxPk/s1600/SWAPY_code_Tree_Expand_result.jpg" /></a></div><br />
</div><div><br />
</div><div>Now the Editor pane supports unlimited "Undo" steps including the whole code reset. Of course an action cannot be undone in the application so use the "Undo" carefully.<br />
<br />
An additional useful option is switching between Start and Connect methods. If you believe the application is already started when your script is supposed to run, you can right click on the top level window item ("Common Controls Sample" in the given example) and choose <b>Application.Connect</b> method instead of <b>Start</b> one.<br />
<br />
Feel free to propose new features in the <a href="https://github.com/pywinauto/SWAPY/issues"><span style="color: blue;">SWAPY issues</span></a> section or tell us your opinion on <a href="https://gitter.im/pywinauto/pywinauto"><span style="color: blue;">the Gitter chat room</span></a>.<br />
<br />
There is a <b>known problem</b>: if Win8.1 or Win10 denies you to run SWAPY executable, just click "More info" link on the warning window and then choose "Run anyway". The binaries are not digitally signed yet.</div></div>Vasily Ryabovhttp://www.blogger.com/profile/08731307684086415382noreply@blogger.com10tag:blogger.com,1999:blog-7311662403011450777.post-73143522673265205672015-10-26T05:27:00.000-07:002015-10-26T05:50:07.329-07:00Pywinauto Has Been Presented at the Auckland Python Meetup<div dir="ltr" style="text-align: left;" trbidi="on">
The regular <a href="http://www.meetup.com/NZPUG-Auckland/events/225405249/"><span style="color: blue;">Auckland Python Meetup has been held on 23 October</span></a> where Valentin (<a href="https://github.com/airelil"><span style="color: blue;">airelil</span></a>) presented the project. Unfortunately video wasn't recorded this time. However the <a href="https://docs.google.com/presentation/d/1dIblkBhrIPAP208tqXMPWB2sHr1nvkdIeCkJhZBe-zE/edit?usp=sharing"><span style="color: blue;">slides</span></a> are still available for everyone. A small insight into Pywinauto internals describing principles of controls name resolution and introductory examples can make your automation scripting a bit easier.<br />
<br />
One of the quite popular (strangely) questions, that popped out on the presentation too, is "How can I interact with a console window of cmd.exe?". In this case, Pywinauto couldn't be the answer though. We believe that a GUI automation tool should be used for GUI not a command line. :)<br />
<br />
The standard way to send keyboard input to the console application is using <span style="background-color: #eeeeee;">subprocess.Popen()</span> object with <span style="background-color: #eeeeee;">stdin=subprocess.PIPE</span> and <span style="background-color: #eeeeee;">stdout=subprocess.PIPE</span> arguments that are <a href="https://docs.python.org/2/library/subprocess.html"><span style="color: blue;">well described in the Python docs</span></a>.<br />
<br />
Interestingly, <a href="http://stackoverflow.com/questions/33168854/how-can-i-use-settext-in-command-prompt"><span style="color: blue;">a person on Stack Overflow</span></a> discovered that it's possible to send characters to cmd.exe using WM_CHAR window message. It even works silently for a minimized console window. That is could be considered as an alternative for the <span style="background-color: #eeeeee;">TypeKeys</span> method in Pywinauto which runs for the active window only. However you have to remember that <span style="background-color: #eeeeee;">TypeKeys</span> performs a closer real user behavior emulation than sending of WM_CHAR message or calling <span style="background-color: #eeeeee;">SetText</span> for a GUI control.</div>
Vasily Ryabovhttp://www.blogger.com/profile/08731307684086415382noreply@blogger.com4tag:blogger.com,1999:blog-7311662403011450777.post-29723363096465581572015-10-15T05:55:00.000-07:002016-01-29T03:04:30.369-08:00New Team Icon and New Team Members<div dir="ltr" style="text-align: left;" trbidi="on"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzSL9xm6XOm9HrA3u8w4ARdZBjRCu1387xn_1tPyW-sQu9ydzYFzgjTAODK7dSSlgYr5Dh847Xksl7hnjNmHZTeSgL-jUe4vr2F2dt1JkQmfsKAbpLFHLqo_Q0-tJhDSL_TKOu4N-egLMa/s1600/walter_cat.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzSL9xm6XOm9HrA3u8w4ARdZBjRCu1387xn_1tPyW-sQu9ydzYFzgjTAODK7dSSlgYr5Dh847Xksl7hnjNmHZTeSgL-jUe4vr2F2dt1JkQmfsKAbpLFHLqo_Q0-tJhDSL_TKOu4N-egLMa/s1600/walter_cat.jpg" /></a>The Open Source <a href="https://github.com/pywinauto"><span style="color: blue;">community</span></a> (pywinauto & SWAPY) has a new team icon. It's name is cat Walter. Thanks <a href="https://www.behance.net/anna9111990"><span style="color: blue;"><b>Anna</b></span></a> who painted it.<br />
<br />
Welcome 2 new members in the project! <a href="https://github.com/MagazinnikIvan"><span style="color: blue;">Ivan</span></a> and <a href="https://github.com/cetygamer"><span style="color: blue;">Alexander</span></a> are students at Lobachevsky State University of Nizhny Novgorod (<span style="color: blue;"><a href="http://www.unn.ru/eng/">UNN</a></span>) making their diploma works at the Computer Science department.</div>Vasily Ryabovhttp://www.blogger.com/profile/08731307684086415382noreply@blogger.com0tag:blogger.com,1999:blog-7311662403011450777.post-86944271758199769652015-10-12T03:05:00.000-07:002015-10-25T14:04:17.550-07:00Pywinauto Has Been Revived This Summer!<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://pywinauto.github.io/"><b>Pywinauto</b></a> is a great Python solution for Windows GUI Automation. It has been intensively developed from 2006 up to 2011 by <b><a href="http://pywinauto.blogspot.ru/"><span style="color: blue;">Mark McMahon</span></a></b>. In period 2011-2013 it was maintained by <a href="https://github.com/mherrmann"><span style="color: blue;">Michael Herrmann</span></a> (version 0.4.2).<br />
<br />
Google Code, the original hosting of Pywinauto, recently has been declared as end-of-life so the revived project is now <a href="http://pywinauto.github.io/"><span style="color: blue;">hosted on GitHub</span></a>. The first new major version <b>0.5.0</b>, released on June, 30th was featured with a full support to <b>x64</b> for Python 2 / Python 3 and several other improvements as well.<br />
<br />
The latest pywinauto, <a href="https://github.com/pywinauto/pywinauto/releases/tag/0.5.3" style="font-weight: bold;"><span style="color: blue;">version 0.5.3</span></a>, focused on restoring the partially broken backward compatibility with 0.4.2. The full list of changes can be found <a href="http://pywinauto.github.io/docs/HISTORY.html"><b><span style="color: blue;">here</span></b></a>.<br />
These new releases are maintained by <b><a href="http://www.intel.com/"><span style="color: blue;">Intel Corporation</span></a></b> (c) and the Open Source community.<br />
<br />
Many thanks to the contributors who helped to make it possible: <b><a href="https://github.com/airelil"><span style="color: blue;">airelil</span></a></b> and <a href="https://github.com/moden-py"><b><span style="color: blue;">moden-py</span></b></a> (author of <a href="https://github.com/pywinauto/SWAPY"><span style="color: blue;">SWAPY</span></a>, the Pywinauto object inspector).</div>
Vasily Ryabovhttp://www.blogger.com/profile/08731307684086415382noreply@blogger.com0