Roll your own script dialog

Hier diskutieren die Betatester von PhotoLine untereinander und mit den Entwicklern
Benutzeravatar
russellcottrell
Mitglied
Beiträge: 251
Registriert: Sa 26 Jul 2014 10:13
Wohnort: California

Roll your own script dialog

Beitrag von russellcottrell »

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: Alles auswählen

<!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: Alles auswählen

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))
Benutzeravatar
Herbert123
Mitglied
Beiträge: 2164
Registriert: Sa 12 Mai 2012 21:38

Re: Roll your own script dialog

Beitrag von Herbert123 »

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
Benutzeravatar
russellcottrell
Mitglied
Beiträge: 251
Registriert: Sa 26 Jul 2014 10:13
Wohnort: California

Re: Roll your own script dialog

Beitrag von russellcottrell »

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

Code: Alles auswählen

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