On a Mac, I'd like to have a keyboard shortcut to open Google Chrome. I know how to set a keyboard shortcut in the system preferences, however I'm unsure how to script it and hook it up.
Is this possible through AppleScript?
If you don't want to use any third party applications you need to create a service and assign it a shortcut.
Open Automator and select Service. You want it to look like the following :
Save it to its default location. ie ~/Library/Services
Open System Preferences --> Keyboard --> Keyboard Shortcuts. Enable the service and assign it a shortcut.
Shortcuts for Automator services might not always work until the service has been selected once from the menu bar. And they won't be available in applications that don't have a Services menu. There's usually also a noticable delay before they are run.
Using a third party application like Alfred or Apptivate would probably be a better idea.
Another option would be assign shortcuts to AppleScripts like this:
tell application "iTunes"
reopen
activate
end tell
Not with AppleScript alone -- there's no way to bind a keyboard shortcut to execute an arbitrary command.
Instead of writing something yourself, you may want to take a look at some existing launcher applications, like Butler, Spark, or Quicksilver.
Here is a trick.
Use Ctrl + ↑ to create a new desktop, say desktop2, and drag chrome application into that new desktop.
Open the keyboard preference pane, switch to the shortcut tab, and select mission control to assign a key to that desktop2. Now you can switch to chrome use that key.
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 was wondering if there was a way to set a keyboard shortcut to send terminal to the back, behind other windows and then back to the front. Cmd-tab is the only way I can think of, but not a good option as I often have many windows of the same application.
You can do it via Hotkey option.
Goto Preferences -> Keys tab -> Hotkey section -> Set a shortcut key combination.
By this, when you are in the other application, the same shortcut in application level will not work.
For instance, if you set CMD+SHIFT+J as the hotkey, now if you switch to chrome, then CMD+SHIFT+J will not open downloads page in Chrome. It switches back to the iTerm window.
I am very new to applescript, but was wondering if it is possible to open applications to different desktops "spaces" using applescript. I have found how to launch applications, but don't know how to assign them to different desktops. Basically I am looking to open;
Outlook - Desktop 1
Skype - Desktop 1
Safari - Desktop 2
Onenote - Desktop 3
Thanks for any help, I really appreciate it.
Last system versions do not include any scripting of spaces. the only thing you can now do is to assign, in system preferences, shortcut keys to switch to a space, and once done, launch applications you want to.
To simulate action keys in Applescript, use system event "keystroke" instruction.
Easy: start these applications, one by one, in your "chosen" space, click on and hold Dock's icon, move cursor to "Options" (below), select this one (of three) options:
– Current desktop (or: this desktop, or similar)
… which from now on will always open THIS application in THIS space.
There is no programmatic way in AppleScript to instruct your Mac to switch spaces/workspaces or even to return the identity (number) of the current desktop.
Switching may happen, though, if the relevant option in System Preferences, Mission Control, is set.
(Indirectly, comparing a desktop "picture" to a user-defined list empowers a script to get its "number".)
How can I unbind Command-Control-Space from Mac OS X 10.9?
This shortcut shows Special Characters table and conflicts with my Emacs key binding, and I couldn't disable it from System Preference->Keyboard->Shortcuts.
Thanks.
At least on macOS Sierra to macOS Big Sur ⌃Space is the default binding for Select the previous input source which is on by default (even if only one input source is activated).
You can free it by:
Open System Preferences
Go to Keyboard > Shortcuts > Input Sources
Untick "Select the previous input source"
Afterwards, you should be able to bind it as expected.
You can create custom keyboard shortcuts for most app's menubar choices in System Preferences. If a desired key combination is losing precedence to a default shortcut that you don't use and can't easily disable, simply override it with a new, unobtrusive shortcut.
Open System Prefs / Keyboard / Shortcuts. Select App Shortcuts from the left pane. Toggle the All Applications category's triangle in the main window to point downward (if it's not open already).
If there's an item named Emoji & Symbols* shown there, then click its shortcut combination and enter a new shortcut (such as option-shift-command-t, in this case).
If there's not an item named Emoji & Symbols under All Applications, click the + button at the bottom, type or copy-paste Emoji & Symbols, and then enter a new keyboard shortcut (option-shift-command-t, or anything really). This will free the control-command-space combination for you to use as a specialized shortcut elsewhere.
To remove your custom shortcut, just click to highlight it in the main window of this preference pane, and click the – button at the bottom. The custom shortcut will disappear and the default action will resume.
*Note: On versions older than Mac OS 10.10.3, the menu item is called Special Characters… instead of Emoji & Symbols.
I don't know of any way to disable this, but an alternative option might be to create a shortcut for the app you want to use that in. I created a Command-Control-Space shortcut for Chrome and now Command-Control-Space doesn't bring up the special character palette anymore in Chrome.
failing that you may be better off asking in Apple Stackexchange
OK, completely noob question I should be able to figure out but I am stuck.
I have a small program that I want to run in Windows 7 with a keyboard shortcut. Selected Start -> Program In Question -> Right Click -> Send to (Create Shortcut on Desktop).
I want to add a keyboard shortcut to this, so I right click on the desktop shortcut and click properties. Now I only have the following tabs: General, Security, Details, Previous Versions. No option for Shortcut.
So, how do I create a custom keyboard shortcut from this desktop shortuct?
Thanks!
It sounds like you made a folder shortcut, if it is a folder you won't have a shortcut tab, try it again but this time click the program you wanted to make a shortcut and see if it is just a folder that has a different icon. (If it expands in your start menu then it was a folder.)