keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
Post Reply
User avatar
blackwind
Posts: 115
Joined: May 12th, 2007, 3:07 pm
Location: Canada
Contact:

Re: keyconfig 20110522

Post by blackwind »

Well, it's a start, but I can't find a target that CommandUtils.createEnvironment() will accept in Fx31.
/bw (Author of Reload Plus)
ventainais
Posts: 9
Joined: May 29th, 2014, 12:43 am

Re: keyconfig 20110522

Post by ventainais »

I still would like some help with the copying.
imagr8m8
Posts: 117
Joined: August 6th, 2004, 3:39 pm

Did move message funtion change in TBird 31?

Post by imagr8m8 »

All my key bindings to move messages to either local and imap folders stopped working when I upgraded to TBrid 31

This worked in Tbrid 24 but no longer works in TBird 31:

MsgMoveMessage(GetMsgFolderFromUri("mailbox://nobody@Feeds/Save"));

Searches for "MsgMoveMessage" and "Move Message function" haven't been fruitful. Any ideas welcome.
j6CPmZpg38SiOu91
Posts: 4
Joined: April 9th, 2014, 4:54 pm

Re: keyconfig 20110522

Post by j6CPmZpg38SiOu91 »

Hi, is there any command to obtain firefox.exe path? Thanks.
morat
Posts: 6429
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@imagr8m8

Try this:

Code: Select all

var targetUri = "mailbox://nobody@Local%20Folders/Trash";
var targetFolder = MailUtils.getFolderForURI(targetUri);
MsgMoveMessage(targetFolder);

@j6CPmZpg38SiOu91

Using Special Files:

Code: Select all

var file = Components.classes["@mozilla.org/file/directory_service;1"].
  getService(Components.interfaces.nsIProperties).
  get("XREExeF", Components.interfaces.nsIFile);
alert(file.path);
var uri = Components.classes["@mozilla.org/network/io-service;1"].
  getService(Components.interfaces.nsIIOService).
  newFileURI(file);
alert(uri.spec);
var localFile = file.QueryInterface(Components.interfaces.nsILocalFile);
localFile.reveal();

Export Special Files to Clipboard:

Code: Select all

var ds = Components.classes["@mozilla.org/file/directory_service;1"].
  getService(Components.interfaces.nsIProperties);
var nsDirectoryServiceDefs = ["AppData", "ApplMenu", "Buckt", "CmAppData", "CmDeskP", "CmPrgs",
  "CmStrt", "CntlPnl", "Cntls", "CookD", "CurProcD", "CurWorkD", "Desk", "DeskP", "DeskV",
  "DfltDwnld", "Docs", "Drivs", "DrvD", "Exts", "Favs", "Fnts", "GreD", "Home", "IntrntSts", "ISrch",
  "LibD", "LocalAppData", "LocApp", "LocDocs", "LocDsk", "LocFrmwrks", "Locl", "LoclIntrntPlgn",
  "LocPrfs", "Mov", "Music", "netH", "NetW", "Pct", "Pers", "Pict", "Prfs", "PrntHd", "Prnts",
  "ProgF", "Progs", "Rcnt", "Shdwn", "SndTo", "Strt", "SysD", "TmpD", "Tmpls", "Trsh", "ULibDir",
  "UsrApp", "UsrDocs", "UsrDsk", "UsrFrmwrks", "UsrIntrntPlgn", "UsrPrfs", "Vids", "WinD",
  "XCurProcD", "XDGDesk", "XDGDocs", "XDGDwnld", "XDGMusic", "XDGPict", "XDGPubSh", "XDGTempl",
  "XDGVids", "XpcomLib"];
var nsAppDirectoryServiceDefs = ["AChrom", "AChromDL", "APluginsDL", "APlugns", "AppRegD", "AppRegF",
  "ARes", "BMarks", "cachePDir", "DefProfLRt", "DefProfRt", "DefRt", "DLoads", "ExtPrefDL",
  "indexedDBPDir", "LclSt", "MetroPrefF", "permissionDBPDir", "PrefD", "PrefDL", "PrefDOverride",
  "PrefF", "PrfDef", "ProfD", "profDef", "ProfDefNoLoc", "ProfLD", "SHARED", "SrchF", "SrchPluginsDL",
  "SrchPlugns", "UChrm", "UMimTyp", "UPnls", "UsrSrchPlugns", "XPIClnupD"];
var nsXULAppAPI = ["OSUpdApplyToD", "ProfDS", "ProfLDS", "UAppData", "UpdArchD", "UpdRootD",
  "XREAppDist", "XREExeF", "XREExtDL", "XRESysLExtPD", "XRESysSExtPD", "XREUSysExt"];
var props = new Array();
var out = new Array();
props = props.concat(nsDirectoryServiceDefs);
props = props.concat(nsAppDirectoryServiceDefs);
props = props.concat(nsXULAppAPI);
for (var i = 0; i < props.length; i++) {
  if (ds.has(props[i])) {
    var file = ds.get(props[i], Components.interfaces.nsIFile);
    if (file && file.path) {
      out.push([props[i], file.path]);
    }
  }
}
out.sort(function(a, b) { return a[1] > b[1] });
var width = out.reduce(function(a, b) { return a[0].length > b[0].length ? a : b })[0].length;
for (var i = 0; i < out.length; i++) {
  out[i] = out[i][0] + Array(width + 2 - out[i][0].length).join(" ") + out[i][1];
}
var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"].
  getService(Components.interfaces.nsIClipboardHelper);
clipboard.copyString(out.join("\r\n"));

http://mxr.mozilla.org/mozilla-release/ ... viceDefs.h
http://mxr.mozilla.org/mozilla-release/ ... viceDefs.h
http://mxr.mozilla.org/mozilla-release/ ... ULAppAPI.h

Edit: export code based on Gecko 31
Last edited by morat on August 5th, 2014, 4:23 am, edited 1 time in total.
j6CPmZpg38SiOu91
Posts: 4
Joined: April 9th, 2014, 4:54 pm

Re: keyconfig 20110522

Post by j6CPmZpg38SiOu91 »

morat wrote:

Code: Select all

var file = Components.classes["@mozilla.org/file/directory_service;1"].
  getService(Components.interfaces.nsIProperties).
  get("XREExeF", Components.interfaces.nsIFile);
alert(file.path);
var uri = Components.classes["@mozilla.org/network/io-service;1"].
  getService(Components.interfaces.nsIIOService).
  newFileURI(file);
alert(uri.spec);
var localFile = file.QueryInterface(Components.interfaces.nsILocalFile);
localFile.reveal();

Works beautifully. Thanks.
imagr8m8
Posts: 117
Joined: August 6th, 2004, 3:39 pm

Re: keyconfig 20110522

Post by imagr8m8 »

Thank you @morat..much appreciated.

Just to be helpful for anyone struggling with code...replace quoted text in first line with the Uri of folder you want to move to.

var targetUri = "mailbox://nobody@Local%20Folders/Trash";
var targetFolder = MailUtils.getFolderForURI(targetUri);
MsgMoveMessage(targetFolder);


Tip I got few years ago: To get the folder Uri, you can bind code below to a key (I use key ctrl-shft-U), select folder, press key combo & get pop-up with Folder Uri

alert(GetFirstSelectedMsgFolder().URI);
brwno
Posts: 1
Joined: July 31st, 2014, 5:19 pm

Shortcut conflict

Post by brwno »

I set the web search shortcut to alt+s, but it won't work because alt+s is already the keyboard accelerator for the history menu. Is there something that can be done about this?

Also, my unfocused tabs are set to show only the favicon, while the focused tabs has a certain width. What is the code for applying favicon width to the focused tab?
Amsuke
Posts: 60
Joined: April 3rd, 2010, 8:23 am

Re: keyconfig 20110522

Post by Amsuke »

I had previously been using code that would duplicate the current window:


Code: Select all

OpenBrowserWindow().addEventListener("load", function tempFunction(event){
 this.removeEventListener("command", tempFunction, true);
 var ss = Components.classes["@mozilla.org/browser/sessionstore;1"].getService(Components.interfaces.nsISessionStore);
 ss.setTabState(this.gBrowser.mCurrentTab, ss.getTabState(gBrowser.mCurrentTab))
},true);


However, after updating Firefox (now v31), this no longer works.

How does this need to be adjusted to work again?
sorosch
Posts: 1
Joined: August 15th, 2014, 11:58 am

Re: keyconfig 20110522

Post by sorosch »

Hello,

is the Add-In "Keyconfig" also working with Firefox 31?

I changed the shortcut "Reload Tabs (Clear Cache)" to F5 and "Reload Tabs" to Shift+F5 - but it doesn´t work.

F5 is still only "Reload Tabs" and Shift+F5 is still "Reload Tabs (Clear Cache)".

Any idea whats the reason? Or does the Add-In don´t work with Firefox 31?

Is there another method to do that?

Thank you very much
Best regards
George
User avatar
tonymec
Posts: 734
Joined: October 15th, 2004, 2:58 am
Location: Ixelles (Brussels Capital Region, Belgium)
Contact:

Re: keyconfig 20110522

Post by tonymec »

sorosch wrote:Hello,

is the Add-In "Keyconfig" also working with Firefox 31?

I changed the shortcut "Reload Tabs (Clear Cache)" to F5 and "Reload Tabs" to Shift+F5 - but it doesn´t work.

F5 is still only "Reload Tabs" and Shift+F5 is still "Reload Tabs (Clear Cache)".

Any idea whats the reason? Or does the Add-In don´t work with Firefox 31?

Is there another method to do that?

Thank you very much
Best regards
George

Are these built-in keybindings, or did you define F5 "Reload Tabs" and Shift+F5 "Reload Tabs (Clear Cache)" yourself in a previous release of Firefox?

Some (but not all) of the built-in keystrokes are snatched by Firefox (or Thunderbird, or SeaMonkey) before keyconfig ever has a chance to see them. This varies from one keybinding to the next depending on where in the code they are detected. The programming language used for the corresponding routine might be a relevant factor.
Best regards,
Tony
mueller
Posts: 11
Joined: July 11th, 2011, 3:10 am

Re: keyconfig 20110522

Post by mueller »

Code for moving mails to a specific folder.

In the past I used the following code:
MsgMoveMessage(GetMsgFolderFromUri("imap://123@example.tld/lorem"));

Since Thunderbird 31 that does not work anymore.
See:
https://bugzilla.mozilla.org/show_bug.cgi?id=1043819

Is someone please so kind to post the complete new code (or steps) which is (are) necessary to move mails into a specific folder?

Thanks :)
morat
Posts: 6429
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@mueller

Try this:

Code: Select all

var targetUri = "mailbox://nobody@Local%20Folders/Trash";
var targetFolder = MailUtils.getFolderForURI(targetUri);
MsgMoveMessage(targetFolder);

Here is how to show the selected folder URI.

Code: Select all

alert(GetFirstSelectedMsgFolder().URI);
Rasmis
Posts: 3
Joined: April 12th, 2013, 6:31 am

Re: keyconfig 20110522

Post by Rasmis »

I can't search the thread, and I have been unable to find the necessary information, so I need some assistance.

I want to make a keyboard shortcut, that
    1) tags the selected message as junk and
    2) forwards it as an attachment to my SpamCop reporting address.
Current solution:

Code: Select all

goDoCommand('cmd_markAsJunk');
goDoCommand('cmd_forwardAttachment');

This opens a new message, where I have to input the recipient myself. On the command list, I cannot find any for adding recipients.

How would you solve that?

Thanks,
Rasmus
morat
Posts: 6429
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Rasmis

Try these:

* forward message as attachment

Code: Select all

var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
  getService(Components.interfaces.nsIWindowMediator);
var msgHdr = gFolderDisplay.selectedMessage;
var addressTo = "foo bar <test@invalid.com>";
// var addressCc = "foo bar <test@invalid.com>";
var Listener = {
  onWindowTitleChange: function () {},
  onCloseWindow: function () {},
  onOpenWindow: function (aWindow) {
    wm.removeListener(this);
    this.compose = aWindow.docShell.
      QueryInterface(Components.interfaces.nsIInterfaceRequestor).
      getInterface(Components.interfaces.nsIDOMWindow);
    this.compose.addEventListener("compose-window-init", this, true);
  },
  handleEvent: function (event) {
    event.currentTarget.removeEventListener(event.type, this, true);
    event.currentTarget.gMsgCompose.RegisterStateListener(Listener);
  },
  NotifyComposeFieldsReady: function () {},
  NotifyComposeBodyReady: function () {
    this.compose.gMsgCompose.UnregisterStateListener(this);
    this.compose.window.setTimeout(function () {
      this.AddRecipient("addr_to", addressTo);
      // this.AddRecipient("addr_cc", addressCc);
      this.awDeleteRow(this.awGetMaxRecipients());
      // this.goDoCommand("cmd_sendNow");
    }, 0);
  }
}
wm.addListener(Listener);
// goDoCommand("cmd_forward");
// goDoCommand("cmd_forwardInline");
goDoCommand("cmd_forwardAttachment");

* automatically forward message as attachment

Code: Select all

var forwardTo = "foo bar <test@invalid.com>";
var messageArray = gFolderDisplay.selectedMessageUris;
for (var i = 0; i < messageArray.length; i++) {
  var messageUri = messageArray[i];
  var messenger = Components.classes["@mozilla.org/messenger;1"].
    createInstance(Components.interfaces.nsIMessenger);
  var msgHdr = messenger.messageServiceFromURI(messageUri).messageURIToMsgHdr(messageUri);
  var msgWindow = Components.classes["@mozilla.org/messenger/msgwindow;1"].
    createInstance(Components.interfaces.nsIMsgWindow);
  msgWindow.domWindow = window;
  msgWindow.rootDocShell.allowAuth = true;
  var msgAccountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].
    getService(Components.interfaces.nsIMsgAccountManager);
  var server = msgAccountManager.defaultAccount.incomingServer;
  var msgComposeService = Components.classes["@mozilla.org/messengercompose;1"].
    getService(Components.interfaces.nsIMsgComposeService);
  var forwardAsDefault = msgComposeService.kForwardAsDefault;
  var forwardAsAttachment = msgComposeService.kForwardAsAttachment;
  var forwardInline = msgComposeService.kForwardInline;
  // kForwardAsDefault uses mail.forward_message_mode preference
  // 0: forward as attachment
  // 1: forward as quoted (obsolete, mapped to 2)
  // 2: forward as inline with attachments (default)
  var forwardType = forwardAsAttachment;
  msgComposeService.forwardMessage(forwardTo, msgHdr, msgWindow, server, forwardType);
}
Post Reply