General :  K-Meleon Forum
General discussion about K-Meleon. 
Cookie-button with right-click options?
Posted by: siria
Date: September 14, 2009 05:26AM

am struggling endlessly with customization and thought I'd give up at last and ask ;-) A couple questions, first about cookies:

Is it possible to add some right-click options to the Toggle-Cookie-Button in the privacy bar, and if so, how??
- "View cookies" (Tools/Privacy/View data/View cookies)
- "Exceptions" (Tools/Privacy/Permissions/Cookies)
- "Cookie Culler" (=macro)
- "Preferences" (F2 / Privacy&Security)
- "Clear all cookies" (privacy(ClearCookies)
(- nice-to-have: allow/protect/block cookies from this site, regardless button state)

At the moment the button looks like this:
Block Cookies

Btw, am I guessing right, that when cookies are blocked in the privacy bar, all the other cookie settings are ignored except if this page is allowed in the privacy-permissions...? And if they are not blocked in the privacy bar, but the F2-settings say "originating website only", the latter has priority?

Would it also find useful for the other buttons on the privacy bar, to find permission-settings by right-click, but thats probably getting a bit too much then ;-)

Options: ReplyQuote
Re: Cookie-button with right-click options?
Posted by: desga2
Date: September 14, 2009 06:38PM

Isn't difficult only need read Documentation and some test:
macros(pref_ToggleCookies) | RightClickMenuName
Block Cookies

Also you must create the RightClickMenu in some macro or in Edit -> Configuration -> Menus.

K-Meleon in Spanish

Options: ReplyQuote
Attach custom menus to privacy bar
Posted by: Doon
Date: October 22, 2009 10:18AM

Siria, your knowledge may have already surpassed what I'm about to say, but I've written the following to help (and answer) you and others, as well as to document my own progress and put desga2's suggestions into action. Your question is one I asked myself, which is how I got here, and I've learned how to do some of what you desired to do.

To add new context menus two things must be done, a menu must be invoked in the toolbars.cfg just as desga2 has shown, and the menus themselves must be defined in the menus.cfg.

Menu reference:

Creating new menus:

I began defining my own menus by clicking Edit -- Configuration -- Menus in the K-Meleon menu, which opened a text file I could edit called "menus.cfg". Note: if one doesn't open up when you do the same you'll need to make a copy of the one in the "K-Meleon\defaults\profile" folder and place it in your active user folder, then it will open on command.

Apparently K-Meleon will process the main menus.cfg in the "K-Meleon\defaults\settings" folder and then process any additional menus defined in the customized menus.cfg in the active profile folder, with the customized menus replacing the default ones if they have the same names.

I added the following entries to the empty menus.cfg, to create three separate menus I could point to at will:


	Cookie Permissions=ID_COOKIE_PERM

	View Cache=macros(moz_AboutCache)

- The first menu, named DoonCookieLookie, defines a context menu item called "View Cookies", and when it is clicked on the cookie viewer will open. The "=" sign points to the command "ID_COOKIES_VIEWER", which is a standard "Command ID" you can find listed in the wiki documentation. I attached this menu to the delete cookies button on my privacy bar.

- The second menu, named DoonCookieTasting, defines a context menu item called "Cookie Permissions", and when it is clicked the cookie permissions dialog will pop up. The command itself is defined just like the first menu. I attached this menu to the toggle cookies button on my privacy bar.

- The third menu, named DoonCachePeek, defines a context menu item called "View Cache", and when it is clicked it will display the cache as if you had typed "about:cache" in the url bar. I attached this menu to the toggle images button on my privacy bar.

The command in this third menu invokes a default, pre-defined macro. Following the "=" sign you see "macros(moz_AboutCache)". The word "macros" there tells K-Meleon the command to issue is a macro, and the "(moz_AboutCache)" defines the macro to be invoked.

This whole macro invoking command line was quite an adventure for me. I didn't have any notes or examples to follow, I just studied the menus and macros until I could figure out what might open the cache. I must have tried 20 commands until I got that one to work, many of them were just guesses and stuff pasted in from the macro file.

In the process I learned a lot and now understand the basic structure of macro files (similar to menus in many respects), even though I have no clue how to program one, and most of it's contents is noise to me. On that note, the menus themselves (menus.cfg) were just a bunch of noise a few days ago, but over time the structure and meaning of it all sank into my brain, thanks to hours of staring at them, tracing the relationships, and also thanks to the help files provided, which finally made sense of it all. Without studying the structures themselves the help files weren't helpful to me. I say this to encourage others who may be bewildered by it all, like many things, if you can break things down into small pieces it's not so difficult, just as desga2 said. I'm writing this posting immediately after learning what I've learned in order to help other newbies like myself.

Also, for the sake of an example: I could have compiled those three commands, along with others, into single custom menu, like this:

	Cookie Permissions=ID_COOKIE_PERM
	View Cache=macros(moz_AboutCache)

Attaching menus to toolbar buttons:

Connecting menus to privacy bar buttons. Menus are always referred to by name, and will be found and used if they are in a menus.cfg (they can also be in a macro.kmm, like the one named "Reloa&ding" in main.kmm, but I don't know how they work).

In my case I edited toolbars.cfg and changed this:

	Block Images. Press F9 to toggle.

to this: (note the addition to the second line)

	Block Images. Press F9 to toggle.

Adding the "|" sign followed by a menu name, after the command, will add a right-click context menu to the toolbar button.

I added the "|MenuName" to the Cookies and Clear Cookies buttons too, as in
"macros(pref_ToggleCookies)|DoonCookieTasting" and

End of story.

Here's an additional tweak. Taking a cue from others, in toolbars.cfg I added a "|&Privacy" to the Stop button, to add the whole privacy menu (from the tools menu) as a right-click context menu, which is a very handy and logical place for many of the commands.

	Stop loading this page

Lastly, just for fun, here is a picture of my customized Klassic skin privacy bar:

That is an animated gif showing the different states, if you have animations disabled you won't be seeing much of anything. It's a quick hack job that was intended to shorten the buttons, and the buttons shown are the only ones I'm interested in at this time. It's not much to look at but I'm amused by the image squasher. :-)

I must say that I love the privacy bar and use the image and javascript toggles constantly, that toolbar it's easily one of the biggest reasons K-Meleon is so appealing to me!

Edited 5 time(s). Last edit at 10/23/2009 01:28PM by Doon.

Options: ReplyQuote
Re: Attach custom menus to privacy bar
Posted by: siria
Date: October 22, 2009 12:34PM

You're definitely on the same path as me grinning smiley Yeah, most of the stuff I've meanwhile figured out too, and especially my toolbar.cfg is meanwhile full with right- and left-click menus, and additional buttons for macros, and additional toolbars for extra stuff. Wanted long-since to get it cleaned up and ready to post as skin, but alas am so slow with everything, and instead of getting that chaos cleaned up, I keep playing around with yet more new macros and oh-so-necessary buttons ;-) Hopefully soon....

But one thing I haven't really dealt with yet, and that is the menus.cfg. Am surprised that it sounds rather easy (but then, not really surprised, after all it's KM), and since I'll introduce a macro anyway with the skin (have given in at last), can just as well add those menus to my skin.

You described this very well and easy to understand, great! :-)

Options: ReplyQuote
making custom menus
Posted by: Doon
Date: October 22, 2009 03:07PM

:-) Buttons and buttons, I saw your Hotlinks toolbar posting, where you offered some ready to use button graphics and code. Being that hotlinks and typed urls are the only 'bookmarks' I've used so far (it's only been a few days) it was interesting to me, and I will probably use it in the future.

As for menus, I was greatly impressed with the ability to customize all menus, and it was fairly easy to get into. Before realizing that I should not do so, I had begun making all kinds of changes to the 'default' menus.cfg, but I now know differently. Allow me to explain the basics as I understand it.

When K-Meleon is extracted from it's .7z archive two "menus.cfg" files can be found in the following two folders:


The one in the defaults\settings folder contains all of the default menu data.
The one in the defaults\profile folder is empty.

If a copy of the empty one hasn't already been placed in your active profile folder, when you click Edit -- Configuration -- Menus in the main K-Meleon menu you will get an error message saying "The file menus.cfg could not be found." But if it's there it will be opened and ready for editing.

The empty menus.cfg contains only the following text:

# K-Meleon Menus (

# Syntax:
# <menuname>{
# <label>=<command>
# !<submenunameINLINE>
# :<submenunamePOPUP>
# }
# - Lines beginning with '#' are ignored (comments)
# - Menus must be defined BEFORE being used as submenus

# Note: The purpose of this file is to host your personal menu definitions.
# Using the syntax described above, you can completely redefine the
# default menus which are defined in defaults\settings\menus.cfg in
# your K-Meleon installation directory. Using an extended syntax, you
# can even add menus and commands to the default menus and remove
# items from them whithout to miss future updates of the defaults.
# For this extended syntax, please refer to our wiki.

To use this menus.cfg you can add new custom menus like I described earlier (DoonCachePeek, etc) or you can copy sections out of the main menus.cfg and paste them into this empty one, then edit them at will.

I spoke about menus having names earlier. Well, when you copy named menus out of the main menus.cfg and then edit their contents (in your custom menus.cfg), your custom ones will replace the default ones based on the name when the menus are loaded by K-Meleon at startup. So, you can edit the menu commands but you don't change the menu name.

Here is an example of a menu I changed, this code contains a part of the context menu you get when you right-click on a webpage background.

This is the default code seen in the "K-Meleon\defaults\settings\menus.cfg":

	# ----- Document Elements

	Add Page To &Bookmarks=bookmarks(Add)
	Add Page To F&avorites=favorites(Add)
	Add Page To H&otlist=hotlist(Add)
	&Save Page As...=ID_FILE_SAVE_AS

I included the whole section header for 'context', what you see are three different named menus, in each case the name preceeds the "{" bracket, they are "DocumentOpenExternal", "DocumentSave" and "Document". The "Document" one near the bottom is the context menu I'm concerned with. What I did was paste that "Document" menu into MY menus.cfg and then edit it to look like this:


If you study the code, you will see that I first stripped the "!Nav" reference out. The "!Nav" points to a sub-menu defined elsewhere (included below for reference), the entire contents of which I did not want. The preceeding exclamation point, by the way, makes the referenced sub-menu display 'inline', seeming to be an integral part of the "Document" menu.

Anyway, I junked the "!Nav" and only used the parts of it that I wanted, which were the simple commands "back, forward, stop and reload". I then added two more commands that I wanted (again, these Command IDs are listed in the wiki documentation), Select All and Find (Select All should be obvious, and Find brings up the find box you'd get if you pressed Ctrl-F).

This "Documents" menu is only the first portion of the whole context menu seen when right-clicking on a page, but it's now slightly smaller and much more to my liking. The whole context menu is actually "DocumentPopup", which calls on "Document" for the first portion.

To hearken back to what I wrote earlier, if I wanted to make my custom made three command "DoonContextMenu" a part of the "Document" context menu, I could reference it by adding a "!DoonContextMenu" line.

This is the "!Nav" menu code:

	# ----- View


Edited 2 time(s). Last edit at 10/23/2009 01:31PM by Doon.

Options: ReplyQuote
Re: making custom menus
Posted by: siria
Date: October 23, 2009 01:25AM

WHOOSH.... You're flying by at hyperspeed, LOL!! grinning smiley
Sorry can't follow that fast, and currently have my head stuffed with other skin-and-macro-related details, but will sure keep this thread in mind for later studying in more detail smiling smiley

The privbar is also one of my TOP important reasons to love KM, although I recently read here that FFox has it too (named prefbar there). Never mind tongue sticking out smiley And yes, your block-images-icon is hilarious, LOL! grinning smiley

Options: ReplyQuote
Re: making custom menus
Posted by: Doon
Date: October 23, 2009 02:19AM

will sure keep this thread in mind for later studying in more detail smiling smiley

That was the idea. :-) I sometimes like to record things in this manner while it's fresh in my mind, to share with others who are learning and to have something to refer back to later if necessary. I knew my words would (ultimately) not go to waste with users like you around, and once my hyperdrives shut down (lol) you probably won't see me posting anymore. Have fun!

Options: ReplyQuote
custom macros and hotkeys
Posted by: Doon
Date: October 23, 2009 01:51PM

Drifting off topic a bit and speaking generally... Some folks experience a screen lockup/freezing condition caused by certain websites, as described on page three of the sticky Crash Report thread in the bugs forum. I've created an UnFreeze workaround for that issue by making a simple macro and setting some hotkeys to trigger it. Please allow me to present an explanation of how to perform such a task.

Making a simple macro.

I created a plain text file with the following macro definition in it, which I then saved as "UnFreeze.kmm" and placed in the K-Meleon Macros folder.


Macro complete. "UnFreeze" names the macro and the curly brackets surround the command used by the macro when it's invoked. The command used here is the very simple "exec", which will execute a command line. Inside the quotes you see the command line, which contains a 'path' to a batch file I placed in an UnFreeze folder in the Tools folder. In this case I didn't have to use any drive/folder/file path preceeding the word 'tools' because K-Meleon sees itself as the 'root' folder.

Using this macro as an example, anyone could create their own custom macro that is able to execute any external program. In my case I linked to a batch file called "UnFreeze.bat" (which launches a series of commands), but I could just as well have linked to any exe with a full path such as "C:\\Windows\\Notepad.exe". This kind of easily created, simple macro can be attached to any menu or toolbar (as described earlier), or some custom hotkeys/accelerators can be assigned to it.

This is what a Notepad launching macro might look like:


You could link to any executable of course, just imagine any program you might launch while browsing the web. You can put a bunch of these macros in a single .kmm file and just call them by name as you need them.

Creating your own accelerator hotkeys.

If you click Edit -- Configuration -- Accelerators in the K-Meleon menu a text file called "accel.cfg" should open up, which you can edit. If one doesn't open up you'll need to make a copy of the one in the "K-Meleon\defaults\profile" folder and place it in your active user folder, then it will open on command.

This "accel.cfg" is a version of the accelerator keys configuration file that you can add to without messing up the primary one that lives in the "K-Meleon\defaults\settings" folder.

On each line you can define some keys to launch a command. These lines are composed in three parts: the key or keys to be used, followed by an equals sign, followed by the name of a pre-defined Command ID or macro. See the "accel.cfg" in the "K-Meleon\defaults\settings" folder for examples.

You could add a simple line like this and then save the file:

CTRL ALT N = macros(Notepad)

Then, when the key combo Ctrl-Alt-N is pressed, Notepad will be launched, thanks to the macro described a moment ago.

Here's one using a Command ID:


In this case the key combo Ctrl-Alt-O will toggle the Work Offline mode.

I'm making three-key combos using Ctrl and Alt because they're easy to remember and I've found there are not many already in use in the main accel.cfg. You must always check if an existing definition is already in use before making it your own, because you will override an existing one if you use the same keys (which is in fact a way of redefining all shorcut keys to your liking of course).

That's all there is to it.

Now back to my UnFreeze macro solution. The macro shown up above was linked to a batch file (a plain text file) that contains command lines for a 3rd party utilty called "QRes". QRes is a tiny, freeware command line utility that can instantly change the screen resolution, color depth and refresh rate, available at:

As it turns out, simply changing the screen resolution or bit depth will clear up the effect of the frozen screen, so I use QRes to do so.

Set up for my use, this is what "UnFreeze.bat" contains:

	@echo off
	qres.exe /c:16
	qres.exe /c:32

Since I run my screen in 32-bit color mode I use QRes to quickly change it to 16-bit and then back to 32-bit. Someone who normally runs 16-bit should do exactly the opposite. If a person doesn't want to toggle the bit depth a screen resolution change can be just as quick, changing to a different resolution and back again with command lines like "qres.exe /x:800 /y:600" and "qres.exe /x:1024 /y:768". The changes are virtually instantaneous even on my PC (Windows 98, PII 450, 128mb RAM).

To set everything up I placed "UnFreeze.kmm" in the K-Meleon Macros folder, I created a folder called "Tools" in the K-Meleon folder (commonly used by extensions), I then created a folder called "UnFreeze" inside the tools folder. I placed "QRES.EXE" and "UnFreeze.bat" in the UnFreeze folder, then right-clicked Unfreeze.bat and selected Properties, then set the program's 'working' folder to match it's actual location ("X:\K-Meleon\Tools\Unfreeze").

To invoke the UnFreeze macro I assign it the key combination Ctrl-Alt-F, with the F standing for 'freeze' or 'fix' in my mind.

CTRL ALT F = macros(UnFreeze)

Now when a website fatally freezes my screen, I press Ctrl-Alt-F to instantly fix it and make it fully functional again, then continue on my way.

Someone with macro writing skills could surely make all of this work in a much more clever, professional and self contained manner, but my hack does the trick. Cheers.

Edited 1 time(s). Last edit at 10/24/2009 06:01PM by Doon.

Options: ReplyQuote

K-Meleon forum is powered by Phorum.