What is the nature of shortcuts of the second kind, how are they created and how do they actually work? How does a developer create a shortcut of this kind for his application?
Related
Running on: MacOS Catalina 10.15.5
I made a Quick Action in Automator and it works just fine. In fact, I've been using it for a few years. The code in the action itself is not the problem, nor is it allowing accessibility/controls in system preferences. My problem is mind-boggling to say the least and I cannot seem to figure it out and thought I'd ask the hive mind.
After making my quick action with AppleScript and making sure the 'workflow receives: no input in any application' as I normal would do, then going in and assigning the shortcut the key 'F13' in System Preferences --> Keyboard --> Shortcuts --> Services, everything seems just great.
In the application I use this shortcut in, if I hover over the application main dropdown and hover over "Services" the item is there and has a shortcut 'F13' associated with it. If I select the shortcut from the dropdown menu, it works PERFECTLY.
Here is the problem, if I hit 'F13' on my keyboard, the service runs 3 times in a row. It's almost as if the system services thinks I want to run that particular item 3x. I have tried a number of different shortcut keys as well (as simple as: F13 and as complicated as: ⌘⌥⌃⇧N) and the shortcut keys did not yield any positive results either.
I have checked everywhere and cannot seem to find why this is happening. Any insight/help would be much appreciated. This is not an AppleScripting issue. It's something with the OS that is causing a triple selection on the services menu item for some reason. It does not seem to be a Key Repeater issue either.
Thanks in advance!
The problem, as best as I can tell, isn't that the workflow is running three times, but that you're getting a series of three security error messages. It seems that when you try to run a service using a keyboard shortcut, the system invokes an xpc service (com.automator.runner.xpc, which is located inside the automator application package), and that service is triggering security alerts because it doesn't have the accessibility rights that are needed for GUI scripting. There is no obvious way to grant the xpc the proper rights (and I suspect that would be an enormous security hole anyway), so that's not workable.
However, there's a workaround. Take your functioning script, copy it into a new Script Editor window, and save it as an application using the 'File Format' pulldown at the lower left of the save window:
Give this application permission to use accessibility features:
System Preferences → Security & Privacy → Privacy → Accessibility
Now create a service in automator that uses the Launch Application action to launch the script application you just created. Assign your keyboard shortcut to that service, and things should work as you like.
Of course, this launches an application, showing it in the Dock and grabbing the foreground momentarily, which can be visually distracting. If you want it to run silently in the background, do the following:
Right-click on the icon for the script app and choose Show Package Contents.
Drill down two levels to find the info.plist file, and open it in TextEdit, BBEdit or some other plain-text editor
Add the following key/value pair to the file (being carful not to break up other key/value groups):
<key>LSUIElement</key>
<true/>
Save the info.plist file, then run the app again; it should be faceless.
I am new to Mac and have been surprised from the absence of keyboard shortcuts for opening applications. According to the instruction (http://support.apple.com/kb/PH3957) :” You can’t define keyboard shortcuts for general purpose tasks such as opening an application or switching between applications”.
In Windows assigning keyboard shortcuts for opening applications is very easy. What is the way in Mac OS?
I think you may want to ask this question on Ask Different instead of stack overflow.
As a preliminary answer, though, a quote from the Use global keyboard shortcuts Help text provided by Apple concerning system keyboard shortcuts:
Note: You can create keyboard shortcuts only for existing menu commands. You cannot *define keyboard shortcuts* for general purpose tasks such as opening an app or switching between apps.
I favor keyboard shortcuts over mouse actions so I'm heavily using keyboard shortcuts with all kinds of applications. Every now and then I'm running into a situation where I assign a keyboard shortcut that has already been used in a different app. Not all apps show warnings when you re-use a combination that has already been used.
Also, since I tend to forget some of the lesser used combinations, it would be nice to find out what has been assigned where.
System Preferences doesn't list all of them, but since my Mac responds to them, there must be some way to get a global list of all assigned keyboard shortcuts.
Does anyone know of a command/script/application that displays them all?
What you want may not be possible. Consider the method by which a application specific system-wide shortcuts may be implemented: event taps. An application can do whatever it wants with an event and never actually register the event with the system. Thus, no application could be written to identify every possible event!
Here is an app that does almost what you want:
http://www.ergonis.com/products/keycue/
It even updates its list when shortcuts are changed.
You can download a list of additional system-wide shortcuts from their site that includes keys not listed anywhere else. But it doesn't show shortcuts for continuously active applications such as Evernote.
Further, you can query and modify hotkeys programmatically:
http://www.theregister.co.uk/2009/02/24/hotkeys_framework2/
(but it still won't know about event taps)
This list of all system shortcuts from Apple is also useful:
http://support.apple.com/kb/HT1343
I've only ever done server, web, and database programming, never any desktop programming. I now want to learn and have a small project I want to attempt, but am not sure which library/framework to use.
I'd like to create a small cross-platform app that runs in the system tray (and whatever the OSX equivalent is), and listens for changes to windows on the Desktop. Specifically:
Windows XP, Vista, 7, Gnome, KDE, OSX. BSD, Android, and/or iOS would be nice too but not required.
Listens for when any window gains focus, loses focus, is opened or closed, or if the window title changes (for example when switching tabs in a tabbed browser). Any other information it can scrape from the window would be useful as well.
Can store these events, preferably in an embedded database like SQLLite.
The lighter-weight the better.
Includes an options GUI accessible via a right-click menu from the system-tray icon.
Preferably FOSS, but if you know any non-FOSS please list too.
Is there a single library or framework that can do all that across multiple platforms? QT? Python? Java? Something else? TIA.
Almost any GUI framework can easily let you know when your own application gains or loses focus (or the other operations you mention). However, listening for these events for other arbitrary applications is definitely platform-specific and may or may not even be possible.
One framework for doing this on Windows is the CBT callback hook. See the question CBT Hook not working in Windows Vista for information about possible limitations on using this technique.
Can someone please remind me how do I toggle between open projects using a keyboard shortcut? I briefly knew how to do this but it has evaporated from my brain and Google is no help.
I don't know what the shortcut is for switching between open projects, but in OS X in general you can use Command + ` (backtick) to cycle among windows of an application.