K-Meleon

KMeleonWiki > Resources > MacroLibrary > KmmPageTimer

Submitted by: JamesD



Notes:

Allows the user to set a timer for a page. Timers can be set on multiple tabs concurrently. The macro anticipates that the page/tab will not change title. May be run from quick keys ALT + p.


Updates:

2008-11-05
Fixed error when prompt is cancelled.



Open your User Macro Folder (Edit > Configuration > User-Defined Macros) or your Macro Folder (Edit > Configuration > Macros) and create the following text file(s):

PageTimer.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- PageTimer.kmm
# ---------- K-Meleon Macro Language Page timer/reminder ---------------
# ---------- set a number of minutes to wait for a reminder
# ---------- anticipates that the page/tab will not change title
#
# Dependencies        : main.kmm, Windows Scripting Host
# Resources           : -
# Preferences         : -
# Version             :  1.1   2008-11-05
# --------------------------------------------------------------------------------
#

PageTimer_RunCode{
        $_PageTimer_CurrentPage = $TITLE ;
        $_PageTimer_Minutes = prompt( "Enter number of minutes", "Set timer value" );
        $_PageTimer_Milliseconds = $_PageTimer_Minutes * ( 60 * 1000 ) ;
        $_PageTimer_Minutes > 0 ? exec("wscript.exe \"".$_PageTimer_Path."\" \"".$_PageTimer_CurrentPage."\" \"".$_PageTimer_Milliseconds."\"") : 0 ;
        }

_PageTimer_BuildMenu{
        # add another option to Tools menu 
        setmenu("&Tools",macro,"PageTimer",PageTimer_RunCode,misc);
        }

_PageTimer_SetAccels{
setaccel("ALT p", "macros(PageTimer_RunCode)");
        }

_PageTimer_GetPath{
        ### PageTimer.js is supposed to be located in the same folder as PageTimer.kmm (this file).
        ### If it isn't, Windows Script Host will notify the user.
        ### Double underscore makes variable local only.
        $__Data=readfile(getfolder(MacroFolder)."\\PageTimer.kmm");
        $_PageTimer_Path=getfolder($__Data==""?UserMacroFolder:MacroFolder)."\\PageTimer.js";
        }

$OnStartup=$OnStartup."_PageTimer_GetPath;";
$OnInit=$OnInit."_PageTimer_SetAccels;";
$OnInit=$OnInit."_PageTimer_BuildMenu;";
$macroModules=$macroModules."PageTimer;";


PageTimer.js

/* PageTimer.js by JamesD, version  1.0  2008-10-28

   This script is a helper application for the K-Meleon Macro Module PageTimer.kmm that
   enables you to set a timer/reminder for a page.

   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 PageTimer_CurrentPage  = WScript.Arguments(0);
        var PageTimer_Milliseconds  = WScript.Arguments(1);
        WScript.Sleep( PageTimer_Milliseconds) ;
        var d = new Date();
        WScript.Echo("Timer expired on page \n\n " + PageTimer_CurrentPage + "\n\n " + d) ;
}
else
{
objArgs = WScript.Arguments ;
WScript.Echo(WScript.Arguments.Count());
for (i=0; i<objArgs.length; i++)
        {
            WScript.Echo(objArgs(i))
        }
}        


Comments & Questions

K-Meleon

(c) 2000-2010 kmeleonbrowser.org. All rights reserved.
design by splif.