MozillaZine

keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
avada
 
Posts: 1742
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted May 9th, 2017, 1:36 pm

morat wrote:@avada

You can use the ctypes to send a right click, then execute the command.

Code: Select all
// Save Link with DownThemAll!
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:regular-link").doCommand();
}, 1000);

Similar post: viewtopic.php?p=12970451#p12970451

Thanks! This works fine. The timeout can even be decreased substantially.

scheffkocha
 
Posts: 2
Joined: May 11th, 2017, 12:12 am

Post Posted May 11th, 2017, 12:17 am

Hallo,

thank you for this wonderful extension.
Just one question: What can I do if content is null? I created a simple new shortcut with
Code: Select all
alert(content)

The alert window contains just null, so I cannot access the content of the current document.
I am using Firefox 53.0 and Dorando keyconfig 2016.2
Any hints?

Thank you!

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

Post Posted May 11th, 2017, 9:13 am

@scheffkocha

I guess the content object is null because e10s is enabled. You can disable it.

Electrolysis also called e10s
http://wiki.mozilla.org/Electrolysis#Firefox_Release

scheffkocha
 
Posts: 2
Joined: May 11th, 2017, 12:12 am

Post Posted May 11th, 2017, 11:33 pm

@morat

Yes, that's the reason. Thank you for pointing this out!

firefoxuse
 
Posts: 1014
Joined: November 8th, 2011, 12:06 pm

Post Posted May 14th, 2017, 12:22 pm

morat are you the person who wrote this addon? can you help me with my request?

malliz
Folder@Home

User avatar
 
Posts: 43262
Joined: December 7th, 2002, 4:34 am
Location: Australia

Post Posted May 14th, 2017, 3:39 pm

No he's not

nohamelin wrote:@firefoxuse
They are a bunch of code requests, without providing a single clue if you at least took some time to check older pages in this thread to find something similar. The bigger the request, the greater the patience you need to wait for someone who can take that task for you.
What sort of man would put a known criminal in charge of a major branch of government? Apart from, say, the average voter.
"Terry Pratchett"

hife
 
Posts: 5
Joined: May 20th, 2014, 6:38 am

Post Posted May 18th, 2017, 12:07 pm

I am looking for a command that does the same as Tools > Apply filters to messages in Thunderbird 52.

More precisely, I am trying to automate "Select All" then "Apply filters to messages" to emulate "Run filters on folder" for virtual folders. However, I have been unable to find the proper command for "Apply filters to messages". I have checked this article and tried every code that seemed to be related to filters and I tried using morat's script from this post by creating a shortcut in keyconfig and pasting the code in the code box, however, nothing gets copied to the clipboard when I press the shortcut (the shortcut works if I set it for different functions, so it is not blocked or anything). Am I using the script wrong?

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

Post Posted May 18th, 2017, 2:04 pm

@hife

Try this:

Code: Select all
// Select All
goDoCommand("cmd_selectAll");

// Run Filters on Message
goDoCommand("cmd_applyFiltersToSelection");

The code snippet from this post works for me. Perhaps the chrome url is different in Linux.

Thunderbird Commands
http://pastebin.com/raw/nJdfp3ib

Thunderbird 52.1.1
Windows 7 SP1 32-bit

P.S.

You can use the following code to easily extract commands.

Code: Select all
function getCommand(event) {
  window.removeEventListener("command", getCommand, true);
  event.preventDefault();
  event.stopPropagation();
  alert(event.originalTarget.getAttribute("oncommand") ||
    event.originalTarget.getAttribute("onclick"));
}
window.addEventListener("command", getCommand, true);

The trick does not work for all user interface elements.

hife
 
Posts: 5
Joined: May 20th, 2014, 6:38 am

Post Posted May 19th, 2017, 3:16 am

morat wrote:
Code: Select all
// Select All
goDoCommand("cmd_selectAll");

// Run Filters on Message
goDoCommand("cmd_applyFiltersToSelection");

Thanks, that was what I was looking for. However, I just noticed "Apply filters to selection" doesn't seem to work in my smart inbox folder (both when run from the menu or by the above command). That's a separate issue though and not really related to keyconfig, so I'll take that elsewhere.

morat wrote:The code snippet from this post works for me. Perhaps the chrome url is different in Linux.

Never mind, it did work once I copied the full code. I missed the scroll-bar, my bad. I'm very sorry about that. (What does not seem to work is the "SELECT ALL" button, which just takes me to the top of the page.)

morat wrote:Thunderbird Commands
http://pastebin.com/raw/nJdfp3ib

Thunderbird 52.1.1
Windows 7 SP1 32-bit

Thanks, would you mind if I linked that in the article?

morat wrote:You can use the following code to easily extract commands.

Code: Select all
function getCommand(event) {
  window.removeEventListener("command", getCommand, true);
  event.preventDefault();
  event.stopPropagation();
  alert(event.originalTarget.getAttribute("oncommand") ||
    event.originalTarget.getAttribute("onclick"));
}
window.addEventListener("command", getCommand, true);

The trick does not work for all user interface elements.

That worked like a charm as well. Would you mind if I linked that too?

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

Post Posted May 19th, 2017, 5:08 pm

@hife

As an alternative to the cmd_applyFiltersToSelection command, try something like:

viewtopic.php?p=14717611#p14717611

I don't remember what works with virtual folders.

hife wrote:mind if I linked that

There is already a link to the code in the external links section.

http://kb.mozillazine.org/Keyconfig_ext ... rnal_links

Another user may have different extensions, thus different commands in his list.

hife wrote:mind if I linked that too

It's okay, but link the following page in the external links section.

viewtopic.php?p=12492305#p12492305

It has a version with a confirm dialog to copy the command and a link to the original version.

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

Post Posted May 29th, 2017, 12:29 am

Hi!
Do you think this can be further improved to close the context menu after some time. If DTA window is already open (and I have it set to not come in front) the context menu remains open, even though the download starts. (I also have the context menu item hidden via Menu Wizard because I don't need it there with the hotkey.) (This makes no difference, and I misremembered, they're enabled...)
morat wrote:@avada

You can use the ctypes to send a right click, then execute the command.

Code: Select all
// Save Link with DownThemAll!
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:regular-link").doCommand();
}, 1000);

Similar post: viewtopic.php?p=12970451#p12970451

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

Post Posted May 29th, 2017, 6:02 am

@avada

The code opens the context popup, runs the command, closes the context popup, then opens a "Add Downloads" dialog. If a "Add Downloads" dialog is already open, then the code opens another "Add Downloads" dialog.

The "Make Your Selection" window does not change anything for me.

I don't understand the problem.

You could try click instead of the doCommand method.

Code: Select all
- document.getElementById("dta:regular-link").doCommand();
+ document.getElementById("dta:regular-link").click();

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

Post Posted May 29th, 2017, 6:19 am

@morat
Sorry, I forgot to mention that I use "dta:turbo-link" instead for this, which adds downloads automatically without bringing anything up.

Tried doCommand, but it makes no difference.

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

Post Posted May 29th, 2017, 11:56 am

@avada

Try this:

Code: Select all
// 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);
Last edited by morat on May 30th, 2017, 5:41 am, edited 1 time in total.

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

Post Posted May 29th, 2017, 11:59 pm

morat wrote:@avada

Try this:

Thanks!

Return to Extension/Theme Releases


Who is online

Users browsing this forum: Bing [Bot], mistamontiel and 5 guests