/*************************************************************************** This macro simplifies management of macro files. It scans EmEditor Macros folder (Macros -> Customize -> Options -> folder) for .jsee, .vbee, .py files and appends new macros to the list of macros in the menu. It also removes from the menu macros that no longer exist. Handy after you add new macro files or rename existing ones. originally posted 5/21/2004 at http://www.emeditor.com/forum/viewtopic.php?t=135 ***************************************************************************/ var Macros = new Array(); //valid macro paths var macro = ""; //macro's path var count = 0; //macro's consecutive number var oFSO = new ActiveXObject("Scripting.FileSystemObject"); var oShell = new ActiveXObject( "WScript.Shell" ); //////////// GET VALID MACRO PATHS FROM THE REGISTRY /////////////////////// for (i=0; i<10000; i++) { try { macro = oShell.RegRead( "HKCU\\Software\\EmSoft\\EmEditor v3\\Macros\\Macro" + i ); if (oFSO.FileExists(macro)) { Macros[count] = macro; count++; } } catch (e) { break;} //any other way? } //////////// GET NEW .JSEE, .VBEE, .PY FILES FROM MACROS FOLDER //////////// var MacroFolder = oShell.RegRead( "HKCU\\Software\\EmSoft\\EmEditor v3\\Common\\MacroFolder" ); var oFolder = oFSO.GetFolder(MacroFolder); var oFiles = new Enumerator (oFolder.Files); //all files in Macros folder var extension; for (; !oFiles.atEnd(); oFiles.moveNext()) { macro = oFiles.item().Path; extension = oFSO.GetExtensionName(macro).toLowerCase(); if (extension == "vbee" || extension == "jsee" || extension == "py") { for (i=0; i<=count; i++) { if (i == count) { //macro is new Macros[count] = macro; count++; break; } if (Macros[i]==macro) { //macro is not new break; } if (Macros[i].toLowerCase()==macro.toLowerCase()) { //macro's casing is new Macros[i]=macro; break; } } } } //////////// UPDATE LIST OF MACROS IN THE REGISTRY ///////////////////////// oShell.RegDelete( "HKCU\\Software\\EmSoft\\EmEditor v3\\Macros\\" ) for (i=0; i