keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
Post Reply
dorando
Posts: 1203
Joined: January 9th, 2004, 9:57 am
Contact:

Re: keyconfig 20080929

Post by dorando »

mad.engineer wrote:I understand that keyconfig stores the user customization in pref.js file which begins with user_pref("keyconfig) code in it. If I were to do a fresh install of TB 3.x on a new Windows PC, rather than editing the pref.js file manually and update it with the keyconfig code from the previous install, is it safe to just copy the previous pref.js file over to the new TB install?. Would this work/restore the old Keyconfig settings over to the new setup?.
Copying the prefs.js over to the new profile will restore keyconfig settings along with settings used by other extensions or Thunderbird itself (which might have unintended side effects if the settings are not valid for the new setup).

ballyhairs wrote:How can I run the link on the clipboard using keyconfig?
Try

Code: Select all

loadURI(readFromClipboard()); 

nameanyone wrote:What would be the code to turn off spell checking? Not permanently, as in options, but temporarily, as in Right-click > uncheck "Check Spelling".
Try

Code: Select all

var editor = (commandDispatcher.focusedElement instanceof Components.interfaces.nsIDOMNSEditableElement) ?
commandDispatcher.focusedElement.editor : null;

if(
editor)
 editor.setSpellcheckUserOverride(false);  
or for a toggle

Code: Select all

var editor = (commandDispatcher.focusedElement instanceof Components.interfaces.nsIDOMNSEditableElement) ?
commandDispatcher.focusedElement.editor : null;

if(
editor)
 editor.setSpellcheckUserOverride(!editor.getInlineSpellChecker(true).enableRealTimeSpell);  
mad.engineer
Posts: 314
Joined: August 8th, 2006, 4:08 pm

Re: keyconfig 20080929

Post by mad.engineer »

Is it possible to make Keyconfig work with interactive commands in TB 3.0.1?. In my previous email client, the Reply/Reply All function was combined into one. The way this would work is when you press Reply and if the email had more than one addresses, it would prompt the user "Do you want to Reply All (Y/N)?". Y would do a Reply All whereas N would do just the individual Reply. I'm trying to see if somehow I can do the same using Keyconfig with TB. Any pointers appreciated. Thanks
dorando
Posts: 1203
Joined: January 9th, 2004, 9:57 am
Contact:

Re: keyconfig 20080929

Post by dorando »

Try

Code: Select all

if(!IsReplyAllEnabled()) {
 goDoCommand('cmd_reply');
 return;
}

var nsIPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.
getService(Components.interfaces.nsIPromptService);

var flags =
 nsIPromptService.BUTTON_POS_0 * nsIPromptService.BUTTON_TITLE_IS_STRING +
 nsIPromptService.BUTTON_POS_1 * nsIPromptService.BUTTON_TITLE_IS_STRING;

if(
nsIPromptService.confirmEx(null, "Reply", "Do you want to Reply All (Y/N)?", flags, "&Yes", "&No", null, null, {}) == 0)
 goDoCommand('cmd_replyall');
else
 goDoCommand('cmd_reply'); 
mad.engineer
Posts: 314
Joined: August 8th, 2006, 4:08 pm

Re: keyconfig 20080929

Post by mad.engineer »

Thank you very much. This is exactly what I was looking for !.
mad.engineer
Posts: 314
Joined: August 8th, 2006, 4:08 pm

Re: keyconfig 20080929

Post by mad.engineer »

Hi dorando, Thanks for the previous suggestion for the Reply/Reply All config. I would like to request an another one. I'm trying to make the "Send Now" command in TB interactive using Keyconfig, like what I had in my previous mail client. Currently I've setup "Send Now" to "Ctrl-S" key via Keyconfig. What I'm trying to do is such that when I press "Ctrl-S" in the Message Compose window to send, I'd get an interactive dialog "Do you want to send (Y/N)?". Pressing "Y" will send the message, whereas pressing "N" will cancel message sending. If you could suggest some code just like you did above, I'd really appreciate your help. Thanks
dorando
Posts: 1203
Joined: January 9th, 2004, 9:57 am
Contact:

Re: keyconfig 20080929

Post by dorando »

Try

Code: Select all

var nsIPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.
getService(Components.interfaces.nsIPromptService);

var flags =
 nsIPromptService.BUTTON_POS_0 * nsIPromptService.BUTTON_TITLE_IS_STRING +
 nsIPromptService.BUTTON_POS_1 * nsIPromptService.BUTTON_TITLE_IS_STRING;

if(
nsIPromptService.confirmEx(null, "Send Now", "Do you want to send (Y/N)?", flags, "&Yes", "&No", null, null, {}) == 0)
 goDoCommand("cmd_sendNow"); 
Ensure that you select the Compose window in the dropdown box before adding the shortcut (if the Compose window doesn't seem to appear in it, you might need to change its subject line).

Also note that if you have Tools > Options > Composition > General > Confirm when using keyboard shortcut to send message (mail.warn_on_send_accel_key) enabled, you get a similar confirmation dialog for the default Send Now shortcut ( goDoCommand('cmd_sendWithCheck') ).
mad.engineer
Posts: 314
Joined: August 8th, 2006, 4:08 pm

Re: keyconfig 20080929

Post by mad.engineer »

Hi dorando. Thank you very much. This is Perfect !.
mad.engineer
Posts: 314
Joined: August 8th, 2006, 4:08 pm

Re: keyconfig 20080929

Post by mad.engineer »

Hi dorando. Do you know if there is any way I can assign a shortcut Key to do the same as "File->Compact folders" in TB?. Currently I have a shortcut key assigned via Keconfig to Compact individual folders on a per folders basis only. This mean that I first select a Mail folder then press the key to compact it. Where as "File->Compact Folders" compacts all folders at once globally. Trying to figure out if I can assign a key to it via Keyconfig. Appreciate your help. Thanks
dorando
Posts: 1203
Joined: January 9th, 2004, 9:57 am
Contact:

Re: keyconfig 20080929

Post by dorando »

The code for File > Compact Folders is

Code: Select all

goDoCommand('cmd_compactFolder')  

cmd_compactFolder calls gFolderTreeController.compactAllFoldersForAccount(); which "Compacts [...] all folders for accounts of the currently selected folders" (the call to the non-existing _resetThreadPane will in most cases let it only work for the first selected).

To compact cross-accounts try

Code: Select all

var enumerator = accountManager.allFolders.enumerate();

while(
enumerator.hasMoreElements()) {
 var msgFolder = enumerator.getNext()
  if(msgFolder.canCompact)
   msgFolder.compact(null, msgWindow);
}
  
mad.engineer
Posts: 314
Joined: August 8th, 2006, 4:08 pm

Re: keyconfig 20080929

Post by mad.engineer »

Thank you dorando. It works great!. Appreciate your help again.
nameanyone
Posts: 22
Joined: February 14th, 2007, 10:54 am

Re: keyconfig 20080929

Post by nameanyone »

Thanks, dorando. The code to toggle Spell Checking works, but only in plain text controls. Is there an equivalent for rich text elements? For example, GMail "Compose Mail" in it's default "Rich formatting" mode.
dorando
Posts: 1203
Joined: January 9th, 2004, 9:57 am
Contact:

Re: keyconfig 20080929

Post by dorando »

Try

Code: Select all

var editor = (commandDispatcher.focusedElement instanceof Components.interfaces.nsIDOMNSEditableElement) ?
commandDispatcher.focusedElement.editor : null;

if(!
editor && commandDispatcher.focusedWindow.document.designMode == "on") {
 var editingSession = commandDispatcher.focusedWindow
.QueryInterface(Ci.nsIInterfaceRequestor)
.
getInterface(Ci.nsIWebNavigation)
.
QueryInterface(Ci.nsIInterfaceRequestor)
.
getInterface(Ci.nsIEditingSession);

 editor = editingSession.getEditorForWindow(commandDispatcher.focusedWindow)
}

if(
editor)
 editor.setSpellcheckUserOverride(!editor.getInlineSpellChecker(true).enableRealTimeSpell); 
mad.engineer
Posts: 314
Joined: August 8th, 2006, 4:08 pm

Re: keyconfig 20080929

Post by mad.engineer »

Hi dorando, Do you know if there is any way to assign a keyboard key via Keyconfig that can toggle between the function "View->Message Body As->Plain Text" in TB 3.0.x?. What I'm looking for is when viewing an HTML message, using this key I can quickly toggle between Plain Text and Original HTML Views on a per message basis. Thanks.
mad.engineer
Posts: 314
Joined: August 8th, 2006, 4:08 pm

Re: keyconfig 20080929

Post by mad.engineer »

I found a similar note earlier on this forum:
user_pref("keyconfig.main.xxx_key__View Message Body As Plain Text", "!][][][MsgBodyAsPlaintext();");
and assigned it a Key (T), but it's not working for me. When I press the key, nothing happens?. Am I missing anything here?. Thanks
mad.engineer
Posts: 314
Joined: August 8th, 2006, 4:08 pm

Re: keyconfig 20080929

Post by mad.engineer »

I figured it out. Had to replace the previous code with this one that I found at:
http://kb.mozillazine.org/Keyconfig_ext ... hunderbird

pref.getBoolPref("mailnews.display.prefer_plaintext")?
MsgBodyAllowHTML():MsgBodyAsPlaintext()

Now it it working fine.
Post Reply