Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to use multiple variables in the same AppleScript command?
    primarykey
    data
    text
    <p>I'm writing an applescript function in python using the applescript module and I'm having trouble generalizing the following function: </p> <pre><code>scpt = applescript.AppleScript(''' on code() tell application "System Events" key code 123 using command down end tell end code ''') </code></pre> <p>so that the keycode and the keydown variables can be input parameters, like so:</p> <pre><code>scpt = applescript.AppleScript(''' on code(kc, extras) tell application "System Events" key code kc extras end tell end code ''') </code></pre> <p>But I get the following run time error:</p> <pre><code>Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "example.py", line 28, in &lt;module&gt; ''') File "build/bdist.macosx-10.7-intel/egg/applescript/__init__.py", line 49, in __init__ applescript.ScriptError: Expected end of line but found application constant or consideration. (-2741) range=410-414 </code></pre> <p>so I assume there's something wonky with my syntax.</p> <p>I'm using Mac 0SX 10.7.5, python 2.7.1. </p> <p><strong>EDIT</strong></p> <p>This code is in a python module named example.py, here is the code again exactly as it is in the module:</p> <pre><code>import applescript scpt = applescript.AppleScript(''' on code(kc, extras) tell application "System Events" key code kc extras end tell end code ''') </code></pre> <p>I am invoking it from the command line as follows:</p> <pre><code>$ python Python 2.7.1 (r271:86832, Aug 5 2011, 03:30:24) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import example as e Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "example.py", line 9, in &lt;module&gt; ''') File "build/bdist.macosx-10.7-intel/egg/applescript/__init__.py", line 49, in __init__ applescript.ScriptError: Expected end of line but found identifier. (-2741) range=90-96 </code></pre> <p>where line 9 is the last line of my module -- ''').</p>
    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.
    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