keyconfig 20110522

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

Re: keyconfig 20110522

Post by firefoxuse »

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!!!
User avatar
malliz
Folder@Home
Posts: 43796
Joined: December 7th, 2002, 4:34 am
Location: Australia

Re: keyconfig 20110522

Post by malliz »

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: 1086
Joined: November 8th, 2011, 12:06 pm

Re: keyconfig 20110522

Post by firefoxuse »

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
User avatar
malliz
Folder@Home
Posts: 43796
Joined: December 7th, 2002, 4:34 am
Location: Australia

Re: keyconfig 20110522

Post by malliz »

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: 1086
Joined: November 8th, 2011, 12:06 pm

Re: keyconfig 20110522

Post by firefoxuse »

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

Re: keyconfig 20110522

Post by deltaa »

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: 6394
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@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: http://forums.mozillazine.org/viewtopic ... #p14725693
gentlejack
Posts: 1
Joined: April 13th, 2017, 7:07 pm

Re: keyconfig 20110522

Post by gentlejack »

// 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]
[/u][/i][/b]
avada
Posts: 1932
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Re: keyconfig 20110522

Post by avada »

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: 6394
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@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: 1932
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Re: keyconfig 20110522

Post by avada »

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: 6394
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@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: 1932
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Re: keyconfig 20110522

Post by avada »

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: 6394
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@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: http://forums.mozillazine.org/viewtopic ... #p12958067
morat
Posts: 6394
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@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: http://forums.mozillazine.org/viewtopic ... #p12970451
Post Reply