Hello I am having trouble getting started with scripting in AKelpad. I have copied the following code from the Plugins Manual
var AkelPad=new ActiveXObject("AkelPad.document"); // create object
var WshShell=WScript.CreateObject("WScript.Shell"); // for popup
var hMainWnd=AkelPad.GetMainWnd(); // retrieve window handle var dummy if (hMainWnd) // if AkelPad window exists
dummy=WshShell.popup("AkelPad is running") else
dummy=WshShell.popup("AkelPad is NOT running")
Saved it in the c:\Akelpad\Akelfiles\Plugs\Scripts folder Executing it causes a "Automation server can't create object" error on line 1
What am I doing wrong?
Jim
Scripting
- Author
- Message
-
Offline
- Posts: 1949
- Joined: Sat Mar 06, 2010 7:40 pm
- Location: Poland
Dellji
Plugins manual is a little outdated.
About scripts, read this: ...\AkelPad\AkelFiles\Docs\Scripts-Eng.txt.
Your script might look like this:
var WshShell=new ActiveXObject("WScript.Shell"); // for popup
var hMainWnd=AkelPad.GetMainWnd(); // retrieve window handle
var dummy;
if (hMainWnd) //if AkelPad window exists
dummy=WshShell.popup("AkelPad is running");
else
dummy=WshShell.popup("AkelPad is NOT running");
No need to create AkelPad object. This is always available.
Plugins manual is a little outdated.
About scripts, read this: ...\AkelPad\AkelFiles\Docs\Scripts-Eng.txt.
Your script might look like this:
var WshShell=new ActiveXObject("WScript.Shell"); // for popup
var hMainWnd=AkelPad.GetMainWnd(); // retrieve window handle
var dummy;
if (hMainWnd) //if AkelPad window exists
dummy=WshShell.popup("AkelPad is running");
else
dummy=WshShell.popup("AkelPad is NOT running");
No need to create AkelPad object. This is always available.
-
Offline
- Posts: 8
- Joined: Sun Nov 13, 2011 7:02 pm
- Location: Dayton, Ohio, USA
Scripting - Update
I thought I would update you on my progress. What I wanted to do was preserve the original file and copy it to another disk drive and folder with the date appended to the original file name before I did a series of find and replace operations. Here's the code to do the save operation:
/ Get today date & time
var currentTime = new Date()
// extract month
var month = currentTime.getMonth() + 1
// extract day
var day = currentTime.getDate()
// extract year
var year = currentTime.getFullYear()
var d = month + "-" + day + "-" + year
var fso, f, s;
var pEditFile=AkelPad.GetEditFile(0); // Get file name & path
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFileName(pEditFile); // Extract file name only
// getFileName(f);
var fileNoExtension
// Will find the last dot and replace it and anything behind it with nothing.
fileNoExtension= f.replace(/\..*(?!.*\.)/, "");
// Debug statement
// WScript.Echo(fileNoExtension);
var xFilePath = "H:\\FTW-10-Data\\" // Note the double back slashes
var xGed = "ged"
// build file name
var nFilename = xFilePath + fileNoExtension + "-" + d + "." + xGed;
var hMainWnd=AkelPad.GetMainWnd();
AkelPad.MessageBox(hMainWnd, nFilename, "Find & Replace", 64 /*MB_ICONINFORMATION*/);
Hope this might help anybody else trying to do the same.
Jim
/ Get today date & time
var currentTime = new Date()
// extract month
var month = currentTime.getMonth() + 1
// extract day
var day = currentTime.getDate()
// extract year
var year = currentTime.getFullYear()
var d = month + "-" + day + "-" + year
var fso, f, s;
var pEditFile=AkelPad.GetEditFile(0); // Get file name & path
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFileName(pEditFile); // Extract file name only
// getFileName(f);
var fileNoExtension
// Will find the last dot and replace it and anything behind it with nothing.
fileNoExtension= f.replace(/\..*(?!.*\.)/, "");
// Debug statement
// WScript.Echo(fileNoExtension);
var xFilePath = "H:\\FTW-10-Data\\" // Note the double back slashes
var xGed = "ged"
// build file name
var nFilename = xFilePath + fileNoExtension + "-" + d + "." + xGed;
var hMainWnd=AkelPad.GetMainWnd();
AkelPad.MessageBox(hMainWnd, nFilename, "Find & Replace", 64 /*MB_ICONINFORMATION*/);
Hope this might help anybody else trying to do the same.
Jim
-
Offline
- Posts: 3217
- Joined: Wed Nov 29, 2006 1:19 pm
- Location: Киев, Русь
- Contact:
Dellji
Look Scripts collection.
By saving files already have the following scripts: SaveAs.js, saveStoreTime.js, OpenSaveMask.js, SaveDefault.js.
Look Scripts collection.
By saving files already have the following scripts: SaveAs.js, saveStoreTime.js, OpenSaveMask.js, SaveDefault.js.