Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I import a Python script with several modules included into Sikuli
    primarykey
    data
    text
    <p>I'm trying to call a Python (2.7) script from Sikuli (r930) and use a variable from the script. Below is the Python code:</p> <pre><code>import sys import re import os import time from pywinauto import application from SendKeys import SendKeys from cStringIO import StringIO app=application.Application() app.connect_(path=r'C:\Program Files\myApp\myApp.exe') backup = sys.stdout sys.stdout = StringIO() app.dlg.print_control_identifiers() out = sys.stdout.getvalue() sys.stdout.close() # close the stream sys.stdout = backup # restore original stdout regex = re.compile(r'(\d{8}\s*\-\s*\d{8})') found = re.search(regex, out) print found.group(0) #pass this variable to Sikuli </code></pre> <p>I'm capturing <code>stdout</code> because this is what <a href="http://code.google.com/p/pywinauto/" rel="nofollow">Pywinauto's</a> <code>print_control_identifiers</code> method returns (not a string). Also, I need a hashed serial number from the GUI app that I can't get with Sikuli, hence the need to use Pywinauto. However, when I attempt to call <code>execfile()</code> from Sikuli, I get the error: </p> <pre><code>ImportError: no module named Pywinauto. </code></pre> <p>I read the docs, and I know that Sikuli (Jython) can include Python modules and scripts. Besides, the external .py file that I'm calling runs successfully when ran independently. Can someone tell me if I'm missing a step?</p> <p>Code I'm using to call the .py file shown above from Sikuli:</p> <pre><code>aScript = 'c:\\getHash_serial.py' execfile(aScript) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload