I was new to DOpus last year and proposed adding new simplified script.
Hello! Request to add a new simplified script - Help & Support - Directory Opus Resource Centre (dopus.com).
Now that I have learned some basic JScript, I know that adding another scripting language may be redundant, but I think JScript can be simplified to make scripting more efficient, more friendly to new users, and easier to get started.
Now my idea is to add some built-in functions, like some common dialogs.
inputBox(title, topic, notes, default value, style of dialog, width, height, drop-down items, iconFile)
var tab = DOpus.listers(0).activetab;
var defValue = tab.selected(0).name_stem;
// inputBox(title, topic, notes, default value, style of dialog, width, height, drop-down items, iconFile)
result = inputBox("Directory Opus", "Move Here to New Subfolder", "Select or enter folder name or subpath", defValue, "combo", 500, 208, "selectedNames", "D:\\Icons\\MOVE.png");
msgbox(result)
function inputBox(title, topic, notes, defValue , style, width, height, drop_downItems, iconFile)
{
var dlgInpput = DOpus.Dlg();
dlgInpput.title = topic;
if (style == "combo")
dlgInpput.template = "dlgCombox";
dlgInpput.detach = true;
dlgInpput.Create();
dlgInpput.Control("static").style = "b";
dlgInpput.Control("static").label = topic;
dlgInpput.Control("static2").label = notes;
dlgInpput.Control("static3").label = iconFile;
dlgInpput.Control("combo").label = defValue;
dlgInpput.Control("combo").SelectRange(0, -1);
dlgInpput.Control("static").cx = width-12;
dlgInpput.Control("static2").cx = width-12;
dlgInpput.Control("static2").cy = height/4;
if (width > 501)
dlgInpput.Control("combo").cx = width-42;
else if (width < 801 && width > 501)
dlgInpput.Control("combo").cx = width-402;
dlgInpput.Control("combo").y = height-(height/1.9);
dlgInpput.cx = width;
dlgInpput.cy = height;
if (drop_downItems == "selectedNames") {
for(var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
dlgInpput.Control("combo").AddItem(e.item().name_stem_m);
}
}
dlgInpput.Show();
//-- Add string trim() method
String.prototype.trim = function(s){s=s||"\\s";return this.replace(new RegExp("^("+s+"){1,}\|("+s+"){1,}$","g"),"");}
// msg loop
do
{
msg = dlgInpput.GetMsg();
/*
// Selection
if(msg == true && dlgInpput.Control("combo").focus == true) {
DOpus.Output(dlgInpput.Control("combo").label);
}
*/
// Result, perform the move operation
if (dlgInpput.result == 1) {
return dlgInpput.Control("combo").label.trim();
}
/*
// If the button 3 is pressed
if(dlgInpput.result == 2) {
DOpus.Output("Button 3 is pressed");
}
// If the button 4 is pressed
if(dlgInpput.result == 3) {
DOpus.Output("Button 4 is pressed");
}
*/
} while (msg == true);
}
function msgbox(message)
{
var dlgMsg = DOpus.Dlg();
dlgMsg.message = message;
dlgMsg.buttons = "&OK";
dlgMsg.show
return dlgMsg.Result
}
==SCRIPT RESOURCES
<resources>
<resource name="dlgCombox" type="dialog">
<dialog fontsize="8" height="78" lang="english" resize="yes" title="Directory Opus" width="322">
<control edit="yes" height="40" name="combo" type="combo" width="306" x="8" y="40" />
<control close="3" enable="no" height="14" name="btn4" resize="xy" title="&4" type="button" visible="no" width="50" x="101" y="57" />
<control close="2" enable="no" height="14" name="btn3" resize="xy" title="&3" type="button" visible="no" width="50" x="155" y="57" />
<control halign="left" height="8" name="static" title="Topic" type="static" valign="top" width="280" x="30" y="10" />
<control halign="left" height="16" name="static2" title="Notes" type="static" valign="top" width="280" x="30" y="22" />
<control halign="center" height="14" image="yes" name="static3" title="Icon" type="static" valign="top" width="14" x="8" y="7" />
<control close="1" default="yes" height="14" name="btnOK" resize="xy" title="&OK" type="button" width="50" x="209" y="57" />
<control close="0" height="14" name="btnCancel" resize="xy" title="&Cancel" type="button" width="50" x="263" y="57" />
</dialog>
</resource>
</resources>
Maybe more detailed or simplified.
inputBox(topic, notes, default value, width, height, drop-down items, iconFile)
I often use AutoHotkey's MsgBox, ToolTip, and TrayTip functions.
There are also search, format values, format text and others.