MozillaZine

keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
firefoxuse
 
Posts: 1014
Joined: November 8th, 2011, 12:06 pm

Post Posted April 8th, 2017, 3:03 pm

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.


I cannot check 258 older pages!!!

malliz
Folder@Home

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

Post Posted April 8th, 2017, 3:09 pm

Tried the search this topic box?
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"

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

Post Posted April 8th, 2017, 4:20 pm

malliz wrote:Tried the search this topic box?


yes it didn't work

there should be a list with the common functions, the developer should consider that

malliz
Folder@Home

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

Post Posted April 8th, 2017, 4:52 pm

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"

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

Post Posted April 8th, 2017, 5:00 pm

malliz wrote:http://mozilla.dorando.at/keyconfig/examples.html


well that seems to help, but only a bit

I don't know what coding language is that and if there is a reference so that I can script my own commands!

deltaa
New Member
 
Posts: 1
Joined: April 16th, 2017, 12:26 pm

Post Posted April 16th, 2017, 12:32 pm

Hi i am getting stuck in writing a script that should forward a selected email inline with attachments to a dedicated recipient defined in the script.
The email should not be send automaticially, but i want to add a predefined text "Hello, please check this email" by the script and manually press the "send" button.
Any ideas how to to this?
best reagrds alex

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

Post Posted April 17th, 2017, 3:42 pm

@deltaa

Try this:

Code: Select all
// forward inline, add recipient, insert text
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
  getService(Components.interfaces.nsIWindowMediator);
var msgHdr = gFolderDisplay.selectedMessage;
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", "foo bar <test@invalid.com>");
      this.awDeleteRow(this.awGetMaxRecipients());
      this.GetCurrentEditor().insertText("Abracadabra.");
    }, 0);
  }
}
wm.addListener(listener);
MsgForwardAsInline(null);

Similar post: viewtopic.php?p=14725693#p14725693

gentlejack
 
Posts: 1
Joined: April 13th, 2017, 7:07 pm

Post Posted April 29th, 2017, 1:44 am

// forward inline, add recipient, insert text
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
getService(Components.interfaces.nsIWindowMediator);
var msgHdr = gFolderDisplay.selectedMessage;
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", "foo bar <test@invalid.com>");
this.awDeleteRow(this.awGetMaxRecipients());
this.GetCurrentEditor().insertText("Abracadabra.");
}, 0);
}
}
wm.addListener(listener);
MsgForwardAsInline(null);
Code: Select all
[list][list=][*][img][url][color=#4000FF] :D  =D>  ](*,)  =D> [/color][/url][/img][/list][/list]

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

Post Posted May 8th, 2017, 11:58 am

Hi!
Is it possible to set a shortcut to a few of DownThemAll!'s features available from the context menu?
eg: "DownThemAll!", "DownThemAll! Selection", "Save Link with DownThemAll!"

So far my attempts failed. The code which appears in DOM inspector (eg.: "dta:regular") is suspiciously nothing like code I used in keyconfig before

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

Post Posted May 8th, 2017, 3:18 pm

@avada

Try these:

Code: Select all
// DownThemAll!
var command = document.getElementById("dta:regular");
command.doCommand();

Code: Select all
// DownThemAll! Selection
var command = document.getElementById("dta:regular-sel");
command.doCommand();

Code: Select all
// Save Link with DownThemAll!
var command = document.getElementById("dta:regular-link");
command.doCommand();

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

Post Posted May 8th, 2017, 4:16 pm

morat wrote:@avada

Try these:

Code: Select all
// DownThemAll!
var command = document.getElementById("dta:regular");
command.doCommand();

Code: Select all
// DownThemAll! Selection
var command = document.getElementById("dta:regular-sel");
command.doCommand();

Code: Select all
// Save Link with DownThemAll!
var command = document.getElementById("dta:regular-link");
command.doCommand();


Thanks you very much!
The first two work splendidly. The third, sadly though no unexpectedly doesn't. I get a "TypeError: window.gContextMenu is null" error in the console. (Even if I use tab to get the link selected)
So I guess there's no way of passing for example the hovered link (the way flashgot did it) to the save link feature of DTA?

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

Post Posted May 8th, 2017, 8:05 pm

@avada

I tried using a trick based on the following code, but it no longer works. I get a "TypeError: gContextMenuContentData is null" error in the console.

Code: Select all
// fails
// view image or background image using gContextMenu
// left click image - open image in current tab
// left click image with ctrl - open image in new tab in foreground
// left click image with ctrl and shift - open image in new tab in background
// left click image with shift - open image in new window
// middle click image - same as left click with ctrl
function handleClick(event) {
  window.removeEventListener("click", handleClick, true);
  event.preventDefault();
  event.stopPropagation();
  document.popupNode = event.originalTarget;
  var menuPopup = document.getElementById("contentAreaContextMenu");
  var shiftKey = false;
  gContextMenu = new nsContextMenu(menuPopup, shiftKey);
  if (gContextMenu.onImage) gContextMenu.viewMedia(event);
  else if (gContextMenu.hasBGImage) gContextMenu.viewBGImage(event);
  gContextMenu = null;
}
window.addEventListener("click", handleClick, true);

Code: Select all
// fails
// Save Link with DownThemAll!
document.popupNode = document.commandDispatcher.focusedElement;
var menuPopup = document.getElementById("contentAreaContextMenu");
var shiftKey = false;
gContextMenu = new nsContextMenu(menuPopup, shiftKey);
document.getElementById("dta:regular-link").doCommand();
gContextMenu = null;

I don't know how to execute the last command.

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

Post Posted May 9th, 2017, 1:28 am

morat wrote:I tried using a trick based on the following code, but it no longer works. I get a "TypeError: gContextMenuContentData is null" error in the console.
morat wrote:I don't know how to execute the last command.

Okay. Thanks for trying!

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

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

@avada

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

Code: Select all
// Save Link with DownThemAll!
var localFile = Components.classes["@mozilla.org/file/local;1"].
  createInstance(Components.interfaces.nsILocalFile);
var process = Components.classes["@mozilla.org/process/util;1"].
  createInstance(Components.interfaces.nsIProcess);
var args = ["sendmouse", "right", "click"];
localFile.initWithPath("C:\\nircmd.exe");
process.init(localFile);
process.run(false, args, args.length);
setTimeout(function () {
  document.getElementById("dta:regular-link").doCommand();
}, 1000);

http://www.nirsoft.net/utils/nircmd.html
http://www.nirsoft.net/utils/nircmd2.html#sendmouse

Similar post: viewtopic.php?p=12958067#p12958067

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

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

@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

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 5 guests