K-Meleon's Macro Language offers the "exec" statement to execute external applications out of macros. But this statement is unable to execute command lines containing environment variables. Especially modern NT-based versions of the Windows OS offer a variety of usefull environment variables. These are normally used to address special directories independently of drive letters and/or (localized) directory names.
Following, I want to describe a workaround to use environment variables with K-Meleon's "Exec" macro command.
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 in the Download Section of Microsoft's Scripting Homepage.
Download EnvExec.js and place it in your profile directory
(e.g.
C:\Program Files\K-Meleon\Profiles\<profilename>\<random>.slt).
/* EnvExec.js by kko, version 1.0
This script is a helper application for K-Meleon's macros.cfg that enables you to run
command lines containing environment variables such as %WinDir%, %ProgramFiles%, etc.
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.length) {
var shl = WScript.CreateObject("WScript.Shell");
var arg = WScript.Arguments;
var tmp = "";
for (var j=0; j<arg.length; j++) {
tmp += (j) ? " " : "";
tmp += (arg(j).indexOf(" ") > -1) ? "\"" : "";
tmp += shl.ExpandEnvironmentStrings(arg(j));
tmp += (arg(j).indexOf(" ") > -1) ? "\"" : "";
}
shl.Run(tmp);
}
Select "Tools" > "Advanced Preferences" > "Macros..." to open K-Meleon's macro configuration file macros.cfg and apply the following changes:
# ----MISC. MACROS----
# You can now execute command lines containing Windows environment variables (kko)
#
# instead of : exec(<YourCommandline>);
# call : $EnvArgs=<YourCommandline>; &EnvExec;
#
$EnvArgs="";
EnvExec {
exec("wscript.exe \"".$path."EnvExec.js\" ".$EnvArgs);
}
# The file "EnvExec.js" must be located within Your profile directory (where this file resides) !
SetHome{
setpref(STRING,"kmeleon.general.homePage",$URL);
setpref(INT,$sg,0); setpref(BOOL,$sh,true); &Sync;
#$ie="\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"";
$ie="\"%ProgramFiles%\\Internet Explorer\\iexplore.exe\" ";
URLInIE{
$oldclip=getclipboard(); setclipboard();
id(ID_SELECT_URL); id(ID_EDIT_COPY); $theurl=getclipboard();
$theurl==""? $theurl=$URL:"";
&ResetURL; setclipboard($oldclip);
#exec($ie.$theurl);
$EnvArgs=$ie.$theurl; &EnvExec;
}
LinkInIE{
#exec($ie.$LINKURL);
$EnvArgs=$ie.$LinkURL; &EnvExec;
}