Python scripting with Automation plugin

Discussion of bugs and problems found in Altap Salamander. In your reports, please be as descriptive as possible, and report one incident per report. Do not post crash reports here, send us the generated bug report by email instead, please.
ArgentStar
Posts: 5
Joined: 07 Jun 2011, 18:13

Python scripting with Automation plugin

Post by ArgentStar »

First of all I'd like to thank the makers of Altap Salamander (AS) for an excellent piece of software. :) Best digital purchase I've made in years. Can't believe I went so long before it even occurred to me to change my Windows file-manager. Changed things around plenty on Linux systems. Eventually settled with Dolphin (GUI-based) and Last File Manager (console-based) in Linux. both of those have a dual pane setup and inspired me to ditch Windows Explorer. :)

Anyway, it's mentioned on the forums here that third-party scripting engines are available to use Python (and other) scripting languages with the Automation plugin that comes with AS. I've been using Python for about a year and wanted to try integrating it more. I know I can already use the User Menu to feed a Python script variables from the command line, but I was wondering if there's a way to get it to work more directly with the automation plugin? As I said, I've already got Python scripting fairly well integrated - have scripts to convert audio files, upload direct to my FTP, open a Cygwin terminal at the current directory, etc - but it'd be nice to take things a little further as the Automation plugin's help-file seems top suggest there's some useful functionality available to VBScript and JavaScript.

Thanks for reading and I look forward to any assistance you may be able to give. :)
manison
Plugin Developer
Plugin Developer
Posts: 216
Joined: 09 Dec 2005, 23:23
Location: Ceske Budejovice, Czech Republic
Contact:

Re: Python scripting with Automation plugin

Post by manison »

To use Python for scripting (not only) in Salamander you need to install a third party scripting engine since Windows comes preinstalled with JScript and VBScript engines only. I recommend you to use ActivePython package. After that you should be ready to start experimenting with your first Python scripts. Create a file and give it the .pys extension and save it somewhere where the Automation plugin can find it (see the Options > Plugin Configuration > Automation to check the list of directories that are watched by the plugin). You then run your script from the Plugin Bar or by pressing the assigned keyboard shortcut. For the first steps you may consult example scripts that get installed with Salamander. Although they are in JScript and VBScript dialects I believe you can get it. Also the plugin help contains comprehensive reference to all the available methods.

Hello world Python example for Salamander (save as hello.pys):

Code: Select all

Salamander.MsgBox('Hello world from Automation plugin')
ArgentStar
Posts: 5
Joined: 07 Jun 2011, 18:13

Re: Python scripting with Automation plugin

Post by ArgentStar »

Apologies, I didn't have enough to time to give more detail about what I'd already tried as I was just heading out to work. I'd already got as far as creating a *.pys file and I already had ActivePython installed anyway. The scripts show up in the Automation menu, but nothing happens when I select them. It looks like the script isn't running at all. Even if I do something that doesn't require any visible output like changing the clipboard contents or something, nothing happens. :(

Thanks for taking the time to help, though. Much appreciated. :) Any idea what might be causing the problem? Has anyone actually had success themselves with using Python this way? I get the feeling I'm missing something blatantly obvious and I'm going to feel like an idiot when I find out. That tends to be the way with programming.
manison
Plugin Developer
Plugin Developer
Posts: 216
Joined: 09 Dec 2005, 23:23
Location: Ceske Budejovice, Czech Republic
Contact:

Re: Python scripting with Automation plugin

Post by manison »

I downloaded latest version of ActivePython and tried simple Python script and got the same behavior you are describing. I will try to take a deeper look what's going on.
manison
Plugin Developer
Plugin Developer
Posts: 216
Joined: 09 Dec 2005, 23:23
Location: Ceske Budejovice, Czech Republic
Contact:

Re: Python scripting with Automation plugin

Post by manison »

It seems that the recent versions of the Python scripting engines are broken in respect to the Active Scripting technology used by the Windows Script Host and also Salamander. If you can use the version 2.5 which should work fine.
User avatar
otrov
Posts: 110
Joined: 10 Feb 2010, 04:39

Re: Python scripting with Automation plugin

Post by otrov »

manison wrote:Hello world Python example for Salamander (save as hello.pys):

Code: Select all

Salamander.MsgBox('Hello world from Automation plugin')
Works fine here on Windows XP SP3 32bit with official Python 2.6.6. Additionally I have http://sourceforge.net/projects/pywin32/
I had no idea that Salamander can be scripted with Python. So nice possibilities...
ArgentStar
Posts: 5
Joined: 07 Jun 2011, 18:13

Re: Python scripting with Automation plugin

Post by ArgentStar »

Once again, thanks for the help, folks. :) But alas I'm still getting no joy. Tried using 2.5, 2.7, and 3.1. All to no avail. I'm completely stumped. :(
Post Reply