#newcommand
@script JScript
function OnClick(clickData)
{
// Open the Other Logs console
clickData.func.command.RunCommand("Set UTILITY=otherlog")
DOpus.ClearOutput();
// duplicate dialog check, return if dialog active
// if (DOpus.vars("duplicatedialog").value) {
//return;
// }
// DOpus.vars.set("duplicatedialog", true);
// if (DOpus.vars("uniquevaluenotstoredyet").value) return;
//clickData.func.command.RunCommand("cd " + sourcepath);
//var fso = new ActiveXObject("Scripting.FileSystemObject");
//var a = fso.CreateTextFile("testfile.txt", true);
//a.WriteLine("This is a test.");
//a.Close();
// debug dialog
function debug(message) {
var dialog = clickData.func.Dlg; // creates a dialog object
dialog.message = message;
dialog.window = clickData.func.sourcetab;
dialog.buttons = "OK"
dialog.Show()
}
// SIMPLE DIALOGS CANNOT CHANGE CONTROLS
function simpleDialog () {
var dialog = DOpus.Dlg;
dialog.window = clickData.func.sourcetab;
dialog.template = "debug dialog";
var retVal = dialog.Show(); // set retVal to value of control clicked
DOpus.Output("Return code = " + retVal);
}
// Main Dialog init
var iconname, iconLarge, iconSmall, iconArtist, iconCopy;
var dialog = DOpus.Dlg;
dialog.template = "Main Dialog";
dialog.LoadPosition("Foo_Dialog_Position");
dialog.title = "Directory Opus";
dialog.detach = true;
dialog.opacity = 220;
dialog.icon = "info"
dialog.Create();
// init name with selected file stem if a file is selected in source tab
var source = clickData.func.sourcetab;
//dialog.Control("static4").bg = "#aaffaa";
dialog.Control("static4").bg = "#ff0000";
dialog.Control("static4").fg = "#ffffff";
dialog.Control("edit4").value = "Various";
dialog.Control("edit5").value = "©2022";
if (source.stats.selitems > 0) {
dialog.Control("edit1").value = source.selected(0).name_stem;
dialog.Control("edit1").SelectRange(0,-1);
}
// Main Dialog message loop
while (true) {
var msg = dialog.GetMsg();
if (!msg.result) break;
iconLarge = dialog.Control("edit2").value;
iconSmall = dialog.Control("edit3").value;
DOpus.Output("Large = " + iconLarge);
DOpus.Output("Small = " + iconSmall);
if ((msg.event == "click" && dialog.Control("button1").focus == true) && !((iconSmall >= 12 && iconSmall <= 256) && (iconLarge >= 12 && iconLarge <= 256))) {
dialog.Control("static4").label = "Size is not between 12px and 256px";
dialog.Control("static4").visible = 1;
continue;
}
else if ((msg.event == "click" && dialog.Control("button1").focus == true) && (iconSmall > iconLarge)) {
dialog.Control("static4").label = "Small is bigger than Large";
dialog.Control("static4").visible = 1;
continue;
}
else if ((msg.event == "click" && dialog.Control("button1").focus == true) && (iconLarge == iconSmall)) {
dialog.Control("static4").label = "Large is the same as Small";
dialog.Control("static4").visible = 1;
continue;
}
if ((msg.event == "click" && dialog.Control("button1").focus == true) && ((iconSmall >= 12 && iconSmall <= 256) && (iconLarge >= 12 && iconLarge <= 256))) {
break;
}
else {
dialog.Control("static4").visible = 0;
}
}
dialog.SavePosition("Foo_Dialog_Position");
// Cancel pressed
if (dialog.result == 0) return;
DOpus.Output(dialog.result);
// if (dialog.Control("button1").focus == true) {
// dialog.Control("editSearch").value = "";
// }
// WORK IN PROGRESS
var cmd = clickData.func.command;
var filename = dialog.Control("edit1").value;
var sourcepath = clickData.func.sourcetab.path;
// montage.exe needs to be in source tab
var montage = (sourcepath + "\\montage ?");
cmd.RunCommand("cd " + sourcepath);
cmd.RunCommand(montage);
// clickData.func.command.RunCommand("montage *.png -geometry 32x32+0+0 -tile 16 -background transparent -filter Lanczos -quiet large.png");
DOpus.Output(sourcepath);
DOpus.Output(montage);
// debug(filename);
// --------------------------------------------------------
// duplicate dialog global var reset
// DOpus.vars.set("duplicatedialog", false);
DOpus.Output("END");
}
==SCRIPT RESOURCES
<resources>
<resource name="debug dialog" type="dialog">
<dialog fontsize="22" height="42" lang="english" title="Debug" width="84">
<control halign="center" height="8" name="static1" title="REACHED HERE" type="static" valign="top" width="66" x="9" y="6" />
<control close="1" default="yes" height="14" name="button1" title="Okay" type="button" width="50" x="17" y="24" />
</dialog>
</resource>
<resource name="Main Dialog" type="dialog">
<dialog fontsize="12" height="180" lang="english" opacity="200" width="252">
<control halign="left" height="8" name="static1" title="Enter a unique name for the icon set" type="static" valign="top" width="120" x="66" y="12" />
<control halign="left" height="12" max="31" name="edit1" type="edit" width="112" x="66" y="24" />
<control halign="left" height="8" name="static2" title="Large Icon Size" type="static" valign="top" width="47" x="66" y="51" />
<control halign="left" height="8" name="static3" title="Small Icon Size" type="static" valign="top" width="47" x="66" y="64" />
<control halign="left" height="12" max="3" name="edit2" number="yes" title="32" type="edit" width="19" x="114" y="50" />
<control halign="left" height="12" max="3" name="edit3" number="yes" title="24" type="edit" width="19" x="114" y="63" />
<control default="yes" height="14" name="button1" title="OK" type="button" width="50" x="126" y="156" />
<control close="0" height="14" name="button2" title="Cancel" type="button" width="50" x="192" y="156" />
<control halign="center" height="8" name="static4" title="Size is not between 12px and 256px" type="static" valign="center" width="112" x="65" y="39" />
<control halign="left" height="8" name="static5" title="px" type="static" valign="top" width="12" x="135" y="52" />
<control halign="left" height="8" name="static6" title="px" type="static" valign="top" width="12" x="135" y="65" />
<control halign="left" height="8" name="static7" title="Artist" type="static" valign="top" width="19" x="45" y="92" />
<control halign="left" height="12" max="31" name="edit4" type="edit" width="112" x="66" y="90" />
<control halign="left" height="8" name="static8" title="Copyright" type="static" valign="top" width="33" x="31" y="109" />
<control halign="left" height="12" max="31" name="edit5" type="edit" width="112" x="66" y="108" />
</dialog>
</resource>
</resources>