Roll your own script dialog

Hier diskutieren die Betatester von PhotoLine untereinander und mit den Entwicklern
User avatar
russellcottrell
Mitglied
Posts: 132
Joined: Sat 26 Jul 2014 10:13

Roll your own script dialog

Post by russellcottrell » Mon 12 Nov 2018 23:00

Here is a test of a dialog which is just an html file opened by a script. A parameter string is generated by javascript which is then copied and pasted into an input box so the script can take it from there.

Place browser.htm into the Defaults/Automation file together with browser.vbs.

p.s. I tried to pass parameters to the html file via
URL = Chr(34) & appPath & "\Defaults\Automation\browser.htm" & "?param1=first&param2=second" & Chr(34)
but it doesn't work.

browser.htm:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>

<title>Dialog</title>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<meta http-equiv="content-language" content="en-us">

<SCRIPT type="text/javascript"><!--

function generate() {

var str = "";

var radios = document.theForm.R0;
for (var i=0; i<radios.length; i++) {
  if (radios[i].checked) {
    str += radios[i].value + "|";
    break;
  }
}

var params = document.getElementsByName("param");
for (var i=0; i<params.length; i++)
  str += params[i].value + "|";

str = str.substr(0, str.length - 1);

document.theForm.output.value = str;

document.theForm.output.select();

}

//--></SCRIPT>

</head>

<body>

<form name="theForm">

bit depth:&nbsp;
<input type="radio" name="R0" value="PT8Bit">8-bit&nbsp;
<input type="radio" name="R0" value="PT16Bit">16-bit&nbsp;
<input type="radio" name="R0" value="PT32Bit">32-bit<br>
<br>
width:&nbsp; <input type="text" name="param"><br>
<br>
height:&nbsp; <input type="text" name="param"><br>
<br>
resolution:&nbsp; <input type="text" name="param"><br>
<br>
<a href="javascript:;" onclick="generate(); return false">generate</a><br>
<br>
parameter string:&nbsp; <input name="output" size="64">

</form>

</body>
</html>
browser.vbs:

Code: Select all

Option Explicit

Dim doc, image
Dim fso, appPath, objShell, URL, params
Const PTRGB = 1
Const PT8Bit = 0
Const PT32Bit = 4096
Const PT16Bit = 8192

Set fso = CreateObject("Scripting.FileSystemObject")
appPath = fso.GetAbsolutePathName(".")

Set objShell = CreateObject("WScript.Shell")

URL = Chr(34) & appPath & "\Defaults\Automation\browser.htm" & Chr(34)
objShell.run URL, 1

params = InputBox("parameter string:")
params = Split(params, "|")

Set doc = CreateObject("PhotoLine.Document")
doc.DocumentMode = False
Set image = CreateObject("PhotoLine.Image")
image.InitPicture PTRGB+Eval(params(0)), Array(CLng(params(1)), CLng(params(2))), Array(1, 1, 1)
doc.RootLayer.Insert image, -1
doc.Resolution = CLng(params(3))

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

Re: Roll your own script dialog

Post by Herbert123 » Tue 13 Nov 2018 09:32

This is great. Although clunky, since that parameter string must be copied manually. If we could use html forms directly as front-end panels in PhotoLine, that would be awesome: create our own custom html GUIs to control scripts.
/*---------------------------------------------*/
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
russellcottrell
Mitglied
Posts: 132
Joined: Sat 26 Jul 2014 10:13

Re: Roll your own script dialog

Post by russellcottrell » Wed 14 Nov 2018 01:15

This works to pass parameters to the dialog; but the browser must be specified:

Code: Select all

URL = Chr(34) & "file:\\\" & appPath & "\Defaults\Automation\browser.htm" & "?param1=first&param2=second" & Chr(34)
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "C:\Program Files\Mozilla Firefox\firefox.exe", URL, "", "open", 1