Scripting issues

Here everybody can post his problems with PhotoLine
User avatar
russellcottrell
Mitglied
Posts: 51
Joined: Sat 26 Jul 2014 10:13

Scripting issues

Post by russellcottrell » Wed 12 Sep 2018 22:38

Hello; I have been trying to work with scripting; than you very much for implementing it. A few thoughts; I apologize if they have been addressed elsewhere but I couldn’t find much about it.

May I propose Javascript as the “standard” scripting language? It is cross-platform, and seems better to me than “VB Script for Windows and Apple Script for Mac.” I am a Windows user and I never use VB Script, even in active server pages. I thought I saw some .js files somwhere, maybe when I installed a beta; but I seem to have lost them.

Here is a simple .js file:

Code: Select all

var pl = new ActiveXObject("PhotoLine.application");
var doc = pl.ActiveDocument;

if(doc != null)
  doc.DoOperation("Scale", "Mode", 2, "ValueX", 200, "ValueY", 200, "Interpolation", 5);

pl = null;
I have tried some other operations with mixed success. For example, according to the (VBS) documentation, this should return an array of strings, but I can’t tell that it does:

var docArray = pl.OpenDialog();

It would help if the alert() function were implemented; it is hard to debug scripts without it.

I could not find a way to create a layer; doc.LayerArray.Insert() does not work.

A number of other operations would be useful; I can’t find any documentation for them:
-set the foreground/background color
-select a rectangle
-fill the selection with color
-change document size
-rotate document
-flatten image

Also, being able to open a dialog to accept user input would be handy.

User avatar
Herbert123
Mitglied
Posts: 1669
Joined: Sat 12 May 2012 21:38

Re: Scripting issues

Post by Herbert123 » Thu 13 Sep 2018 07:54

Javascript is supported as well. The v20 beta versions included JS examples as well

JS:
var pl = new ActiveXObject("PhotoLine.application");
var doc = pl.ActiveDocument;
var page;

pl.Visible = 1;

if(doc != null)
{
page = doc.ActivePage;
if (page != null)
{
var layer = page.RootLayer.First;
while (layer != null)
{
// 1 means Image (PhotoLine.LayerType.LTImage)
if (layer.Type == 1)
layer.DoOperation("Dither", "RasterSize", 32, "Angle", 0);
layer = layer.next;
}
}
}

VB:

Dim pl
Dim doc
Dim page
Dim layer

Set pl = CreateObject("PhotoLine.Application")
Set doc = pl.ActiveDocument

pl.Visible = True

If Not doc Is Nothing Then
For Each page In doc
Set layer = page.RootLayer.First
While (Not layer Is Nothing)
' 1 means Image (PhotoLine.LayerType.LTImage)
If (layer.Type = 1) Then
layer.DoOperation "Dither", "RasterSize", 32, "Angle", 0
End If
Set layer = layer.Next
wend
Next
End If
/*---------------------------------------------*/
System: Win10 64bit - i7 920@3.6Ghz, p6t Deluxe v1, 48gb (6x8gb RipjawsX), Nvidia GTX1080 8GB, Revodrive X2 240gb, e-mu 1820, 2XSamsung SA850 (2560*1440) and 1XHP2408H 1920*1200 portrait

User avatar
Gerhard Huber
Entwickler
Entwickler
Posts: 3549
Joined: Mon 18 Nov 2002 15:30
Location: Bad Gögging

Re: Scripting issues

Post by Gerhard Huber » Thu 13 Sep 2018 08:01

Herbert123 wrote:
Thu 13 Sep 2018 07:54
Javascript is supported as well. The v20 beta versions included JS examples as well
Javascript works, but we don't support it. VBS on Windows and AppleScript on macOS are the only supported scripting languages at the moment.

Martin Huber
Entwickler
Entwickler
Posts: 3174
Joined: Tue 19 Nov 2002 15:49

Re: Scripting issues

Post by Martin Huber » Thu 13 Sep 2018 10:03

russellcottrell wrote:
Wed 12 Sep 2018 22:38
var docArray = pl.OpenDialog();
This returns a COM SAFERARRAY. In JScript it has to be converted to an JScript array by

var jscriptArray = VBArray(docArray).toArray();

See:
https://blogs.msdn.microsoft.com/david. ... afe-array/
russellcottrell wrote:
Wed 12 Sep 2018 22:38
It would help if the alert() function were implemented; it is hard to debug scripts without it.
You can use:

var msgBox = new ActiveXObject("WScript.Shell");
msgBox.Popup("text");
russellcottrell wrote:
Wed 12 Sep 2018 22:38
I could not find a way to create a layer; doc.LayerArray.Insert() does not work.
There should be some samples in Scripting folder, that create new layers:
- AdjustmentWithGradient
- NewVector
- TextNewWithPageNumber

Martin

User avatar
russellcottrell
Mitglied
Posts: 51
Joined: Sat 26 Jul 2014 10:13

Re: Scripting issues

Post by russellcottrell » Fri 14 Sep 2018 05:27

Hello, and thank you for the feedback. One little glitch is that .js runs in Wine, .vbs doesn't. I used winetricks to install wsh57, vcrun6, and vb6run; I can run a simple "Hello, world." script with wscript; but the .vbs scripts still do not run in PhotoLine. Can you suggest anything else, other dependencies that are needed?

Martin Huber
Entwickler
Entwickler
Posts: 3174
Joined: Tue 19 Nov 2002 15:49

Re: Scripting issues

Post by Martin Huber » Mon 17 Sep 2018 09:32

russellcottrell wrote:
Fri 14 Sep 2018 05:27
Hello, and thank you for the feedback. One little glitch is that .js runs in Wine, .vbs doesn't. I used winetricks to install wsh57, vcrun6, and vb6run;
I am not a Wine expert, but according to what i found that should be sufficient.
russellcottrell wrote:
Fri 14 Sep 2018 05:27
I can run a simple "Hello, world." script with wscript; but the .vbs scripts still do not run in PhotoLine. Can you suggest anything else, other dependencies that are needed?
The built-in scripts don't work either? For example "AdjustmentWithGradient"?

I think it's strange that JScript is working, but VBScript isn't.

Martin