MozillaZine


keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
Rasmis
 
Posts: 3
Joined: April 12th, 2013, 6:31 am

Post Posted August 31st, 2014, 9:07 am

Works perfect, thanks!

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

Post Posted September 9th, 2014, 10:49 am

hello

I want when I click left and right arrow to activate the left or right accordingly tab

how can I do that?

but I don't want to do that when I have focused some text and I want to move to the right or left character

thanks!

t3l0zvxqIiXuzuH0
 
Posts: 92
Joined: August 17th, 2014, 5:57 am

Post Posted September 13th, 2014, 3:25 pm

Hi, I'm using this code
Code: Select all
var selection = document.commandDispatcher.focusedWindow.getSelection().toString();
if (!selection)
 { return; }

var str = readFromClipboard();
if (str)
 { selection = str + " " + selection; }

var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper);
clipboard.copyString(selection);
to add the selected text to clipboard.
Is there any way to have it work even when selecting something in a textfield?

Thanx.

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

Post Posted September 15th, 2014, 4:32 am

@firefoxuse

Try these:

* Shortcut: Right Arrow

Code: Select all
gBrowser.tabContainer.advanceSelectedTab(1, true);

* Shortcut: Left Arrow

Code: Select all
gBrowser.tabContainer.advanceSelectedTab(-1, true);

@t3l0zvxqIiXuzuH0

Try this:

Code: Select all
var selection = getBrowserSelection();
if (!selection) return;
var str = readFromClipboard();
if (str) selection = str + " " + selection;
var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
  getService(Ci.nsIClipboardHelper);
clipboard.copyString(selection);

t3l0zvxqIiXuzuH0
 
Posts: 92
Joined: August 17th, 2014, 5:57 am

Post Posted September 15th, 2014, 10:34 am

morat wrote:@t3l0zvxqIiXuzuH0

Try this:

Code: Select all
var selection = getBrowserSelection();
if (!selection) return;
var str = readFromClipboard();
if (str) selection = str + " " + selection;
var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
  getService(Ci.nsIClipboardHelper);
clipboard.copyString(selection);

Perfect. Thanks.

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

Post Posted September 16th, 2014, 1:19 pm

morat wrote:@firefoxuse

Try these:

* Shortcut: Right Arrow

Code: Select all
gBrowser.tabContainer.advanceSelectedTab(1, true);

* Shortcut: Left Arrow

Code: Select all
gBrowser.tabContainer.advanceSelectedTab(-1, true);



thanks, but after I entered them into configuration, they appeared DISABLED !

any hint?

ventainais
 
Posts: 9
Joined: May 29th, 2014, 12:43 am

Post Posted September 16th, 2014, 11:09 pm

ventainais wrote:
ventainais wrote:Thank you for the reply, but the code wont copy anything, just the message appears "No reply found", but there is a reply.
Hmm, has the reply a References header (View > Message Source) or any other header identifying the main message? Also try removing
Code: Select all
 if(!folder.canFileMessages)
  continue;  

Alternatively try (just comparing the subject):
Code: Select all
var messageId = gFolderDisplay.selectedMessage.messageId;
var messageSubject = gFolderDisplay.selectedMessage.mime2DecodedSubject;
var replyMessage = null;

var allFolders = MailServices.accounts.allFolders.enumerate();
var folders = [];
while(allFolders.hasMoreElements()) {
 var folder = allFolders.getNext().QueryInterface(Components.interfaces.nsIMsgFolder);

 if(!folder.canFileMessages)
  continue;

 var messages = folder.messages;
 while(messages.hasMoreElements()) {
  var message = messages.getNext().QueryInterface(Components.interfaces.nsIMsgDBHdr);

  if(message.mime2DecodedSubject == messageSubject)
   if(!replyMessage || message.date > replyMessage.date)
    replyMessage = message;
 }
}

if(replyMessage && replyMessage.messageId != messageId) {
 MsgHdrToMimeMessage(replyMessage, null, function (aMsgHdr, aMimeMessage) {
  Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper)
  .copyString([
   (aMsgHdr.flags & Components.interfaces.nsMsgMessageFlags.HasRe ? "Re: " : "") + aMsgHdr.mime2DecodedSubject,
   new Date(aMsgHdr.dateInSeconds * 1000),
   aMsgHdr.mime2DecodedAuthor,
   aMsgHdr.mime2DecodedRecipients,
   "",
   aMimeMessage.coerceBodyToPlaintext(gFolderDisplay.displayedFolder).replace(/^\s+/,"").replace(/\s+$/g,"").replace(/\n/g,"\r\n")
  ].join("\r\n"));
  alert("Reply copied");
 }, true);
} else {
 alert("No reply found");
}


I am using IMAP server and I don't know where to find the References header in the source
There is a Message-ID: <1482295362.93038.1403161307842.JavaMail.zimbra@test.eu>

Removing the one code line wont help.

The alternative gives the same error.


The solution was to remove ! from if(!replyMessage || message.date > replyMessage.date)
replyMessage = message;

ventainais
 
Posts: 9
Joined: May 29th, 2014, 12:43 am

Post Posted September 17th, 2014, 1:56 am

ventainais wrote:
ventainais wrote:
ventainais wrote:Thank you for the reply, but the code wont copy anything, just the message appears "No reply found", but there is a reply.
Hmm, has the reply a References header (View > Message Source) or any other header identifying the main message? Also try removing
Code: Select all
 if(!folder.canFileMessages)
  continue;  

Alternatively try (just comparing the subject):
Code: Select all
var messageId = gFolderDisplay.selectedMessage.messageId;
var messageSubject = gFolderDisplay.selectedMessage.mime2DecodedSubject;
var replyMessage = null;

var allFolders = MailServices.accounts.allFolders.enumerate();
var folders = [];
while(allFolders.hasMoreElements()) {
 var folder = allFolders.getNext().QueryInterface(Components.interfaces.nsIMsgFolder);

 if(!folder.canFileMessages)
  continue;

 var messages = folder.messages;
 while(messages.hasMoreElements()) {
  var message = messages.getNext().QueryInterface(Components.interfaces.nsIMsgDBHdr);

  if(message.mime2DecodedSubject == messageSubject)
   if(!replyMessage || message.date > replyMessage.date)
    replyMessage = message;
 }
}

if(replyMessage && replyMessage.messageId != messageId) {
 MsgHdrToMimeMessage(replyMessage, null, function (aMsgHdr, aMimeMessage) {
  Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper)
  .copyString([
   (aMsgHdr.flags & Components.interfaces.nsMsgMessageFlags.HasRe ? "Re: " : "") + aMsgHdr.mime2DecodedSubject,
   new Date(aMsgHdr.dateInSeconds * 1000),
   aMsgHdr.mime2DecodedAuthor,
   aMsgHdr.mime2DecodedRecipients,
   "",
   aMimeMessage.coerceBodyToPlaintext(gFolderDisplay.displayedFolder).replace(/^\s+/,"").replace(/\s+$/g,"").replace(/\n/g,"\r\n")
  ].join("\r\n"));
  alert("Reply copied");
 }, true);
} else {
 alert("No reply found");
}


I am using IMAP server and I don't know where to find the References header in the source
There is a Message-ID: <1482295362.93038.1403161307842.JavaMail.zimbra@test.eu>

Removing the one code line wont help.

The alternative gives the same error.


The solution was to remove ! from if(!replyMessage || message.date > replyMessage.date)
replyMessage = message;



I just noticed that the scrip copies the replay I made to the sender, but I need to copy the last reply which I got from the sender.
Please help.

Springtime
 
Posts: 68
Joined: November 8th, 2013, 8:59 pm

Post Posted September 17th, 2014, 5:07 am

Searched but didn't find a relevant result - is there a way to open a sub-menu item (ideally under the mouse) using keyconfig? Was wanting to open the History>Recently Closed Tabs sub-menu using a shortcut.

t3l0zvxqIiXuzuH0
 
Posts: 92
Joined: August 17th, 2014, 5:57 am

Post Posted September 19th, 2014, 11:45 am

@Springtime
You can do that with a mouse gesture using Firegestures.

Springtime
 
Posts: 68
Joined: November 8th, 2013, 8:59 pm

Post Posted September 19th, 2014, 3:22 pm

t3l0zvxqIiXuzuH0 wrote:@Springtime
You can do that with a mouse gesture using Firegestures.


Thanks for the suggestion, but was ideally looking for a way to do it with a keyboard shortcut. For clarification by 'under the mouse' I meant the menu being at the mouse's position when the hotkey is activated (not sure if Firefox supports this, I know Opera Presto did this).

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

Post Posted September 21st, 2014, 11:38 am

any response for me?

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

Post Posted September 21st, 2014, 2:57 pm

firefoxuse wrote:they appeared DISABLED

Did you type the shortcut in the "<Disabled>" textbox? Did you use the "Apply" button?

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

Post Posted September 26th, 2014, 10:45 am

morat wrote:
firefoxuse wrote:they appeared DISABLED

Did you type the shortcut in the "<Disabled>" textbox? Did you use the "Apply" button?


I typed the shortcut in the Disabled textbox and it works now marvelously!

thanks!

t3l0zvxqIiXuzuH0
 
Posts: 92
Joined: August 17th, 2014, 5:57 am

Post Posted September 26th, 2014, 2:41 pm

t3l0zvxqIiXuzuH0 wrote:
morat wrote:@t3l0zvxqIiXuzuH0

Try this:

Code: Select all
var selection = getBrowserSelection();
if (!selection) return;
var str = readFromClipboard();
if (str) selection = str + " " + selection;
var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
  getService(Ci.nsIClipboardHelper);
clipboard.copyString(selection);

Perfect. Thanks.

Well, not so perfect after all. It turns out that getBrowserSelection() limits selection to 150 characters. So I changed the first line to this and it seems to work:

Code: Select all
var command = "cmd_insertText";
var controller = document.commandDispatcher.getControllerForCommand(command);
if ( controller && controller.isCommandEnabled(command) )
 { var selection = getBrowserSelection(); }
else
 { var selection = document.commandDispatcher.focusedWindow.getSelection().toString(); }

It still uses getBrowserSelection() in text areas but I use it mostly to select words in a page before a web search, so it works for me.

I gladly accept better ideas. Thanks.

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 3 guests