MozillaZine

keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
bigfootnlc
 
Posts: 8
Joined: June 10th, 2016, 8:51 am

Post Posted June 29th, 2018, 9:51 am

I'm looking for a way to automate the execution of a 'macro' created long ago that's assigned to Ctrl-t via Dorando keyconfig. I'd like to be able to make this 'macro' execute every so many seconds without having to hit Ctrl-t all of the time.

Is there a crontab, or some other sort of macro automation for Thunderbird? I've been looking but can't find anything. Maybe I'm blind!

Thanks!

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

Post Posted June 29th, 2018, 9:11 pm

@bigfootnlc

Here is a countdown alarm example using the setInterval method. The setInterval method calls a function at specified intervals.

The keyboard shortcut starts (or stops if already started) the countdown. The alarm sounds when the countdown shows 00h 00m 00s in the status bar.

Code: Select all
/* absolute examples
      const target = "Jul 3 2018 3:30:00 PM";
      const target = "2018, 7, 3, 15:30:00";
      const target = date(0) +  "6:00:00 PM"; // today
      const target = date(1) + "12:30:00 AM"; // tomorrow
      const target = next(0);                 // next on the hour
      const target = next(15);                // next quarter past the hour
      const target = next(30);                // next half past the hour
      const target = next(45);                // next quarter to the hour
   relative examples
      const target = [1, 15, 0];              // 1 hour, 15 minutes
      const target = [0, 3, 30];              // 3 minutes, 30 seconds
      const target = [0, 0, 10];              // 10 seconds
*/
const target = [0, 0, 10];
function date(increment) {
  return new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + increment).
    toDateString() + String.fromCharCode(32);
}
function next(minute) {
  if (minute > 0 && minute < 60) {
    return new Date(Math.floor((new Date().getTime() + (60 - minute) * 60000) / 3600000) * 3600000 + minute * 60000).
      toString();
  } else {
    return new Date(Math.floor((new Date().getTime() + (60 -      0) * 60000) / 3600000) * 3600000 +      0 * 60000).
      toString();
  }
}
function absolute(s) {
  return new Date(s);
}
function relative(hour, minute, second) {
  return new Date(beginTime.getTime() + hour * 3600000 + minute * 60000 + second * 1000);
}
function count(t0, t1) {
  var millisecond = t1.getTime() - t0.getTime();
  var hour = Math.floor(millisecond / 3600000);
  var minute = Math.floor(millisecond % 3600000 / 60000);
  var second = Math.floor(millisecond % 3600000 % 60000 / 1000);
  if (t0 > t1) {
    hour = 0; minute = 0; second = 0;
    clearInterval(that.tick); delete that.tick;
    removeElementById(uid);
    sound.play(ios.newFileURI(file));
    Components.utils.import("resource://gre/modules/ctypes.jsm");
    var lib = ctypes.open("kernel32.dll");
    var beep = lib.declare("Beep", ctypes.winapi_abi, ctypes.bool, ctypes.uint32_t, ctypes.uint32_t);
    var ret = beep(800, 200);
    lib.close();
  }
  hour = (hour < 10 ? "0" : "") + hour;
  minute = (minute < 10 ? "0" : "") + minute;
  second = (second < 10 ? "0" : "") + second;
  return hour + "h " + minute + "m " + second + "s";
}
var uid = "__unique_identifier_" + this.id;
var ios = Components.classes["@mozilla.org/network/io-service;1"].
  getService(Components.interfaces.nsIIOService);
var sound = Components.classes["@mozilla.org/sound;1"].
  getService(Components.interfaces.nsISound);
var file = Components.classes["@mozilla.org/file/local;1"].
  createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("C:\\WINDOWS\\Media\\notify.wav");
if (this.tick) {
  clearInterval(this.tick); delete this.tick;
  removeElementById(uid);
} else {
  var that = this;
  var beginTime = new Date();
  var endTime;
  if (target.constructor == String) {
    endTime = absolute(target);
  } else {
    endTime = relative(target[0], target[1], target[2]);
  }
  removeElementById(uid);
  const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  var statusBar = document.getElementById("status-bar");
  var statusBarPanel = document.createElementNS(kXULNS, "statusbarpanel");
  statusBarPanel.setAttribute("id", uid);
  statusBarPanel.setAttribute("tooltiptext", endTime.toLocaleString());
  statusBar.appendChild(statusBarPanel);
  this.tick = setInterval(function() {
    var currentTime = new Date();
    statusBarPanel.setAttribute("label", count(currentTime, endTime));
  }, 10);
}
function removeElementById(id) {
  var element = document.getElementById(id);
  if (element) {
    element.parentNode.removeChild(element);
  }
}

What is the macro?

bigfootnlc
 
Posts: 8
Joined: June 10th, 2016, 8:51 am

Post Posted July 2nd, 2018, 6:59 am

Here's the macro:

MailOfflineMgr.toggleOfflineStatus();

// select a folder
var targetUri = "mailbox://nobody@Local%20Folders/Sent";
var targetFolder = MailUtils.getFolderForURI(targetUri);
gFolderTreeView.selectFolder(targetFolder);

MailOfflineMgr.toggleOfflineStatus();

// select a folder
var targetUri = "mailbox://nobody@Local%20Folders/Inbox";
var targetFolder = MailUtils.getFolderForURI(targetUri);
gFolderTreeView.selectFolder(targetFolder);

goDoCommand("cmd_getMsgsForAuthAccounts");


I have a situation in my Thunderbird where it does not update properly with the IMAP server. I've tried all kinds of things to resolve it, this is the work-around created, was to hit Ctrl-t every so often. I'd like to be able to automate this so it happens ever few minutes automatically.

Thanks!

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

Post Posted July 2nd, 2018, 10:02 am

@bigfootnlc

Try this:

Code: Select all
var uid = "__unique_identifier_" + this.id;
if (this.tick) {
  clearInterval(this.tick); delete this.tick;
  removeElementById(uid);
} else {
  removeElementById(uid);
  const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  var statusBar = document.getElementById("status-bar");
  var statusBarPanel = document.createElementNS(kXULNS, "statusbarpanel");
  statusBarPanel.setAttribute("id", uid);
  statusBarPanel.setAttribute("label", "Workaround");
  statusBarPanel.setAttribute("tooltiptext", "Workaround for a bug");
  statusBar.appendChild(statusBarPanel);
  this.tick = setInterval(function() {

    // Workaround
    MailOfflineMgr.toggleOfflineStatus();
    var targetUri = "mailbox://nobody@Local%20Folders/Sent";
    var targetFolder = MailUtils.getFolderForURI(targetUri);
    gFolderTreeView.selectFolder(targetFolder);
    MailOfflineMgr.toggleOfflineStatus();
    var targetUri = "mailbox://nobody@Local%20Folders/Inbox";
    var targetFolder = MailUtils.getFolderForURI(targetUri);
    gFolderTreeView.selectFolder(targetFolder);
    goDoCommand("cmd_getMsgsForAuthAccounts");

  }, 300000); // 300000 milliseconds or 300 seconds or 5 minutes
}
function removeElementById(id) {
  var element = document.getElementById(id);
  if (element) {
    element.parentNode.removeChild(element);
  }
}

The keyboard shortcut starts (or stops if already started) running the workaround every 5 minutes.

bigfootnlc
 
Posts: 8
Joined: June 10th, 2016, 8:51 am

Post Posted July 3rd, 2018, 4:03 pm

I will give that a try and let you know how it works.

Thanks, again!!

bigfootnlc
 
Posts: 8
Joined: June 10th, 2016, 8:51 am

Post Posted July 9th, 2018, 1:02 pm

Hey, Morat! That seems to be doing the trick nicely. Thanks!!

ultramage
 
Posts: 18
Joined: September 18th, 2009, 3:21 am

Post Posted July 14th, 2018, 12:48 am

Hi, I installed Dorando keyconfig and proceeded to disable most shortcuts. A lot of them now say "Restart required" instead of the corresponding shortcut sequence. This text doesn't go away when I press Reset, nor does it go away after a restart. Now I can't even tell what the original sequence was. I don't think the UI is supposed to behave like this.

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

Post Posted July 14th, 2018, 7:40 am

@bigfootnlc

You're welcome.

@ultramage

Are you using Firefox ESR or Thunderbird? Are you using the current release? What is the version of the extension?

It works here in Thunderbird.

* open keyconfig window

Name: Address Book, Shortcut: Ctrl+Shift+B

* select shortcut
* click "Disable" button

Name: Address Book, Shortcut: <Disabled>

* test: shortcut disabled
* click "Reset" button

Name: Address Book, Shortcut: Restart required

* test: shortcut still disabled
* restart application
* open keyconfig window

Name: Address Book, Shortcut: Ctrl+Shift+B

* test: shortcut enabled

Keyconfig 2018.1 by trlkly
Thunderbird 52.9.1
Window 7 SP1 32-bit

When I disable the shortcut for the Address Book, the extension creates a preference in about:config like so.

Preference Name: extensions.dorandoKeyConfig.main.key_addressbook
Preference Value: !][][

If I reset the preference in about:config and restart, then the shortcut is enabled. Maybe something is wrong with the prefs.js file.

Maybe the application didn't exit properly. Try exiting the application, then kill the thunderbird.exe process in the task manager.

Try the standard diagnostic for extension issues. There may be a conflict with another extension.

http://kb.mozillazine.org/Standard_diagnostic_-_Firefox
http://kb.mozillazine.org/Standard_diagnostic_-_Thunderbird

Support site for trlkly's extension to report issues
http://github.com/trlkly/dorando-keyconfig/issues

ultramage
 
Posts: 18
Joined: September 18th, 2009, 3:21 am

Post Posted July 14th, 2018, 10:19 am

@morat I have been using thunderbird 52.7.0 with addon version 2018.1.
First thing I did was update to 52.7.2, now the stuck entries are gone from both the UI and prefs.js, and I was able to successfully set them. No restart required on any of them.

One small UI problem I still see is that pressing Reset always puts in "Restart required", even though it wasn't required to set it. And I still need to restart to find out what the default hoteky was on the entries that I disabled.

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

Post Posted July 14th, 2018, 3:01 pm

ultramage wrote:One small UI problem I still see is that pressing Reset always puts in "Restart required", even though it wasn't required to set it. And I still need to restart to find out what the default hotkey was on the entries that I disabled.

That's normal behavior.

Keyboard shortcuts
http://support.mozilla.org/en-US/kb/keyboard-shortcuts

RobertJ
Moderator

User avatar
 
Posts: 10678
Joined: October 15th, 2003, 7:40 pm
Location: Chicago IL/Oconomowoc WI

Post Posted August 18th, 2018, 3:16 pm

.
I'm using this in TB60. Presently once an email is selected and shows in the message pane, there is no way to deselect it so the message pane is blank.

I can do it via Edit > Select > Starred Messages (If there are none starred) but that does not show up in the keyconfig preference pane.

Seems ridiculous that TB has no way to deselect a selected email.

Any thoughts using keyconfig or any other magic?

Thanks

.
FF 63.0.1 - FF 64b8 - FF 65a - TB 60.3 - Mac OSX 10.13.6
Computers I've used: IBM 7094/UNIVAC 1108/IBM 360/DEC PDP11/DEC VAX-11 780/DEC VAXstation 8000/Sun SPARCstation 2/Mac from 1984 to 2018

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

Post Posted August 18th, 2018, 6:23 pm

@RobertJ

Try these:

Code: Select all
var treeBoxObject = document.getElementById("threadTree").treeBoxObject;
treeBoxObject.view.selection.clearSelection();
treeBoxObject.view.selection.currentIndex = -1;

Code: Select all
var treeBoxObject = document.getElementById("threadTree").treeBoxObject;
treeBoxObject.view.selection.select(0);
treeBoxObject.ensureRowIsVisible(0);
treeBoxObject.invalidate();
treeBoxObject.view.selection.clearSelection();
treeBoxObject.view.selection.currentIndex = -1;
document.getElementById("folderTree").focus();

Reference
http://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeBoxObject
http://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeView
http://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsITreeSelection

P.S.

I noticed that the menulist[id="window-list"] button fails to open the popup in the keyconfig dialog.

Keyconfig 2018.1
Thunderbird Portable 60.0
Windows 7 SP1 32-bit

RobertJ
Moderator

User avatar
 
Posts: 10678
Joined: October 15th, 2003, 7:40 pm
Location: Chicago IL/Oconomowoc WI

Post Posted August 19th, 2018, 7:56 am

.
morat, Thanks.

Have screwed around and tried to add a key in keyconfig with that code but can'r seem to do it.

Any guidance would be helpful.

.
FF 63.0.1 - FF 64b8 - FF 65a - TB 60.3 - Mac OSX 10.13.6
Computers I've used: IBM 7094/UNIVAC 1108/IBM 360/DEC PDP11/DEC VAX-11 780/DEC VAXstation 8000/Sun SPARCstation 2/Mac from 1984 to 2018

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

Post Posted August 19th, 2018, 8:54 am

@RobertJ

Instructions:

1. install extension and restart

http://addons.thunderbird.net/thunderbird/addon/dorando-keyconfig/

2. tools > keyconfig
3. select a window in the dropdown window list
4. add a new key
5. type a command in the /* CODE */ box, e.g. alert("test");
6. type a shortcut in the <Disabled> box, e.g. Ctrl+Shift+!
7. apply
8. close

More info: viewtopic.php?p=13754363#p13754363

RobertJ
Moderator

User avatar
 
Posts: 10678
Joined: October 15th, 2003, 7:40 pm
Location: Chicago IL/Oconomowoc WI

Post Posted August 19th, 2018, 9:29 am

morat wrote:@RobertJ

Try

Code: Select all
var treeBoxObject = document.getElementById("threadTree").treeBoxObject;
treeBoxObject.view.selection.clearSelection();
treeBoxObject.view.selection.currentIndex = -1;


With your instructions and that code I can now deselect an email using a key shortcut.

Thank you. Much appreciated!

.
FF 63.0.1 - FF 64b8 - FF 65a - TB 60.3 - Mac OSX 10.13.6
Computers I've used: IBM 7094/UNIVAC 1108/IBM 360/DEC PDP11/DEC VAX-11 780/DEC VAXstation 8000/Sun SPARCstation 2/Mac from 1984 to 2018

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 3 guests