Note: I'm posting a tip to help other tbkeys users.
Use the nsIDOMWindowUtils.sendNativeKeyEvent method to simulate or synthesize a
keypress. The nsIDOMWindowUtils.sendKeyEvent method doesn't work anymore.
Examples:
Send the down arrow key.
Code: Select all
(function () {
var KEYBOARD_LAYOUT_EN_US = {name: 'US', Mac: 0, Win: 0x00000409, hasAltGrOnWin: false};
var WIN_VK_DOWN = 0xe0500028;
window.windowUtils.sendNativeKeyEvent(KEYBOARD_LAYOUT_EN_US, WIN_VK_DOWN, 0, '', '');
})();
Send the Shift+F8 keypress to toggle the thread pane using the
Maximize Message Pane addon.
Code: Select all
(function () {
var KEYBOARD_LAYOUT_EN_US = {name: 'US', Mac: 0, Win: 0x00000409, hasAltGrOnWin: false};
var WIN_VK_F8 = 0x00420077;
var NATIVE_MODIFIER_SHIFT_LEFT = 0x00000100;
var modifiers = 0;
modifiers |= NATIVE_MODIFIER_SHIFT_LEFT;
window.windowUtils.sendNativeKeyEvent(KEYBOARD_LAYOUT_EN_US, WIN_VK_F8, modifiers, '', '');
})();
Send the Ctrl+Shift+I keypress to open the Developer Tools utility.
Code: Select all
(function () {
var KEYBOARD_LAYOUT_EN_US = {name: 'US', Mac: 0, Win: 0x00000409, hasAltGrOnWin: false};
var WIN_VK_I = 0x00000049;
var NATIVE_MODIFIER_CONTROL_LEFT = 0x00000400;
var NATIVE_MODIFIER_SHIFT_LEFT = 0x00000100;
var modifiers = 0;
modifiers |= NATIVE_MODIFIER_CONTROL_LEFT;
modifiers |= NATIVE_MODIFIER_SHIFT_LEFT;
window.windowUtils.sendNativeKeyEvent(KEYBOARD_LAYOUT_EN_US, WIN_VK_I, modifiers, '', '');
})();
French users need to use the KEYBOARD_LAYOUT_FRENCH native keyboard layout object.
German users need to use the KEYBOARD_LAYOUT_GERMAN native keyboard layout object.
Mac users need to use the MAC_VK_ native key code constants. Windows users need to use the WIN_VK_ native key code constants.
The NATIVE_MODIFIER_ modifier constants are the same on Mac and Windows.
Reference
http://searchfox.org/mozilla-esr102/sea ... YOUT_EN_US (see native keyboard layout objects in EventUtils.js)
http://searchfox.org/mozilla-esr102/sea ... IN_VK_DOWN (see native key code constants in NativeKeyCodes.js)
http://searchfox.org/mozilla-esr102/sea ... SHIFT_LEFT (see native modifier constants in nsIDOMWindowUtils.idl)
http://searchfox.org/mozilla-esr102/sea ... &case=true
http://searchfox.org/mozilla-esr102/sea ... &case=true
Similar thread
http://github.com/wshanks/tbkeys/issues/125
Use the nsIDOMWindowUtils.sendMouseEvent method to simulate or synthesize a
mouse click.
Example:
Send a mouse click to focus the message and display the caret when caret browsing.
Code: Select all
(function () {
var browser = window.document.getElementById('messagepane');
var rect = browser.getBoundingClientRect();
var x = rect.left + 10;
var y = rect.top + 10;
var button = 0;
var clickCount = 1;
var modifiers = 0;
window.windowUtils.sendMouseEvent('mousedown', x, y, button, clickCount, modifiers);
window.windowUtils.sendMouseEvent('mouseup', x, y, button, clickCount, modifiers);
})();
Reference
http://searchfox.org/mozilla-esr102/sea ... FIER_SHIFT (see non-native modifier constants in nsIDOMWindowUtils.idl)
http://searchfox.org/mozilla-esr102/sea ... &case=true
Tips:
http://forums.mozillazine.org/viewtopic ... #p14872763