Quote
Open your User Macro Folder (Edit > Configuration > User-Defined Macros) or your Macro Folder (Edit > Configuration > Macros) and create the following text file(s):
Quote
JamesD
I have other macros which read dot js files in WSH. Are they likely to have the same problem?
Quote
JamesD
SearchH is one I am now concerned about.
var SearchH_History_Filespec= SearchH_Profile_Path + "\\History.dat" ; var SearchH_Pref_Filespec= SearchH_Profile_Path + "\\prefs.js"; var SearchH_Defaults_Filespec = SearchH_Root_Path + "\\defaults\\pref\\I10n.js" var SearchH_Htm_Filespec= SearchH_Profile_Path + "\\SH.htm";
c.WriteLine( "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">" );
Quote
JamesD
Does the error message about loading problems occur when KM starts or does it occur when you try to use FavRenAdd?
setpref(STRING,"kmeleon.plugins.favorites.newitemFolder",$_SubFolder); # HERE IS THE TRAP # When the plugin is called below, it's not sure that the pref is already updated from above $_SubFolder==":"?0: plugin(favorites,$_FavAction);
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage) # # ---------- FRA_U8.kmm # ---------- K-Meleon Macro Language Rename/Add page to Favorites --------------- # # Dependencies : main.kmm, Favorites plugin active, JScript, Windows Scripting Host # Resources : - # Preferences : - # Version : 1.01 2008-07-19 # -------------------------------------------------------------------------------- # _FRA_U8_RnameTrue{ #### look three places for the favorites directory $_FRA_U8_FavFolder=getpref(STRING,"kmeleon.plugins.favorites.directory"); $_FRA_U8_FavFolder==""?$_FRA_U8_FavFolder=readreg("HKCU","Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Favorites"):0; $_FRA_U8_FavFolder==""?$_FRA_U8_FavFolder=readreg("HKLM","Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Favorites"):0; #### $_FRA_U8_FavFolder should have the path for the favorites folder c:\something\favorites #### call _FRA_U8_RnameTrue_loop until $_FRA_U8_SubFolder is no longer a "?" $_FRA_U8_SubFolder="?"; while($_FRA_U8_SubFolder=="?") &_FRA_U8_RnameTrue_loop; $_FRA_U8_Title = substr($_FRA_U8_value,1); macros(_FRA_U8_Sanitize_Title) ; $_FRA_U8_PathName = $_FRA_U8_FavFolder."\\".$_FRA_U8_SubFolder."\\".$_FRA_U8_Title.".url" ; $_FRA_U8_Ext_Interger = 1; while ($_FRA_U8_Ext_Interger > 0 ) &_FRA_U8_Duplicates_loop ; $_FRA_U8_Profile_Path = getfolder( ProfileFolder ); # $_fmax: The length of the command line must not exceed 258 characters! $_fmax=258; $_fcmd="(wscript.exe \"".$_FRA_U8_Path."\" \"".$_FRA_U8_PathName."\" \"".$_FRA_U8_CurURL.")" ; length($_fcmd)>$_fmax ? &_FRA_U8_Error : exec("wscript.exe \"".$_FRA_U8_Path."\" \"".$_FRA_U8_PathName."\" \"".$_FRA_U8_CurURL."\"") ; } _FRA_U8_Error{ setclipboard($_FRA_U8_Path. "\n" .$_FRA_U8_Profile_Path. "\n" .length($_fcmd) ); alert("Unable to create favorite - data too long!\n\nThe data was copied to the clipboard.","Failure to complete",EXCLAIM); } _FRA_U8_Sanitize_Title{ $_FRA_U8_RevTitle = gsub( "?"," ",$_FRA_U8_Title); $_FRA_U8_RevTitle = gsub( ":"," ",$_FRA_U8_RevTitle); $_FRA_U8_RevTitle = gsub( "*"," ",$_FRA_U8_RevTitle); $_FRA_U8_RevTitle = gsub( "<"," ",$_FRA_U8_RevTitle); $_FRA_U8_RevTitle = gsub( ">"," ",$_FRA_U8_RevTitle); $_FRA_U8_RevTitle = gsub( "/"," ",$_FRA_U8_RevTitle); $_FRA_U8_RevTitle = gsub( "|"," ",$_FRA_U8_RevTitle); $_FRA_U8_RevTitle = gsub( "\\","",$_FRA_U8_RevTitle); $_FRA_U8_Title = gsub( "\"","^",$_FRA_U8_RevTitle); } _FRA_U8_Duplicates_loop{ $_FRA_U8_Exists=readfile($_FRA_U8_PathName); $_FRA_U8_Exists=1.$_FRA_U8_Exists ; $_FRA_U8_Len2=length($_FRA_U8_Exists); $_FRA_U8_Len2 == 1 ? $_FRA_U8_Ext_Interger=0 : &_FRA_U8_Extend; } _FRA_U8_Extend{ $_FRA_U8_Wrk_Int = $_FRA_U8_Ext_Interger - 1 ; $_FRA_U8_Ext_Interger == 1 ? $_FRA_U8_PathName = gsub(".url" , "[".$_FRA_U8_Ext_Interger."].url",$_FRA_U8_PathName):0; $_FRA_U8_Ext_Interger > 1 ? $_FRA_U8_PathName = gsub("[".$_FRA_U8_Wrk_Int."].url" , "[".$_FRA_U8_Ext_Interger."].url" , $_FRA_U8_PathName):0; $_FRA_U8_Ext_Interger = $_FRA_U8_Ext_Interger + 1 ; } _FRA_U8_RnameTrue_loop{ $_FRA_U8_SubFolder=promptforfolder("Specify where to add the new shortcut. Select your Favorites folder or one of its subfolders:",$_FRA_U8_FavFolder); $_FRA_U8_SubFolder=$_FRA_U8_SubFolder=="" ? "" : index($_FRA_U8_SubFolder,$_FRA_U8_FavFolder) == 0 ? substr($_FRA_U8_SubFolder,length($_FRA_U8_FavFolder)+1) : "?"; } _FRA_U8_RenameAdd{ $_FRA_U8_CurrTitle = $TITLE; $_FRA_U8_CurURL = $URL; $_FRA_U8_value=prompt($_FRA_U8_CurrTitle,"Rename the Favorite Title here",$_FRA_U8_CurrTitle); ### cancel from prompt will return a length of zero to which we add one $_FRA_U8_value = 1.$_FRA_U8_value; $_FRA_U8_Len=length($_FRA_U8_value); ### if the length is 1 cancelled was pressed on the prompt box $_FRA_U8_Len == 1 ? &_FRA_U8_Cancelled :&_FRA_U8_RnameTrue ; } _FRA_U8_Cancelled{ $FRA_U8_Button=confirm("Did you mean to cancel?","Affirm cancel" ,YESNO,QUESTION); $FRA_U8_Button == "YES" ? 0 : &_FRA_U8_RenameAdd ; } _FRA_U8_ModMenu{ ### add another option to Favorites menu if favorites plugin is active $kFavorites=="true"?setmenu("F&avorites",macro,"&Rename-Add-8",_FRA_U8_RenameAdd,1):0; ### show in Document Popup ; $kFavorites=="true"?setmenu("DocumentSave",macro,"&Rename-Add-8 to Favorites",_FRA_U8_RenameAdd,1):0; } _FRA_U8_GetPath{ ### FRA_U8.js is supposed to be located in the same folder as FRA_U8.kmm (this file). ### If it isn't, Windows Script Host will notify the user. $_FRA_U8_Data=readfile(getfolder(MacroFolder)."\\FRA_U8.kmm"); $_FRA_U8_Path=getfolder($_FRA_U8_Data==""?UserMacroFolder:MacroFolder)."\\FRA_U8.js"; } $OnStartup=$OnStartup."_FRA_U8_GetPath;"; $OnInit=$OnInit."_FRA_U8_ModMenu;"; $macroModules=$macroModules."FRA_U8;";
/* FRA_U8.js by JamesD, version 1.01 2008-07-19 This script is a helper application for the K-Meleon Macro Module FRA_U8.kmm that enables you to rename a favorite, select a folder, and write the favorite to that folder. Windows Script Host 1.0 (or better) required! WSH is part of Microsoft Internet Explorer 5.0 and newer. Latest version of WSH is available at http://msdn.microsoft.com/scripting/ */ if(WScript.Arguments.count()==2) { var $_FRA_U8_PathName = WScript.Arguments(0); var $_FRA_U8_CurURL = WScript.Arguments(1); var WshShell = new ActiveXObject("WScript.Shell") var oShellLink = WshShell.CreateShortcut($_FRA_U8_PathName); oShellLink.TargetPath = $_FRA_U8_CurURL; oShellLink.Save(); } else { objArgs = WScript.Arguments ; WScript.Echo(WScript.Arguments.Count()); for (i=0; i<objArgs.length; i++) { WScript.Echo(objArgs(i)) } }
Quote
JamesD
I think the problem must be that I do not know how to code for UTF-8. These work for me, but I use only English. Maybe someone who reads this post will be kind and explain to me what I have to change to make them work for languages other than English.
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage) # # ---------- FavRenAdd.kmm # ---------- K-Meleon Macro Language Rename/Add page to Favorites --------------- # ---------- INTERNATIONAL VERSION # # Dependencies : - main.kmm, Favorites plugin active, JScript, Windows Scripting Host # Resources : - Registry keys "HKCU\\Software\\KMELEON\\FavRenAdd\\URLname" # and "HKCU\\Software\\KMELEON\\FavRenAdd\\URLdisc" # Preferences : - # Version : - 3.0 2008-07-30 # -------------------------------------------------------------------------------- # _FavRenAdd_RnameTrue{ #### look three places for the favorites directory $_FavRenAdd_FavFolder=getpref(STRING,"kmeleon.plugins.favorites.directory"); $_FavRenAdd_FavFolder==""?$_FavRenAdd_FavFolder=readreg("HKCU","Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Favorites"):0; $_FavRenAdd_FavFolder==""?$_FavRenAdd_FavFolder=readreg("HKLM","Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Favorites"):0; #### $_FavRenAdd_FavFolder should have the path for the favorites folder c:\something\favorites #### call _FavRenAdd_RnameTrue_loop until $_FavRenAdd_SubFolder is no longer a "?" $_FavRenAdd_SubFolder="?"; while($_FavRenAdd_SubFolder=="?") &_FavRenAdd_RnameTrue_loop; $_FavRenAdd_Title = substr($_FavRenAdd_value,1); macros(_FavRenAdd_Sanitize_Title) ; $_FavRenAdd_PathName = $_FavRenAdd_FavFolder."\\".$_FavRenAdd_SubFolder."\\".$_FavRenAdd_Title.".url" ; $_FavRenAdd_Ext_Interger = 1; while ($_FavRenAdd_Ext_Interger > 0 ) &_FavRenAdd_Duplicates_loop ; ## enclosure of a parameter in double quotes is only necessary when the parameter can contain whitespace ## therefor the 1, 2, and 3 in the next "exec" lines do not have double quotes ## first check the line lengths $_fmax=258 ; $_FavRenAdd_ExVal = 0 ; $_fcmd = "(wscript.exe \"".$_FavRenAdd_Path."\" 1 \"".$_FavRenAdd_PathName.")" ; length($_fcmd)>$_fmax ? &_FavRenAdd_Error1:0; $_fcmd = "(wscript.exe \"".$_FavRenAdd_Path."\" 2 \"".$_FavRenAdd_CurURL.")" ; length($_fcmd)>$_fmax ? &_FavRenAdd_Error2:0; $_FavRenAdd_ExVal < 2 ? &_FavRenAdd_RunScript:0; } _FavRenAdd_RunScript{ exec("wscript.exe \"".$_FavRenAdd_Path."\" 1 \"".$_FavRenAdd_PathName."\""); exec("wscript.exe \"".$_FavRenAdd_Path."\" 2 \"".$_FavRenAdd_CurURL."\""); exec("wscript.exe \"".$_FavRenAdd_Path."\" 3 \""execute"\"") ; } _FavRenAdd_Error1{ alert("Unable to create favorite - data too long! Line length, ". length($_fcmd). " and line are displayed\n\n". $_fcmd, "String length too long!", EXCLAIM) ; $_FavRenAdd_ExVal = $_FavRenAdd_ExVal + 2; } _FavRenAdd_Error2{ alert("Unable to create favorite - data too long! Line length, ". length($_fcmd). " and line are displayed\n\n". $_fcmd, "String length too long!", EXCLAIM) ; $_FavRenAdd_ExVal = $_FavRenAdd_ExVal + 3; } _FavRenAdd_Sanitize_Title{ $_FavRenAdd_RevTitle = gsub( "?"," ",$_FavRenAdd_Title); $_FavRenAdd_RevTitle = gsub( ":"," ",$_FavRenAdd_RevTitle); $_FavRenAdd_RevTitle = gsub( "*"," ",$_FavRenAdd_RevTitle); $_FavRenAdd_RevTitle = gsub( "<"," ",$_FavRenAdd_RevTitle); $_FavRenAdd_RevTitle = gsub( ">"," ",$_FavRenAdd_RevTitle); $_FavRenAdd_RevTitle = gsub( "/"," ",$_FavRenAdd_RevTitle); $_FavRenAdd_RevTitle = gsub( "|"," ",$_FavRenAdd_RevTitle); $_FavRenAdd_RevTitle = gsub( "\\","",$_FavRenAdd_RevTitle); $_FavRenAdd_Title = gsub( "\"","^",$_FavRenAdd_RevTitle); } _FavRenAdd_Duplicates_loop{ $_FavRenAdd_Exists=readfile($_FavRenAdd_PathName); $_FavRenAdd_Exists=1.$_FavRenAdd_Exists ; $_FavRenAdd_Len2=length($_FavRenAdd_Exists); $_FavRenAdd_Len2 == 1 ? $_FavRenAdd_Ext_Interger=0 : &_FavRenAdd_Extend; } _FavRenAdd_Extend{ $_FavRenAdd_Wrk_Int = $_FavRenAdd_Ext_Interger - 1 ; $_FavRenAdd_Ext_Interger == 1 ? $_FavRenAdd_PathName = gsub(".url" , "[".$_FavRenAdd_Ext_Interger."].url",$_FavRenAdd_PathName):0; $_FavRenAdd_Ext_Interger > 1 ? $_FavRenAdd_PathName = gsub("[".$_FavRenAdd_Wrk_Int."].url" , "[".$_FavRenAdd_Ext_Interger."].url" , $_FavRenAdd_PathName):0; $_FavRenAdd_Ext_Interger = $_FavRenAdd_Ext_Interger + 1 ; } _FavRenAdd_RnameTrue_loop{ $_FavRenAdd_SubFolder=promptforfolder("Specify where to add the new shortcut. Select your Favorites folder or one of its subfolders:",$_FavRenAdd_FavFolder); $_FavRenAdd_SubFolder=$_FavRenAdd_SubFolder=="" ? "" : index($_FavRenAdd_SubFolder,$_FavRenAdd_FavFolder) == 0 ? substr($_FavRenAdd_SubFolder,length($_FavRenAdd_FavFolder)+1) : "?"; } _FavRenAdd_RenameAdd{ $_FavRenAdd_CurrTitle = $TITLE; $_FavRenAdd_CurURL = $URL; $_FavRenAdd_value=prompt($_FavRenAdd_CurrTitle,"Rename the Favorite Title here",$_FavRenAdd_CurrTitle); ### cancel from prompt will return a length of zero to which we add one $_FavRenAdd_value = 1.$_FavRenAdd_value; $_FavRenAdd_Len=length($_FavRenAdd_value); ### if the length is 1 cancelled was pressed on the prompt box $_FavRenAdd_Len == 1 ? &_FavRenAdd_Cancelled :&_FavRenAdd_RnameTrue ; } _FavRenAdd_Cancelled{ $FavRenAdd_Button=confirm("Did you mean to cancel?","Affirm cancel" ,YESNO,QUESTION); $FavRenAdd_Button == "YES" ? 0 : &_FavRenAdd_RenameAdd ; } _FavRenAdd_ModMenu{ ### add another option to Favorites menu if favorites plugin is active $kFavorites=="true"?setmenu("F&avorites",macro,"&Rename-Add",_FavRenAdd_RenameAdd,1):0; ### show in Document Popup ; $kFavorites=="true"?setmenu("DocumentSave",macro,"&Rename-Add to Favorites",_FavRenAdd_RenameAdd,1):0; } _FavRenAdd_GetPath{ ### FavRenAdd.js is supposed to be located in the same folder as FavRenAdd.kmm (this file). ### If it isn't, Windows Script Host will notify the user. $_FavRenAdd_Data=readfile(getfolder(MacroFolder)."\\FavRenAdd.kmm"); $_FavRenAdd_Path=getfolder($_FavRenAdd_Data==""?UserMacroFolder:MacroFolder)."\\FavRenAdd.js"; } $OnStartup=$OnStartup."_FavRenAdd_GetPath;"; $OnInit=$OnInit."_FavRenAdd_ModMenu;"; $macroModules=$macroModules."FavRenAdd;";
/* FavRenAdd.js by JamesD, version 3.01 2008-07-30 INTERNATIONAL VERSION This script is a helper application for the K-Meleon Macro Module FavRenAdd.kmm that enables you to rename a favorite, select a folder, and write the favorite to that folder. Windows Script Host 1.0 (or better) required! WSH is part of Microsoft Internet Explorer 5.0 and newer. Latest version of WSH is available at http://msdn.microsoft.com/scripting/ */ if(WScript.Arguments.count()==2) { var WshShell = new ActiveXObject("WScript.Shell") if (WScript.Arguments(0) == 1) { WshShell.RegWrite ("HKCU\\Software\\KMELEON\\FavRenAdd\\URLname", WScript.Arguments(1), "REG_SZ"); } if (WScript.Arguments(0) == 2) { WshShell.RegWrite ("HKCU\\Software\\KMELEON\\FavRenAdd\\URLdisc", WScript.Arguments(1), "REG_SZ"); } if (WScript.Arguments(0) == 3) { WScript.Sleep(1000); var $_FavRenAdd_PathName = WshShell.RegRead ("HKCU\\Software\\KMELEON\\FavRenAdd\\URLname") ; var $_FavRenAdd_CurURL = WshShell.RegRead ("HKCU\\Software\\KMELEON\\FavRenAdd\\URLdisc") ; var oShellLink = WshShell.CreateShortcut($_FavRenAdd_PathName); oShellLink.TargetPath = $_FavRenAdd_CurURL; oShellLink.Save(); WshShell.RegDelete ("HKCU\\Software\\KMELEON\\FavRenAdd\\URLname") ; WshShell.RegDelete ("HKCU\\Software\\KMELEON\\FavRenAdd\\URLdisc") ; } } else { objArgs = WScript.Arguments ; WScript.Echo(WScript.Arguments.Count()); for (i=0; i<objArgs.length; i++) { WScript.Echo(objArgs(i)) } }