K-Meleon
KMeleonWiki > Resources > MacroLibrary > KmmChmView
Submitted by: JamesD
Notes:
ChmView.kmm can be used to decode compressed help files and view them in K-Meleon. This is especially helpfull to users who have removed Microsoft Internet Explorer from their computer.
You will need to obtain the chmdecoder.exe file. That is free and located at http://www.freedownloadscenter.com/Web_Authoring/HTML_Text_Styling_Tools/CHM_Decoder_Download.html
To use the ChmView macro, you should create a folder in your macro or usermacro folder and name it chmdecoder. Unzip the chmdecoder.exe file to that folder.
You will also need a place for the decoded chm files to be written as html. That place, I suggest you create a folder, must be where you have write authority.
Install the following ChmView.kmm file in either your macro or usermacro folder. It must be the same one which has the folder chmdecoder.
A menu item will be in the TOOLS menu.
Open your User Macro Folder (Edit > Configuration > User-Defined Macros) or your Macro Folder (Edit > Configuration > Macros) and create the following text file:
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- ChmView.kmm
# ---------- K-Meleon Macro Language to allow viewing of chm files in K-Meleon ---
# ---------- creates HTML files within usermacro\chmdecoder folder
#
# Dependencies : main.kmm KM version 1.5.x
# Resources : chmdecoder.exe
# - http://www.freedownloadscenter.com/Web_Authoring/HTML_Text_Styling_Tools/CHM_Decoder_Download.html
# Preferences : "k-meleon_chmview.general"
# Version : 0.2 2009-01-05
# Author : JamesD
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_ChmView_RunCode{
$_ChmView_DefaultOut = getpref(STRING, "k-meleon_chmview.general");
$_ChmView_CFolder = promptforfolder( "Select the folder where the chm file is located." );
if ($_ChmView_CFolder != "") {
$_ChmView_CHMPath = promptforfile($_ChmView_CFolder, "CHM files", "*.chm");
if ($_ChmView_CHMPath != "") {
$_ChmView_CHMbase = basename($_ChmView_CHMPath, ".chm");
$_ChmView_DefaultOut == "" ? &_ChmView_Default_Out1 : &_ChmView_Default_Out2 ;
if ($_ChmView_OFolder !="") {
exec($_ChmView_Path." -menu \"".$_ChmView_CHMPath."\" \"".$_ChmView_OFolder."\"");
alert("Wait until files are written before doing OK.", "Waiting for chmdecoder.exe to finish", EXCLAIM);
open($_ChmView_OFolder."\\".$_ChmView_CHMbase.".html");
}
}
}
}
_ChmView_Default_Out1{
$_ChmView_OFolder = promptforfolder( "Select/create a folder to contain decoded HTML files");
if ($_ChmView_OFolder != "" ) {
$_ChmView_Set = confirm($_ChmView_OFolder, "Make this the default output folder? ", YESNO , QUESTION );
$_ChmView_Set == "YES" ? setpref(STRING, "k-meleon_chmview.general", $_ChmView_OFolder) :0;
}
}
_ChmView_Default_Out2{
$_ChmView_Set = confirm($_ChmView_DefaultOut,"Use this folder for output?", YESNO , QUESTION );
$_ChmView_Set == "YES" ? $_ChmView_OFolder = $_ChmView_DefaultOut : &_ChmView_Default_Out1 ;
}
_ChmView_RunView{
$_ChmView_DefaultOut = getpref(STRING, "k-meleon_chmview.general");
$_ChmView_DefaultOut =="" ? &_ChmView_RunView1 : &_ChmView_RunView2 ;
}
_ChmView_RunView1{
$_ChmView_OFolder = promptforfolder( "Select the folder which contains the decoded HTML files.");
$_ChmView_CHMHtml = promptforfile($_ChmView_OFolder, "html files", "*.html");
open($_ChmView_CHMHtml);
}
_ChmView_RunView2{
$_ChmView_Use = confirm($_ChmView_DefaultOut, "Select from this folder? ", YESNO , QUESTION );
$_ChmView_Use == "YES" ? &_ChmView_RunView3 : &_ChmView_RunView1 ;
}
_ChmView_RunView3{
$_ChmView_CHMHtml = promptforfile($_ChmView_DefaultOut, "html files", "*.html");
#alert($_ChmView_CHMHtml, "The chosen html file [DEFAULT FOLDER] DEBUG", INFO);
open($_ChmView_CHMHtml);
}
_ChmView_BuildMenu{
$_ChmView_Popm = "CHM file viewer";
setmenu("&Tools",popup,$_ChmView_Popm,Misc);
setmenu($_ChmView_Popm, macro, "Decode / View a CHM file", _ChmView_RunCode,0);
setmenu($_ChmView_Popm, macro, "View a decoded CHM file", _ChmView_RunView,1);
}
_ChmView_GetPath{
### chmdecoder\chmdecoder.exe is supposed to be located in the same folder as ChmView.kmm (this file).
### If it isn't, Windows Script Host will notify the user.
### Double underscore makes variable local only.
$__Data=readfile(getfolder(MacroFolder)."\\ChmView.kmm");
$_ChmView_Path=getfolder($__Data==""?UserMacroFolder:MacroFolder)."\\chmdecoder\\chmdecoder.exe";
}
$OnStartup=$OnStartup."_ChmView_GetPath;";
$OnInit=$OnInit."_ChmView_BuildMenu;";
$macroModules=$macroModules."ChmView;";