ngdeleito / easyGestures

A WebExtension for Firefox providing easy to learn gestures through a highly customizable pie menu
https://addons.mozilla.org/en-US/firefox/addon/easygestures-n/
10 stars 1 forks source link

Scripting? #4

Closed seamoonz closed 8 years ago

seamoonz commented 8 years ago

I was dreaming of such an addon. But I need a script that simulates keystroke F2. Also a script to execute files. Could you help it please?

ngdeleito commented 8 years ago

Thank you for your comment!

For simulating an F2 keystroke, I would try to generate a KeyboardEvent with key VK_F2 inside a run script action (see documentation: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent).

For executing files, I am afraid this will not be possible to do inside a run script action unfortunately.

Hope this helps, Nicolás

ngdeleito commented 8 years ago

I don't see your comment on AMO anymore... don't know what happened.

Anyhow, I have looked into it and the following piece of code worked for me for simulating a F2 keystroke inside a run script action:

window.content.document.body.dispatchEvent(new window.KeyboardEvent("keyup", { key: "F2" }));

Good luck, Nicolás