Mac OSX DDHotKey for Play/FF/Rewind Buttons - macos

I'm working on an OSX app with DDHotKeyCenter to control youtube/pandora song playbacks and would like to use the Mac play/pause, rewind, and FF buttons; however, they only seem to be accessible by calling the function key that they are mapped to (e.g., 'play' button maps to F8, so user has to hit "fn"+play/F8 button). Ideally, I'd like the user to just be able to hit play instead of having to do a combo.
Is there any way to hook into the play/rewind/FF buttons without the F8 keys? Creative solutions welcome! I'm coming from iOS background so OSX is a bit new to me..
Thanks!

Whether the hardware buttons require the use of the "fn" key or not is controlled by user preferences. See System Preferences > Keyboard pane > Keyboard tab > Use all F1, F2, etc. keys as standard function keys. If that is checked, then the F8 key produces a key event for, well, the F8 key. In order to access the hardware function (e.g. Play/Pause), the user has to hold down "fn".
If that preference setting is not checked, then the behavior is reversed. The F8 key does Play/Pause by default and the user has to hold down "fn" to get a key event.
By the way, third-party keyboards can't access the hardware functions in the same way that Apple keyboards do. So, don't write an app that depends on them being available.
The hardware functions can't be trapped as hot keys. They are intercepted at a low level by the keyboard driver. I have a vague recollection of some very hacky approach to hijacking them, but it won't work to treat them as hot keys.
So, what you're probably finding is that you're able to set up F8 as a hot key for your app's functions, but, since your preference settings are configured so that the F8 key event is only generated when you press fn+F8, you have to use that combo. Pressing the F8 key by itself is generating a hardware function operation which is not visible as a key event.

Related

How to change the functionality of PrtSc (PrintScreen) key?

I wrote a little program that uses the PrtSc key as a replacement for pressing / clicking the middle mouse key.
My program uses the GetAsyncKeyState API function to scan the PrtSc.
It works fine.
The problem is that the original functionality of PrtSc continues to work also.
So, as long as PrtSc is pressed, screenshots of the desktop are being made.
After a brief moment, this leads to some hickups and delays in my screen repainting.
So I would like to turn off the 'screenshot function' of PrtSc.
I tried this method of adding a registry key to change the scan code.
disable the printscreen keyboard option from windows
But this makes the PrtSc key pretty much 'disappear' for Windows.
In the sense that GetAsyncKeyState also does not see the keypresses anymore.
Does anybody know of a way to 'detach' the screenshot functionality from PrtSc, but in such a way that pressing PrtSc still generates keycodes ...?
I have a work-around for now.
Still interested in the answer to my question though...
Work-arounds (two):
I am using the Tab key instead of the PrtSc key in my program. Not entirely happy with this, since it messes with the Tab action when entering text.
Using key remapping in AutoHotkey (that I was already using)
I remap the Tab key to Middle Mouse Button, but only for the program for which I need this:
#IfWinActive "My CAD software"
*Tab::MButton
#IfWinActive

How can my Cocoa app receive global keyboard events even if it doesn't have focus?

I'm building a little app which needs to recognize if certain keys on the keyboard were pressed. In this case the arrow keys. The app must take action when these keys get pressed, even if it's not the frontmost and has no focus.
Is this possible to do? What would I have to do to receive these keyboard events no matter where they happen?
You do this by registering a hotkey using Carbon's RegisterEventHotKey function. There are also open source libraries available that make this easier, for example SGHotKeysLib.

Activate Item on Button Press or Button Release

I have a simple GUI that I am developing for an embedded system. The menus can be navigated with the up/down keys and an item can be activated by pressing a confirm key. Presently there are no double presses or long presses planned, but they might be implemented in future releases. Right now the keys are processed on key release. I like this configuration, but could there be a reason why I would want to process a key on button press instead? Any reason why someone has a preference over key press or key release?
I'd go for key press, because it's the result of the user's desire to make something happen, and it's happening now.
Some users may move more slowly than others, so to only act on release of the key means delaying the user's intention, which goes against the UI principle of giving instant feedback for user actions.
What's your reason for preferring key release?
Incidentally, if these are actual physical switches, don't forget to do some debouncing in software. Jack Ganssle's Guide to Debouncing goes into a lot of detail on how to do this.

How can I detect whether the alt/option key is down in GTK on Mac OS X?

I want to detect whether the alt/option key is pressed during a mouse drag in GTK on Mac OS X. I am using pygtk. Normally, holding down alt would add MOD1_MASK to event.state, but alt does affect event.state at all. In key press events alt shows up as gtk.keysyms.kana_switch, but this is not sufficient for my purposes since the user might press alt in a different application and switch to mine by clicking.
Is there an available setting that would cause alt/option to show up as a modifier in event.state? Alternatively, is there a way of detecting whether a key is currently down even if the key down event went to a different application?
I think you should use gtk.accelerator_get_default_mod_mask()
http://library.gnome.org/devel/gtk/unstable/checklist-modifiers.html

Reenable (windows)keys after another program has disabled it

Quake3 has disabled the alt and windows keys.
Is there any way to reenable them even while quake3 is running? I need those keys even while I have the game open.
They way I think it works is that the game registers a hotkey using RegisterHotKey and then sets the handled property to true every time the key is pressed.
So if you use UnRegisterHotkey on these keys on the quake3-window I guess the keys will start working again. The problem is that you have no idea what hotkey-id the disabled keys have.
Is there any way to enumerate the hotkeys that a window has registered to get all the hotkey-ids?
It's quite likely that Quake3 doesn't bother with RegisterHotKey at all, but instead uses DirectInput. In that case, it quite likely holds the keyboard in exclusive mode, which explains why the Windows key doesn't work - it's the OS which disables it. Quoting MSDN : "In exclusive mode, the Windows logo key is always disabled."

Resources