carlin-q-scott / browser-media-keys

Lets you control many web players using the media keys on your keyboard.
Mozilla Public License 2.0
123 stars 31 forks source link

Add method to manual set hotkey #86

Closed gmelikov closed 6 years ago

gmelikov commented 8 years ago

Some people (like me) doesn't have media buttons, and one method to use this addon is to use any global hotkey app to emulate media buttons.

If there is a method to manually set hotkeys, then any problems with different signals from keyboard (such as #79, #49) may be resolved too by manual hotkey set.

I looked into @Noitidart work on hotkey submodule, and while it would be implemented, there's a way to add manual hotkeys too.

Or maybe better to add this functionality to @Noitidart 's submodule? @Noitidart, what do you think about it?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/37244822-add-method-to-manual-set-hotkey?utm_campaign=plugin&utm_content=tracker%2F7600490&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F7600490&utm_medium=issues&utm_source=github).
Noitidart commented 8 years ago

Do you mean that on the options page we should offer a button that says "Change". And when the user clicks its, it starts listening to the next keyboard input. Then the user is able to set a hotkey. After they press some combo, then it sets that as the hotkey?

If this is what you mean, I can definitely work to add to the submodule a single shot "listening" mode.

gmelikov commented 8 years ago

Yes, exactly. In this way your submodule will be universal.

Noitidart commented 8 years ago

That is a feature I want to add. I don't have time for that right now though. But it is something I very much need in the addons I use this module in. (a monitor screenshot addon, and always on top windows [for not just firefox windows] addon).

I still have to figure out how to use XCB to capture key presses of just the current window. I can use GTK but that is not good, it needs to run on main thread, and I don't like to rely on GTK, as not everyone has it (even though currently if you have Firefox GTK is installed with it).

Noitidart commented 8 years ago

@gmelikov I just set it up for windows mac and linux, but its outside of a submodule as things are all on the mainthread for my first iteration. Try it out please - https://github.com/Noitidart/Topick

Please download that repo, zip it up as xpi, then go to about:topick and then click on "Change" under "System Hotkey".

The hotkey is not registering right now, I just worked on recording the key.

gmelikov commented 8 years ago

@Noitidart when i download repo through zip archive, submodules are empty.

I tried it with git clone, about:topick is empty (if look at page source, it's not empty, i think there is a problem with js on page), there are browser logs:

INITING TAB MainFramescript.js:225
Comm.server.framescript - incoming, payload: Object { method: "callInMainworker", arg: Object, cbid: 1 } Comm.js:226
doing old way MainFramescript.js:331
Comm.client.worker - incoming, payload: Object { method: "fetchCore", arg: undefined, cbid: 7 } Comm.js:473:5
Comm.client.worker - Fullfilled - rez_scope -  Object { core: Object } Comm.js:490:10
Comm.server.worker - incoming, payload: Object { method: null, arg: Object, cbid: 7 } Comm.js:87
doing old way MainFramescript.js:331
Comm.client.framescript - incoming, payload: Object { method: null, arg: Object, cbid: 1 } Comm.js:560
got core in fs MainFramescript.js:227
ok updated core to: Object { addon: Object, os: Object, firefox: Object } MainFramescript.js:229
testing matches about:topick docuri: about:topick MainFramescript.js:243
MATCHING, RELOADING NATIVESHOT PAGE MainFramescript.js:248
doing old way MainFramescript.js:331
page ready, contentWindow.location.href: about:topick MainFramescript.js:148
Comm.server.content - creating worker Comm.js:387
doing old way MainFramescript.js:331
Security Error: Content at about:topick may not load or link to chrome://topick/content/resources/images/icon16.png.
Comm.server.content - attaching listener and posting message, this.listener: function () Comm.js:378
ReferenceError: reference to undefined property e.$$typeof react-with-addons.js:14:19580
ReferenceError: reference to undefined property e.propTypes react-with-addons.js:13:12105
ReferenceError: reference to undefined property t.autobind react-with-addons.js:13:10043
mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create react-redux.js:1:1754
in iprenit app.js:17:2
page ready, contentWindow.location.href: about:topick MainFramescript.js:148
Comm.server.content - creating worker Comm.js:387
Comm.server.content - attaching listener and posting message, this.listener: function () Comm.js:378
Comm.client.content - in handshake Comm.js:709:8
calling fetchCore with hydrant_ex_instructions: Object { filestore_entries: Array[1], addon_info: true } app.js:24:2

web console from about:topick page:

ReferenceError: reference to undefined property e.$$typeof react-with-addons.js:14:19580
ReferenceError: reference to undefined property e.propTypes react-with-addons.js:13:12105
ReferenceError: reference to undefined property t.autobind react-with-addons.js:13:10043
mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create react-redux.js:1:1754
in iprenit app.js:17:2
Comm.client.content - in handshake Comm.js:709:8
calling fetchCore with hydrant_ex_instructions: Object { filestore_entries: Array[1], addon_info: true }
Noitidart commented 8 years ago

@gmelikov that's weird. Please try this XPI i made from the repo. Github didnt allow uploading xpi, so please download this and rename to xpi then install - Topick.zip

gmelikov commented 8 years ago

@Noitidart it worked only in firefox dev. But after clicking "change" it doesn't recognize keyboard, here are the log after about page opened and clicked:

out:blankMainFramescript.js:243
INITING TABMainFramescript.js:225
Comm.server.framescript - incoming, payload: Object { method: "callInMainworker", arg: Object, cbid: 1 }Comm.js:226
Comm.client.worker - incoming, payload: Object { method: "fetchCore", arg: undefined, cbid: 9 }Comm.js:473:5
Comm.client.worker - Fullfilled - rez_scope -  Object { core: Object }Comm.js:490:10
Comm.server.worker - incoming, payload: Object { method: null, arg: Object, cbid: 9 }Comm.js:87
Comm.client.framescript - incoming, payload: <unavailable>Comm.js:560
got core in fsMainFramescript.js:227
ok updated core to: <unavailable>MainFramescript.js:229
testing matches about:blank docuri: about:blankMainFramescript.js:243
in iprenitapp.js:17
page ready, contentWindow.location.href: about:topickMainFramescript.js:148
Comm.server.content - creating workerComm.js:387
Comm.server.content - attaching listener and posting message, this.listener: <unavailable>Comm.js:378
Comm.client.content - in handshakeComm.js:709
calling fetchCore with hydrant_ex_instructions: <unavailable>app.js:24
Comm.server.content - incoming, payload: <unavailable>Comm.js:334
Comm.server.framescript - incoming, payload: Object { method: "callInMainworker", arg: Object, cbid: 2 }Comm.js:226
Comm.client.worker - incoming, payload: Object { method: "fetchCore", arg: Object, cbid: 10 }Comm.js:473:5
Comm.server.worker - incoming, payload: Object { method: "getAddonInfo", arg: undefined, cbid: 1 }Comm.js:87
Comm.client.worker - incoming, payload: Object { method: null, arg: Object, cbid: 1 }Comm.js:473:5
Comm.client.worker - Fullfilled - rez_scope -  Object { core: Object, hydrant_ex: Object }Comm.js:490:10
Comm.server.worker - incoming, payload: Object { method: null, arg: Object, cbid: 10 }Comm.js:87
Comm.client.framescript - incoming, payload: <unavailable>Comm.js:560
Comm.client.content - incoming, payload: <unavailable>Comm.js:668
aArg in app.js: <unavailable>app.js:26
formatStringFromNameCore error: <unavailable> args: month.1.name dateFormat undefinedapp.js:169
focused!!!!!!app_options.js:26
in shouldUpdateHydrantExapp_options.js:33
done shouldUpdateHydrantExapp_options.js:71
formatStringFromNameCore error: <unavailable> args: month.1.name dateFormat undefinedapp.js:169
Comm.server.content - incoming, payload: <unavailable>Comm.js:334
Comm.server.framescript - incoming, payload: Object { method: "startRecording", arg: undefined, cbid: 3 }Comm.js:226
its in listening modeapp_options.js:236

- 29 08 2016 - 16 51 49

Noitidart commented 8 years ago

Interesting, thanks much for that test. I'll look into this some more and share with you updates. To verify, the same XPI does not work on any version of Firefox other thne Dev? Which is Fx 50?

gmelikov commented 8 years ago

Doesn't work in ESR 45.3.0, works in 50.0a2 (2016-08-29).

Noitidart commented 8 years ago

Crap I downloaded ESR 45.3.0 and MessageChannel api (Comm submodule) is not working there between framescript and content. Do you have Firefox 46 or release channel by any chance, if you can test on that that would help.

gmelikov commented 8 years ago

I have 48, about page opens, but change hotkey isn't working too, page console:

in iprenitapp.js:17:2
Comm.client.content - in handshakeComm.js:709:8
calling fetchCore with hydrant_ex_instructions: Object { filestore_entries: Array[1], addon_info: true }app.js:24:2

Comm.client.content - incoming, payload: Object { method: null, arg: Object, cbid: 1 }Comm.js:668:5
aArg in app.js: Object { core: Object, hydrant_ex: Object }app.js:26:3
focused!!!!!!app_options.js:26:2

in shouldUpdateHydrantExapp_options.js:33:2
done shouldUpdateHydrantExapp_options.js:71:2
its in listening modeapp_options.js:236:4
focused!!!!!!
Noitidart commented 8 years ago

Lets ignore the ESR issue for now, I think that's a bug in Firefox i have to find and work around.

Can you chat on skype about this bug hotkey issue not recording?

In the about page can you type in Ctrl + Shift + K and then tyep in core.os.mname and tell me what that logs.

And also can you type in core.addon.l10n and if "date" key is there what is in that please?

On Mon, Aug 29, 2016 at 7:55 AM, George Melikov notifications@github.com wrote:

I have 48, about page opens, but change hotkey isn't working too, page console:

in iprenitapp.js:17:2 Comm.client.content - in handshakeComm.js:709:8 calling fetchCore with hydrant_ex_instructions: Object { filestore_entries: Array[1], addon_info: true }app.js:24:2

Comm.client.content - incoming, payload: Object { method: null, arg: Object, cbid: 1 }Comm.js:668:5 aArg in app.js: Object { core: Object, hydrant_ex: Object }app.js:26:3 focused!!!!!!app_options.js:26:2

in shouldUpdateHydrantExapp_options.js:33:2 done shouldUpdateHydrantExapp_options.js:71:2 its in listening modeapp_options.js:236:4 focused!!!!!!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/carlin-q-scott/browser-media-keys/issues/86#issuecomment-243148629, or mute the thread https://github.com/notifications/unsubscribe-auth/AGE8iSsgrkgN1fjaNVtjdAtNE7we84urks5qkvLNgaJpZM4JsN-U .

gmelikov commented 8 years ago

In the about page can you type in Ctrl + Shift + K and then tyep in core.os.mname and tell me what that logs.

"gtk"

And also can you type in core.addon.l10n and if "date" key is there what is in that please?

Object { main: Object, dateFormat: Object } (it doesn't have "date" key).

Yes, i can chat without audio in skype, "georgemelikov".

I tested on dev firefox.

Noitidart commented 8 years ago

Interesting thanks for that. I messaged you on skype quite a bit, are you not getting my messages:

Noitidart commented 8 years ago

@gmelikov I release Topick here - https://addons.mozilla.org/en-US/firefox/addon/topick/

If you could please try it out and leave a review that would be awesome, that will help get me some more users there :)

If you can leave me notes here on Github or on Topick repo about how the key recording worked for you that would be awesome. (like for instance how holding Shift + Something makes it be the shifted char). It will help me when making a submodule out of it.

gmelikov commented 8 years ago

@Noitidart about page still doesn't work in ESR 46. Tried on fresh firefox - on install got

It is most likely that this key combination is already in use by another application. Find that app, and make it release this hotkey. Possibly could be in use by the "Global Keyboard Shortcuts" of the system - http://i.imgur.com/cLz1fDs.png

Details: Was not able to register the code_os of 38 on grabwin of 244. Other info: grabwins: 244 codes_os: 38 code: 97

Offending Hotkey Combination: meta + shift + A (Capslock:Off, Numlock:Off)

Change hotkey works, addon works!

Noitidart commented 8 years ago

Thanks so much for that test! I seriously appreciate it! Im working on landing jscSystemHotkey now to Meida Keys :)

Noitidart commented 7 years ago

@gmelikov may you please try the attached. It has windows and linux support. It allows setting your own hotkeys to do anything.

To create a command that sends keys, you would do:

callInExe('sendSystemKey', 'KEYCODE_HERE');

Here is a list of all the keycodes that are supported - https://gist.github.com/Noitidart/8c5874cb019a48ae69b275bb4dcb8907

For instance this is how I send volume down on windows - http://i.imgur.com/3BLpB8O.png

trigger-v1.0-prerelease.zip

gmelikov commented 7 years ago

@Noitidart firefox says that it's incompatible with my version (50.1.0).

Noitidart commented 7 years ago

@gmelikov Oh yes, excuse that please, it needs Firefox 52 please. It is using Embeded WebExtension so it's future proof. :)

gmelikov commented 7 years ago

image

gmelikov commented 7 years ago

image

Noitidart commented 7 years ago

Oh my gosh thanks so much for the awesome feedback, screenshots are super helfpul! I will take a look at it. :)

Noitidart commented 7 years ago

@gmelikov this version outputs info to log on error, may you please try this one: trigger-v1.0-prerelease-debug.zip

gmelikov commented 7 years ago

image

Noitidart commented 7 years ago

@gmelikov may you please click on the arguments: Arguments {0: Object, ... this will open variable viewer. Then can you please share a screenshot of what the variable viewer shows. Please look for entry called something like "error". Would you be available sometime to chat over skype or whatever is good for you?

gmelikov commented 7 years ago

image I'm in skype.

carlin-q-scott commented 6 years ago

I've released v2.1 which allows you to set custom key combos for the media events. https://addons.mozilla.org/en-US/firefox/addon/media-keys/versions/?page=1#version-2.1.0

ghost commented 6 years ago

@carlin-q-scott would you consider supporting pre 2.0 version? i am not interested in upgrading firefox until the global issue is fixed

carlin-q-scott commented 6 years ago

@cup the code to provide this feature in v1 is too different and more complicated; so I'd prefer to spend my time helping Mozilla implement global support in Firefox Quantum https://bugzilla.mozilla.org/show_bug.cgi?id=1411795.