Copy link to clipboard
Copied
Hi all,
I successfully wrote and executed an idle task routine that periodically executes a simple method. now i need to add a functionality to that method so that it executes a simple javascript.
here is my code:
...
uint32 myTestIdleTask::RunTask(
uint32 appFlags, IdleTimer* timeCheck) {
if( appFlags &
( IIdleTaskMgr::kMouseTracking
| IIdleTaskMgr::kUserActive
| IIdleTaskMgr::kInBackground
| IIdleTaskMgr::kMenuUp))
{
return kOnFlagChange;
}
this->runTestScript();
return kmyTestFvExecInterval;
}
void myTestIdleTask::runTestScript() {
// this is the test script
PMString myTestScript("app.activeDocument.exportFile(ExportFormat.pdfType, File(\"/Users/testuser/testing.pdf\"),false);");
// i think i need to call CScriptRunner::RunScript()
// somewhere here but no success
}
Any help on how to execute the myTestScript Javascript code from the runTestScript() method?
Thanks in advance,
Hakan
I already solved my problem by using "IExtendScriptUtils".
For those who are interested here is my solution:
void myTestIdleTask::runTestScript() {
// this is the test script
PMString myTestScript("app.activeDocument.exportFile(ExportFormat.pdfType, File(\"/Users/testuser/testing.pdf\"),false);");
PMString engineName("myengine");
int32 errorCode=Utils<IExtendScriptUtils>()->RunScriptInEngine ( engineName, myTestScript);
}
Goodluck.
hakan
Copy link to clipboard
Copied
Dear Hakan
I read your post, I'm really very happy to say, B'coz I'm also struggle to run the "JavaScript" through VC++ coding,
I need your help to run the below script.
Code:
var myOs = getOs();
alert(myOs);
function getOs() {
if( $.os.substring(0, 7)=="Windows")
{
myUser = $.os;
return myUser;
}
else if($.os.substring(0, 7)=="Mac Os")
{
myUser = $.os;
return myUser;
}
}
I'm checking the OS. How to invoke this in to VC++ or run through VC++ coding. I'm creating the project using dollyxs.bat file.
Kindly give me a guideline to run the above script & help me.
Thanks in advance
Regards
T.R.Harihara SudhaN
Copy link to clipboard
Copied
I already solved my problem by using "IExtendScriptUtils".
For those who are interested here is my solution:
void myTestIdleTask::runTestScript() {
// this is the test script
PMString myTestScript("app.activeDocument.exportFile(ExportFormat.pdfType, File(\"/Users/testuser/testing.pdf\"),false);");
PMString engineName("myengine");
int32 errorCode=Utils<IExtendScriptUtils>()->RunScriptInEngine ( engineName, myTestScript);
}
Goodluck.
hakan
Copy link to clipboard
Copied
Dear hakan
I used the below coding [some slight modification], but this is not working............
Thats the way I need the help from you.
"For those who are interested here is my solution: "....
Yes, I'm interesed to know how to run the script using VC++....
Thanks & Regards
T.R.Harihara SudhaN
Copy link to clipboard
Copied
Sorry that I can't help you, because I am NOT coding for Microsoft platforms.
For the InDesign API part, as a starting point, from the SDK you can search samples using "IStartupShutdownService" so that you can find a suitable functionality to execute your javascript code at startup. And at that point you can call a method similar to my runTestScript() method.
Good luck.
Hakan
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more