keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
Post Reply
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@dondo

Okay. I tested the autoconfig files with Firefox Portable Legacy 78. It works for me.

* C:\FirefoxPortableLegacy78\App\Firefox\defaults\pref\autoconfig.js
* C:\FirefoxPortableLegacy78\App\Firefox\mozilla.cfg
* C:\FirefoxPortableLegacy78\Data\profile\chrome\ToggleBookmarksToolbarFirefoxShortcut.uc.js

Remember to delete the config-prefs.js and config.js files.

Check if the ToggleBookmarksToolbarFirefoxShortcut.uc.js file is really in the chrome folder in the correct profile folder.

Menu Bar > Help > Troubleshooting Information > Update Folder > Open Folder
Menu Bar > Help > Troubleshooting Information > Profile Folder > Open Folder (click here)

Check if the mozilla.cfg file is in the installation folder.

Installation folder
http://kb.mozillazine.org/Installation_directory

You may need a short delay before running the script. Try this:

* <profile directory>\chrome\ToggleBookmarksToolbarFirefoxShortcut.uc.js

Code: Select all

(function () {
  if (location != "chrome://browser/content/browser.xul" &&
      location != "chrome://browser/content/browser.xhtml") return;

  // Ctrl+Shift+B toggles the bookmarks toolbar

  setTimeout(function () {
    var key = document.getElementById("manBookmarkKb");
    key.setAttribute("oncommand", "BookmarkingUI.toggleBookmarksToolbar('bookmark-tools');");
    key.removeAttribute("command");
  }, 1000);
})();
note: 1000 for a 1 second delay

Also, test the script using the browser console.

Instructions:

* open about:config page
* set devtools.chrome.enabled preference to true
* open browser console i.e. tools > web developer > browser console
* copy and paste code into browser console command line
* press enter to run
bege
Posts: 153
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Re: keyconfig 20110522

Post by bege »

This script (not in tbkeys but as a script imported in userChrome.js) worked for a long time to toggle the spell checker in the compose window.
In TB 91 it does not work any more. It just does nothing, the error console shows nothing and when I run the command in the console it just says "undefined".
What do I need to change (maybe as tbkeys entry)?

Code: Select all

(function () {

  if (location == "chrome://messenger/content/messengercompose/messengercompose.xhtml") {
    setTimeout(function () {
      try {

        var keyset = document.getElementById("tasksKeys");

        // bind 
        var key3 = document.createXULElement("key");
        key3.setAttribute("id", "key_dict_toggle");
        key3.setAttribute("key", "y");
		  key3.setAttribute('modifiers', 'alt');
        key3.setAttribute("oncommand", '(' + onCommand.toString() + ')()');
        keyset.appendChild(key3);

      } catch (e) {
        Components.utils.reportError(e);
      };
    }, 5000);
  }

function onCommand() {
      var lang = document.documentElement.getAttribute("lang");
      if (lang == "en-US") {
        ComposeChangeLanguage("de-DE");
      } else if (lang == "de-DE") {
        ComposeChangeLanguage("en-US");
      };
};
})();
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@bege

I got the `toggle between two languages` function in the other post to work correctly using the developer toolbox console in Thunderbird 91.

Can you run a simple alert using the userChrome.js script?

Code: Select all

- key3.setAttribute("oncommand", '(' + onCommand.toString() + ')()');
+ key3.setAttribute("oncommand", "alert('test')");
Do the other key tweaks, e.g. key1 and key2, work correctly using the userChrome.js script?

Try the following code using the tbkeys addon.

Code: Select all

(function () {
  var lang = window.document.documentElement.getAttribute("lang");
  if (lang == "en-US") {
    window.ComposeChangeLanguage("de-DE");
  } else if (lang == "de-DE") {
    window.ComposeChangeLanguage("en-US");
  }
})();
Troubleshooting for tbkeys: http://forums.mozillazine.org/viewtopic ... #p14872763
Last edited by morat on November 7th, 2021, 6:14 am, edited 1 time in total.
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@bege

I got a simple alert working in Thunderbird 91.

Code: Select all

/* Thunderbird userChrome.js */

// Thunderbird 68 uses .xul pages.
// Thunderbird 78 uses .xhtml pages.
// Thunderbird 91 uses .xhtml pages.

(function () {
  if (location == "chrome://messenger/content/messengercompose/messengercompose.xul" ||
      location == "chrome://messenger/content/messengercompose/messengercompose.xhtml") {
    try {
      var keyset = document.getElementById("tasksKeys");
      var key = document.createXULElement("key");
      key.setAttribute("id", "__unique_identifier_example");
   // key.setAttribute("key", "A"); // A
   // key.setAttribute("modifiers", "control,shift"); // Ctrl+Shift
   // key.setAttribute("modifiers", "alt"); // Alt
      key.setAttribute("keycode", "VK_F2"); // F2
   // key.setAttribute("command", "cmd_print");
      key.setAttribute("oncommand", "alert('test')");
      keyset.appendChild(key);
    } catch (e) {
      Components.utils.reportError(e); // [check] Show Content Messages
    }
  }
})();
userChromeJS by jikamens (compatible with TB 68 and TB 78 and TB 91)
http://addons.thunderbird.net/thunderbird/addon/986610

Instructions:

* install userChromeJS extension
* close email client
* create or edit the userChrome.js file in chrome folder
* open email client
bege
Posts: 153
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Re: keyconfig 20110522

Post by bege »

morat wrote:@bege

I got the `toggle between two languages` function in the other post to work correctly using the developer toolbox console in Thunderbird 91.

Can you run a simple alert using the userChrome.js script?

Code: Select all

- key3.setAttribute("oncommand", '(' + onCommand.toString() + ')()');
+ key3.setAttribute("oncommand", "alert('test')");
Do the other key tweaks, e.g. key1 and key2, work correctly using the userChrome.js script?

Try the following code using the tbkeys addon.

Code: Select all

(function () {
  var lang = window.document.documentElement.getAttribute("lang");
  if (lang == "en-US") {
    window.ComposeChangeLanguage("de-DE");
  } else if (lang == "de-DE") {
    window.ComposeChangeLanguage("en-US");
  }
})();
Troubleshooting for tbkeys: http://forums.mozillazine.org/viewtopic ... #p14872763
Thank you very much @morat.

Other scripts, also a key binding script, work.
Maybe something has changed in the key sets of TB 91 for the compose window.
The code you suggested works with tbkeys in the compose window section with slight changes (quotation marks and line breaks): =D>

Code: Select all

"alt+y": "(function () { var lang = window.document.documentElement.getAttribute('lang'); if (lang == 'en-US') { window.ComposeChangeLanguage('de-DE'); } else if (lang == 'de-DE') { window.ComposeChangeLanguage('en-US'); }})();"
bege
Posts: 153
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Re: keyconfig 20110522

Post by bege »

I found this code in the add-on "Phoenity Buttons" to open the settings of TB and adapted it for tbkeys:

Code: Select all

"alt+x": "(function () {window.openDialog('chrome://global/content/aboutconfig/aboutconfig.html','','width=1300,height=700');})();"
What must I change to have it not open a new window but a tab in TB as the normal TB command does?

And why is the path different from the one in omni.ja? There it is

Code: Select all

 \chrome\toolkit\content\global\aboutconfig\aboutconfig.html
- the sequence of the folders content and global is twisted, nevertheless the above code works.


Edit:
Ah, I got it with the help of the German speaking Thunderbird forum:

Code: Select all

"alt+x": "(function () {var tabmail = window.document.getElementById('tabmail'); tabmail.openTab('contentTab', { url: 'about:config' });})();"
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@bege

There is likely a conflict between the userChrome.js key element shortcut and an event listener shortcut. It's difficult to unbind an event listener shortcut so it's best to use the tbkeys addon.

...

I normally figure out the chrome url or about url using the source.

omni.ja path -> chrome/toolkit/content/global/certviewer/certviewer.html
chrome url -> chrome://global/content/certviewer/certviewer.html
about url -> about:certificate

Reference
http://searchfox.org/comm-esr91/search? ... iewer.html
http://searchfox.org/mozilla-esr91/sear ... iewer.html (see nsAboutRedirector.cpp file)

I use the following addon to test urls.

BrowseInTab
http://addons.thunderbird.net/thunderbird/addon/987779

I use the following addon to open the config editor.

Config Button
http://addons.thunderbird.net/thunderbird/addon/987784
bege
Posts: 153
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Re: keyconfig 20110522

Post by bege »

morat wrote:@bege

I normally figure out the chrome url or about url using the source.

omni.ja path -> chrome/toolkit/content/global/certviewer/certviewer.html
chrome url -> chrome://global/content/certviewer/certviewer.html
about url -> about:certificate

Reference
http://searchfox.org/comm-esr91/search? ... iewer.html
http://searchfox.org/mozilla-esr91/sear ... iewer.html (see nsAboutRedirector.cpp file)

I use the following addon to test urls.

BrowseInTab
http://addons.thunderbird.net/thunderbird/addon/987779

I use the following addon to open the config editor.

Config Button
http://addons.thunderbird.net/thunderbird/addon/987784
@morat Thank you very much for these hints!
User avatar
Qwerky
Posts: 122
Joined: March 5th, 2005, 10:33 pm
Location: Adanac

Re: keyconfig 20110522

Post by Qwerky »

In Thunderbird 60 with keyconfig, the following code:

Code: Select all

gMaxMsgPane.toggleMaxMessagePane();
would collapse the thread pane and maximize the preview pane, or the reverse.

In Thunderbird 91 with tbkeys 2.2.0, this no longer works. What would be the new code to do this?

Edit: If I may add some more functions which worked with keyconfig, but not with tbkeys 2.2.0 (full):

Code: Select all

var threadTree           = GetThreadTree();                           
var threadTreeObj     = threadTree.treeBoxObject;                     
var pageCount           = threadTreeObj.getPageLength() - 1;          
var currentMsgIndex = threadTreeObj.view.selection.currentIndex;      
                                                                      
if ((currentMsgIndex - pageCount) < 0) { newCount = 0; }              
else { newCount = currentMsgIndex - pageCount; }                      
                                                                      
threadTreeObj.ensureRowIsVisible(newCount);                           
threadTreeObj.view.selection.select(newCount);                        
would cause the thread pane to page up,

Code: Select all

var threadTree           = GetThreadTree();                           
var threadTreeObj     = threadTree.treeBoxObject;                     
var pageCount           = threadTreeObj.getPageLength() - 1;          
var rowCount             = threadTree.view.rowCount - 1;              
var currentMsgIndex = threadTreeObj.view.selection.currentIndex;      
                                                                      
if ((currentMsgIndex + pageCount) > rowCount) { newCount = rowCount; }
else { newCount = currentMsgIndex + pageCount; }                      
                                                                      
threadTreeObj.ensureRowIsVisible(newCount);                           
threadTreeObj.view.selection.select(newCount);                        
would cause the thread pane to page down,

Code: Select all

var threadTree       = GetThreadTree();             
var threadTreeObj = threadTree.treeBoxObject;       
                                                    
threadTreeObj.ensureRowIsVisible(0);                
threadTreeObj.view.selection.select(0);             
would cause the thread pane to move to the top, and

Code: Select all

var threadTree       = GetThreadTree();             
var threadTreeObj = threadTree.treeBoxObject;       
var rowCount         = threadTree.view.rowCount - 1;
                                                    
threadTreeObj.ensureRowIsVisible(rowCount);         
threadTreeObj.view.selection.select(rowCount);      
would cause the thread pane to move to the bottom. These four codes worked when the focus was in the preview pane, as well as the thread pane.

With tbkeys, the error for each of these four is, "threadTreeObj is undefined".
Mr. Qwerky
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Qwerky

Is the first code snippet from an addon? I can't find the gMaxMsgPane object in the Thunderbird 60 source.

Reference
http://searchfox.org/comm-esr60/search?q=gMaxMsgPane
http://searchfox.org/comm-esr60/source/ ... ersion.txt

Most of the nsITreeBoxObject methods can now be accessed directly through the tree object.

nsITreeBoxObject changes
http://developer.thunderbird.net/add-on ... sitreeview
http://developer.thunderbird.net/?q=treeBoxObject

I got the page up code snippet working using the error console.

Code: Select all

(function () {
  var threadTree = window.GetThreadTree();
  var threadTreeObj = threadTree;
  var pageCount = threadTreeObj.getPageLength() - 1;
  var currentMsgIndex = threadTreeObj.view.selection.currentIndex;
  var newCount;
  if ((currentMsgIndex - pageCount) < 0) {
    newCount = 0;
  } else {
    newCount = currentMsgIndex - pageCount;
  }
  threadTreeObj.ensureRowIsVisible(newCount);
  threadTreeObj.view.selection.select(newCount);
})();
tbkeys info: http://forums.mozillazine.org/viewtopic ... #p14872763
User avatar
Qwerky
Posts: 122
Joined: March 5th, 2005, 10:33 pm
Location: Adanac

Re: keyconfig 20110522

Post by Qwerky »

<smacks forehead> The first snippet is from an add-on called, wait for it... "Maximize Message Pane". Duh! It come over from TB 60 and updated, and it is installed, but my assigned shortcut does not work (the default shortcut does work). Further, the add-on's options no longer seem to have any way to change the shortcut, as they did previously. So I'll need to pursue that with the add-on's author.

Your code for PageUp does work correctly when focus is in the thread pane. When focus is in the preview pane, it does cause the thread pane to page up, but it also causes the focus to shift from the preview pane to the thread pane, which is undesirable.
Mr. Qwerky
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Qwerty

I can change the "Maximize message pane" shortcut in the Addons Manager tab.

i.e. Tools > Addons and Themes > Extensions > Cogwheel > Manage Extension Shortcuts

Manage addons keyboard shortcuts
http://www.ghacks.net/2019/01/16/manage ... outaddons/

Here is how to click a browser action button using the extension id.

Maximize Message Pane extension id: {CC1FC7EB-79F7-4A28-B12C-731304F16E53}

Code: Select all

(function () {
  function getWidgetId(id) {
    id = id.toLowerCase();
    id = id.replace(/[^a-z0-9_-]/g, '_');
    return id + '-browserAction-toolbarbutton';
  }
  var extensionId = '{CC1FC7EB-79F7-4A28-B12C-731304F16E53}';
  var widgetId = getWidgetId(extensionId);
  var button = window.document.getElementById(widgetId);
  button.click();
})();
I don't think it's possible to call the toggle command directly.

Maximize Message Pane
http://addons.thunderbird.net/thunderbird/addon/1392

The page up code snippet is obviously for the thread pane, not the message pane.

Try this:

Code: Select all

(function () {
  var focusedElement = window.gFolderDisplay.focusedPane;
  if (focusedElement == window.GetThreadTree()) {
    var threadTree = window.GetThreadTree();
    var threadTreeObj = threadTree;
    var pageCount = threadTreeObj.getPageLength() - 1;
    var currentMsgIndex = threadTreeObj.view.selection.currentIndex;
    var newCount;
    if ((currentMsgIndex - pageCount) < 0) {
      newCount = 0;
    } else {
      newCount = currentMsgIndex - pageCount;
    }
    threadTreeObj.ensureRowIsVisible(newCount);
    threadTreeObj.view.selection.select(newCount);
  } else if (focusedElement == window.GetMessagePane()) {
    window.goDoCommand('cmd_scrollPageUp');
  }
})();
Last edited by morat on April 1st, 2022, 12:50 pm, edited 2 times in total.
User avatar
Qwerky
Posts: 122
Joined: March 5th, 2005, 10:33 pm
Location: Adanac

Re: keyconfig 20110522

Post by Qwerky »

@morat

Hmm... the Manage Extension Shortcuts does indeed allow some changes, but it requires either Control or Alt for alphabetic keys; my desired shortcut is Shift-Z, which it does not allow.

I'm not entirely clear on what the button code above is supposed to do? I assigned that code to a key, but pressing that key does nothing. I ran the code in the Error Console, and the message was: "button is null".

As to the other codes, I wasn't clear enough. What is desired, and what the original codes did, was to operate on the thread pane (top, bottom, page up, page down, etc.) while the message page is focused. This allows to navigate the thread pane while remaining in the message pane. I have working codes for Up and Down (in the thread pane) which operate while the message pane is focused, so that one can move to previous/next message without repeatedly changing focus.
Mr. Qwerky
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Qwerty

Is the button on the toolbar? Check the extension id. I assume it's the same for all users.
User avatar
Qwerky
Posts: 122
Joined: March 5th, 2005, 10:33 pm
Location: Adanac

Re: keyconfig 20110522

Post by Qwerky »

@morat

What that latest code is doing, is to page up the thread pane, when the thread pane is in focus, and to page up the message pane, when the message pane is in focus. That's the same thing the the PageUp key does by itself (without any additional code).

What is desired is that a new shortcut (Alt+PageUp) will cause the thread pane to page up, regardless of whether the focus is in the thread pane or the message pane; and, that the focus will remain in whichever pane it was.
Mr. Qwerky
Post Reply