1
Automation Interface, Add-Ins and Tools / Re: Run EA in background with Node.js
« on: August 11, 2025, 04:38:54 am »
of course I do not want any people to violate the EULA.
I removed it from the post.
I removed it from the post.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
!INC Local Scripts.EAConstants-JScript
/*
* Script Name:
* Author:
* Purpose:
* Date:
*/
function main()
{
docGenerator = Repository.CreateDocumentGenerator();
if (docGenerator.NewDocument("")) {
docGenerator.DocumentElement(188685, 0, "Test_Element");
docGenerator.SaveDocument("C:\\Temp\\Test_Element.docx", dtDOCX);
}
}
main();
!INC Local Scripts.EAConstants-JScript
/*
* Script Name:
* Author:
* Purpose:
* Date:
*/
function main()
{
var testVal = InputBox("enter your input here", "My InputBox");
MsgBox(testVal);
}
main();
function MsgBox(prompt="", title="MsgBox", style=0) {
style += 4096; // to make the popup active (foreground)
var WSH = new COMObject("WScript.Shell");
return WSH.Popup(prompt, 0, title, style);
}
function InputBox(prompt="Input", title="Inputbox", defaultText="") {
const fso = new COMObject("Scripting.FileSystemObject");
const WSH = new COMObject("WScript.Shell");
const vbsScriptFile = WSH.ExpandEnvironmentStrings("%TEMP%\\ea_inputbox.vbs");
const tmpInputFile = WSH.ExpandEnvironmentStrings("%TEMP%\\ea_input.tmp");
if (!fso.FileExists(vbsScriptFile)) {
CreateInputboxVBS(vbsScriptFile);
}
WSH.Run(`WScript "${vbsScriptFile}" "${tmpInputFile}" "${prompt}" "${title}" "${defaultText}"`, 1, true);
const ForReading = 1;
const file = fso.OpenTextFile(tmpInputFile, ForReading);
if (!file.AtEndOfStream) {
return file.ReadAll();
}
return "";
}
function CreateInputboxVBS(vbsScriptFile) {
// function to create the inputbox VBS sripts in folder
const fso = new COMObject("Scripting.FileSystemObject");
const vbsScriptContent = `dim tmpInputFile, prompt, title, defaultText, input
Set objArgs = WScript.Arguments
If objArgs.Count = 4 Then
tmpInputFile = objArgs(0)
prompt = objArgs(1)
title = objArgs(2)
defaultText = objArgs(3)
input = InputBox(prompt, title, defaultText)
End if
Const ForWriting = 2, CreateIfNeeded = true
set fso = CreateObject("Scripting.FileSystemObject")
set file = fso.OpenTextFile(tmpInputFile, ForWriting, CreateIfNeeded)
file.write input
file.close`.replace(/\t\t/g, '');
const overwrite=true, unicode=true;
const file = fso.CreateTextFile(vbsScriptFile, overwrite, unicode);
file.Write(vbsScriptContent);
file.Close();
}
function InputBox(prompt="Input", title="Inputbox", defaultText="") {
const fso = new COMObject("Scripting.FileSystemObject");
const WSH = new COMObject("WScript.Shell");
const vbsScriptFile = WSH.ExpandEnvironmentStrings("%TEMP%\\ea_inputbox.vbs");
const tmpInputFile = WSH.ExpandEnvironmentStrings("%TEMP%\\ea_input.tmp");
if (!fso.FileExists(vbsScriptFile)) {
CreateInputboxVBS(vbsScriptFile);
}
WSH.Run(`WScript "${vbsScriptFile}" "${tmpInputFile}" "${prompt}" "${title}" "${defaultText}"`, 1, true);
const ForReading = 1;
const file = fso.OpenTextFile(tmpInputFile, ForReading);
if (!file.AtEndOfStream) {
return file.ReadAll();
}
}
function CreateInputboxVBS(vbsScriptFile) {
// function to create the inputbox VBS sripts in folder
const fso = new COMObject("Scripting.FileSystemObject");
const vbsScriptContent = `dim tmpInputFile, prompt, title, defaultText, input
Set objArgs = WScript.Arguments
If objArgs.Count = 4 Then
tmpInputFile = objArgs(0)
prompt = objArgs(1)
title = objArgs(2)
defaultText = objArgs(3)
input = InputBox(prompt, title, defaultText)
End if
Const ForWriting = 2, CreateIfNeeded = true
set fso = CreateObject("Scripting.FileSystemObject")
set file = fso.OpenTextFile(tmpInputFile, ForWriting, CreateIfNeeded)
file.write input
file.close`.replace(/\t\t/g, '');
const overwrite=true, unicode=true;
const file = fso.CreateTextFile(vbsScriptFile, overwrite, unicode);
file.Write(vbsScriptContent);
file.Close();
}