Use this page to experiment with the wiki. (Just don't delete this text; otherwise people won't know the purpose of the page.)
Events
The Macro Extension Plugin provides a variety of events.
Event |
Is triggered |
OnActivateWindow |
When a window gets the focus. |
OnCloseGroup |
When a multi-layered window is closed. |
OnCloseTab |
When a tab is closed. |
OnCloseWindow |
When a window/layer is closed. |
OnInit |
When the Default Configuration Files have been parsed. |
OnLoad |
When a document has finished loading. |
OnLoadOnce |
When a document has finished loading.(1) |
OnOpenTab |
When a tab is opened. |
OnOpenWindow |
When a window/layer is opened. |
OnQuit |
When the macro plugin (the browser) is being closed. |
OnSetup |
When the User Configuration Files have been parsed. |
OnStartup |
When the first window is opened. |
OnWMAppExit |
When ID_APP_EXIT is called to terminate the application. |
Not all of these events are supported by all versions of K-Meleon.
(1) OnLoadOnce runs prior to OnLoad. The $OnLoadOnce variable is cleared after each OnLoadOnce event.
Event Handling
Whenever <event> is triggered, the Macro Extension Plugin will look for a macro named On<event> and execute it if found. The appropriate On<event> macros are provided by default.
To get your own code executed whenever <event> is triggered, simply add your code to the On<event> macro in your Macro Definition File (macros.cfg).
Since K-Meleon 1.1, the On<event> macros are located in the Main K-Meleon Macro Module (main.kmm). This module also provides global $On<event> variables which you should use in your own modules to get code executed whenever <event> is triggered:
myMacro{
# your On<event> code
}
$On<event>=$On<event>."myMacro;";
Since K-Meleon 1.1, the On<event> macros are executed in the context of the window that triggered the event. In previous versions, these macros were executed in the context of the currently active window (which is not necessarily the window that triggered the event).
Event Cascade
Startup is always followed by Load or OpenWindow.
OpenWindow is always followed by Load.
Init, Setup, and Quit are only fired once a session.(1)
ActivateWindow is usually fired multiple times when a browser window is focused.
Startup Order of Precedence
Init
Setup
Startup(1)
OpenWindow(2)
OpenTab(2)
LoadOnce
Load(2)(3)(4)
(1) When the browser is opening a group or folder at startup, the Load event is fired before Startup and Startup is fired multiple times (once for each opened layer).
(2) The use of sessions or groups may fire these events multiple times.
(3) The code on some websites may fire this event multiple times.
(4) LoadOnce runs before load.
Shutdown Order of Precedence
CloseGroup or WMAppExit(1)
CloseWindow(2)
Quit
(1) WMAppExit seems currently not to be fired at all.
(2) CloseWindow is fired for each closed layer.