MozillaZine


keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
godzfire
 
Posts: 126
Joined: September 13th, 2009, 1:12 pm

Post Posted July 4th, 2021, 8:09 am

One more if I could, I'd like to either modify the current File > Send Now combo that's Command+Return or create a new one that's instead Command+Enter. Can that be done via Thunderbird prefs or tbkeys?

morat
 
Posts: 4754
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 4th, 2021, 8:43 am

@godzfire

The command to send now...

Code: Select all
window.goDoCommand('cmd_sendNow');

Thunderbird commands
http://kb.mozillazine.org/Keyconfig_extension:_Thunderbird
Last edited by morat on July 5th, 2021, 6:10 pm, edited 1 time in total.

godzfire
 
Posts: 126
Joined: September 13th, 2009, 1:12 pm

Post Posted July 5th, 2021, 12:13 pm

How would I format command+enter in tbkeys?

morat
 
Posts: 4754
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 5th, 2021, 5:39 pm

@godzfire

The tbkeys addon uses Mousetrap to bind key sequences to custom commands.

Mousetrap - Supported keys
http://craig.is/killing/mice#keys

The default return shortcut, i.e. open message in new tab, may conflict with the tbkeys command+return shortcut on Mac.

Thunderbird shortcuts
http://support.mozilla.org/kb/keyboard-shortcuts

godzfire
 
Posts: 126
Joined: September 13th, 2009, 1:12 pm

Post Posted July 6th, 2021, 3:47 pm

I could use Command + NumberPad Period instead. I just need to know what the 'equation' is to put into tbkeys (my apologies, but I am not good with understanding programming/coding language. If you could tell me what to copy and paste it in the format of tbkeys would be appreciated ie:
"d": "window.goDoCommand('cmd_viewPageSource');",

morat
 
Posts: 4754
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 6th, 2021, 8:13 pm

@godzfire

Here is a main key bindings example for the tbkeys addon.

Code: Select all
{
  "1": "window.alert('alpha');",
  "2": "window.alert('beta');",
  "3": "window.alert('gamma');"
}

Press One to alert alpha.
Press Two to alert beta.
Press Three to alert gamma.

Now change "1" to "command+." and save settings. That works with the typewriter period and numpad period.

Press Command+Period to alert alpha.

avada
 
Posts: 1901
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted July 15th, 2021, 2:29 am

Hi morat!
If you're still around.

The Ctrl+F1 DTA one click code I got from you started failing for me. (FF89)

Code: Select all
    Components.utils.import("resource://gre/modules/ctypes.jsm");
    var user32 = ctypes.open("user32");
    var BOOL = ctypes.int;
    var LONG = ctypes.long;
    var POINT = ctypes.StructType("tagPOINT", [{x:LONG}, {y:LONG}]);
    var LPPOINT = POINT.ptr;
    var GetCursorPos = user32.declare('GetCursorPos', ctypes.winapi_abi, BOOL, LPPOINT);
    var point = new POINT;
    if (GetCursorPos(point.address())) {
     
     var utils = window.windowUtils;
    
      var MOUSEEVENTF_RIGHTDOWN = 0x0008;
      var MOUSEEVENTF_RIGHTUP = 0x0010;
      utils.sendNativeMouseEvent(point.x, point.y, MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, null);
    }
    user32.close();
    setTimeout(function () {
      document.getElementById("dta:turbo-link").doCommand();
      document.getElementById("contentAreaContextMenu").hidePopup();
      setTimeout(function () {
        var win = Services.wm.getMostRecentWindow("alert:alert");
        if (win &&
            win.document.getElementById("alertTitleLabel") &&
            win.document.getElementById("alertTitleLabel").value == "DownThemAll!") {
          win.onAlertClose();
        }
      }, 2000);
    }, 1000);


    /*
    // Save Link with dTa! OneClick
    Components.utils.import("resource://gre/modules/ctypes.jsm");
    var user32 = ctypes.open("user32");
    var BOOL = ctypes.int;
    var LONG = ctypes.long;
    var POINT = ctypes.StructType("tagPOINT", [{x:LONG}, {y:LONG}]);
    var LPPOINT = POINT.ptr;
    var GetCursorPos = user32.declare('GetCursorPos', ctypes.winapi_abi, BOOL, LPPOINT);
    var point = new POINT;
    if (GetCursorPos(point.address())) {
      var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
        getInterface(Components.interfaces.nsIDOMWindowUtils);
      var MOUSEEVENTF_RIGHTDOWN = 0x0008;
      var MOUSEEVENTF_RIGHTUP = 0x0010;
      utils.sendNativeMouseEvent(point.x, point.y, MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, null);
    }
    user32.close();
    setTimeout(function () {
      document.getElementById("dta:turbo-link").doCommand();
      document.getElementById("contentAreaContextMenu").hidePopup();
      setTimeout(function () {
        var win = Services.wm.getMostRecentWindow("alert:alert");
        if (win &&
            win.document.getElementById("alertTitleLabel") &&
            win.document.getElementById("alertTitleLabel").value == "DownThemAll!") {
          win.onAlertClose();
        }
      }, 2000);
    }, 1000);
   
*/


I get an error in the console:
Code: Select all
11:26:53.076 Uncaught
Exception { name: "NS_ERROR_XPC_NOT_ENOUGH_ARGS", message: "Not enough arguments [nsIDOMWindowUtils.sendNativeMouseEvent]", result: 2153185281, filename: "chrome://browser/content/browser.xhtml", lineNumber: 15, columnNumber: 0, data: null, stack: "oncommand@chrome://browser/content/browser.xhtml:15:13\nopenEditor@chrome://keyconfig/content/keyconfig.js:386:12\nondblclick@chrome://keyconfig/content/keyconfig.xhtml:1:11\n", location: XPCWrappedNative_NoHelper }

columnNumber: 0

data: null

filename: "chrome://browser/content/browser.xhtml"

lineNumber: 15

location: XPCWrappedNative_NoHelper { QueryInterface: QueryInterface(), filename: Getter, name: Getter, … }

message: "Not enough arguments [nsIDOMWindowUtils.sendNativeMouseEvent]"

name: "NS_ERROR_XPC_NOT_ENOUGH_ARGS"

result: 2153185281

stack: "oncommand@chrome://browser/content/browser.xhtml:15:13\nopenEditor@chrome://keyconfig/content/keyconfig.js:386:12\nondblclick@chrome://keyconfig/content/keyconfig.xhtml:1:11\n"

<prototype>: ExceptionPrototype { toString: toString(), name: Getter, message: Getter, … }
browser.xhtml:15

I guess a function might have changed? Is it fixable?

morat
 
Posts: 4754
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 15th, 2021, 7:21 am

@avada

Try this:

Code: Select all
- var MOUSEEVENTF_RIGHTDOWN = 0x0008;
- var MOUSEEVENTF_RIGHTUP = 0x0010;
- utils.sendNativeMouseEvent(point.x, point.y, MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, null);
+ utils.sendNativeMouseEvent(point.x, point.y, utils.NATIVE_MOUSE_MESSAGE_BUTTON_DOWN, 2, 0, null, function () {
+   utils.sendNativeMouseEvent(point.x, point.y, utils.NATIVE_MOUSE_MESSAGE_BUTTON_UP, 2, 0, null);
+ });

Reference
http://searchfox.org/mozilla-esr78/search?q=sendNativeMouseEvent
http://searchfox.org/mozilla-release/search?q=sendNativeMouseEvent

Pet peeve: don't post errors without spaces (forum width messes up)

avada
 
Posts: 1901
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted July 23rd, 2021, 12:28 pm

morat wrote:@avada

Try this:

Code: Select all
- var MOUSEEVENTF_RIGHTDOWN = 0x0008;
- var MOUSEEVENTF_RIGHTUP = 0x0010;
- utils.sendNativeMouseEvent(point.x, point.y, MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, null);
+ utils.sendNativeMouseEvent(point.x, point.y, utils.NATIVE_MOUSE_MESSAGE_BUTTON_DOWN, 2, 0, null, function () {
+   utils.sendNativeMouseEvent(point.x, point.y, utils.NATIVE_MOUSE_MESSAGE_BUTTON_UP, 2, 0, null);
+ });

Reference
http://searchfox.org/mozilla-esr78/search?q=sendNativeMouseEvent
http://searchfox.org/mozilla-release/search?q=sendNativeMouseEvent

Pet peeve: don't post errors without spaces (forum width messes up)


Thanks!

bege
 
Posts: 140
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted August 7th, 2021, 9:58 am

@morat
With your help I got this code for tbkeys to move all messages from the active folder to a given folder.
Now I want to completely delete all messages whose sender contains "immo" in that folder before the remaining messages are moved to the given folder. How can this be accomplished?

Code: Select all
    "p": "(function () { var targetUri = 'mailbox://nobody@Local%20Folders/Trash/GMX'; var targetFolder = window.MailUtils.getExistingFolder(targetUri); window.goDoCommand('cmd_selectAll'); window.MsgMoveMessage(targetFolder); })();",

morat
 
Posts: 4754
Joined: February 3rd, 2009, 6:29 pm

Post Posted August 7th, 2021, 3:55 pm

@bege

Maybe you can use a message filter to do that. I don't know a solution offhand.

Some ideas..

viewtopic.php?p=14845569#p14845569
viewtopic.php?p=14717611#p14717611

Maybe you could use the quick filter bar.

Code: Select all
(function () {
  var filterField = window.document.getElementById('qfb-qs-textbox');
  var button1 = window.document.getElementById('qfb-qs-sender');
  var button2 = window.document.getElementById('qfb-qs-recipients');
  var button3 = window.document.getElementById('qfb-qs-subject');
  var button4 = window.document.getElementById('qfb-qs-body');
  var threadTree = window.document.getElementById('threadTree');
  window.goDoCommand('cmd_showQuickFilterBar');
  filterField.value = 'immo';
  filterField.doCommand();
  if (button1.checked == false) button1.click();
  if (button2.checked ==  true) button2.click();
  if (button3.checked ==  true) button3.click();
  if (button4.checked ==  true) button4.click();
  window.setTimeout(function () {
    threadTree.focus();
    window.goDoCommand('cmd_selectAll');
  }, 1000);
  window.setTimeout(function () {
    if (button1.checked == false) button1.click();
    if (button2.checked == false) button2.click();
    if (button3.checked == false) button3.click();
    if (button4.checked ==  true) button4.click();
    filterField.value = '';
    filterField.doCommand();
    window.goDoCommand('cmd_toggleQuickFilterBar');
  }, 2000);
  window.setTimeout(function () {
    threadTree.focus();
 // window.goDoCommand('cmd_delete');
    window.goDoCommand('cmd_tag1');
  }, 3000);
})();

Move messages
http://forums.mozillazine.org/viewtopic.php?f=19&t=3007811
http://forums.mozillazine.org/viewtopic.php?f=39&t=2400971
http://forums.mozillazine.org/viewtopic.php?f=19&t=3007865

bege
 
Posts: 140
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted August 8th, 2021, 10:38 am

morat wrote:@bege

Maybe you can use a message filter to do that. I don't know a solution offhand.


Thank you for your ideas and links. :-D

This one looks quite promising to delete the filtered messages:

Code: Select all
    (function () {
      function createDummyFilterClone(filter, filterList) {
        var retval = filterList.createFilter(filter.filterName);
        retval.filterType = filter.filterType;
        retval.temporary = true;
        retval.enabled = true;
        retval.filterDesc = filter.filterDesc;
        retval.filterList = filterList;
        retval.scope = filter.scope;
        var nrActions = filter.actionCount;
        for (var i = 0; i < nrActions; i++) {
          retval.appendAction(filter.getActionAt(i));
        }
        return retval;
      }
      var filterName = "tempFilter"; // filter name in message filters window
      var filterService = Components.classes["@mozilla.org/messenger/services/filters;1"].
        getService(Components.interfaces.nsIMsgFilterService);
      var msg = gFolderDisplay.selectedMessage;
      var folder = msg.folder;
      var curFilterList = folder.getFilterList(msgWindow);
      var filter = curFilterList.getFilterNamed(filterName);
      if (filter) {
        var tempFilterList = filterService.getTempFilterList(folder);
        var msgList = Components.classes["@mozilla.org/array;1"].
          createInstance(Components.interfaces.nsIMutableArray);
        msgList.appendElement(msg, false);
        tempFilterList.logStream = curFilterList.logStream;
        tempFilterList.loggingEnabled = curFilterList.loggingEnabled;
        tempFilterList.insertFilterAt(0, createDummyFilterClone(filter, tempFilterList));
        folder.setFilterList(tempFilterList);
        try {
          console.log("Running filter '" + filter.filterName + "' on message '" + msg.mime2DecodedSubject + "'");
          filterService.applyFilters(Components.interfaces.nsMsgFilterType.All, msgList, folder, msgWindow);
          console.log("Done running filter");
        } finally {
          folder.setFilterList(curFilterList);
        }
      } else {
        console.log("No filter with '" + filterName + "' filter name");
      }
    })();


I tested it in the console
- it runs not on all selected but only on the first message
- then it throws the error
TypeError: msgs.enumerate is not a function bootstrap.js:608:36

- then shows
Done running filter

and it deleted the first message although the conditions where not met.

Do you have an idea what needs to be changed?

morat
 
Posts: 4754
Joined: February 3rd, 2009, 6:29 pm

Post Posted August 8th, 2021, 12:13 pm

@bege

The code snippet in the other thread works for me using the error console. I don't get any errors.

Someone would have to rewrite the code snippet to solve your problem. I can't help with the message filter stuff.

bege
 
Posts: 140
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted August 8th, 2021, 1:26 pm

morat wrote:@bege

The code snippet in the other thread works for me using the error console. I don't get any errors.

Did you test with more than one message selected and with messages of which some match the filter conditions and some don't?

morat
 
Posts: 4754
Joined: February 3rd, 2009, 6:29 pm

Post Posted August 8th, 2021, 7:40 pm

@bege

The code snippet only works with a single selected message, not with multiple selected messages.

Okay, I see now. The code snippet is performing the filter action even when the selected message doesn't match the filter condition. I don't know how to fix it. I'm not familiar with the filter methods, so I'm not much help.

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 1 guest