There is no need to “dis” able all the other macros.
If the hotkey combination is unique, the macro will execute.
If there are two “LIVE/enabled” macros with the same hotkey, Keyboard Maestro will display a small window and ask you which one you want to execute. (This can actually be useful as I have a set of macros I do not use often ALL with the same hotkey combination).
a: Renable all your other macros
b: I assume that you can run Chrome from the dock or the application folder
c: add a display message at the start of the macro to show you are running the macro OK, this is a useful debug technique.
d: create another macro to use openurl with chrome. (I have used CTL+OPT+CMD+G a hot key), change the display prompt
e: add “the status menu is selected” as well as the hot-key as this is another way to check you are activating the macro
(the macro will be listed as a dropdown for the Keyboard Maestro icon in your top menu bar)
The above should show Chrome running on you macbook.
Does this solve your problem? If not, then I still do not understand why you were typing “C”
I have a shortcut to open google email. But the problem is that it opens a
new tab every time I use it.
I want it to go to the tab for Mail who is lying there on top together with
google calendar, my disk and so on. Open it again.
Can you give me that?
Geir
[image: Innebygd bilde 1]
You will need to write some AppleScript to ask Chrome for the list of tabs (or even the list of all windows, and then list of all tabs in each window) and find the one that has the right URL. Then if found, bring that to the front and select it, otherwise open a new URL.
Alternative: You could try a Chrome add-on that manages tabs. Your email could always be Tab position 1, and then you could just switch to Chrome and use Keyboard Maestro to select the correct tab.
This was a bit pesky to write due to a bug in OSX affecting changing the index of windows in an application, but it's working.
The script is run from an 'Execute AppleScript' Action in Keyboard Maestro.
It will run faster if you save it as an AppleScript FILE using the Applescript Editor (pre-Yosemite) or the Script Editor (Yosemite) — then run it as a script file instead of as a text-script.
-Chris
-----------------------------------------------------------------
# Auth: Christopher Stone <scriptmeister@thestoneforge.com>
# dCre: 2015/05/14 12:30
# dMod: 2015/05/14 13:21
# Appl: Google Chrome, System Events
# Task: Bring Chrome Tab with Gmail to front if it exists - otherwise open Gmail in new window.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Google_Chrome, @System_Events, @GMail, @Open, @Switch, @Front
-----------------------------------------------------------------
set _win to false
tell application "Google Chrome"
set {idList, urlList} to {id, URL} of every tab of every window
end tell
set AppleScript's text item delimiters to return
if (urlList as text) contains "https://mail.google.com/mail/" = true then
set theWin to 1
repeat with i in urlList
set theTab to 1
repeat with n in i
if n starts with "https://mail.google.com/mail/" then
set {_win, _tab} to {theWin, theTab}
end if
set theTab to theTab + 1
end repeat
set theWin to theWin + 1
end repeat
end if
if _win ≠ false then
tell application "System Events"
if quit delay ≠ 0 then set quit delay to 0
tell process "Google Chrome"
perform action "AXRaise" of window _win
end tell
end tell
tell application "Google Chrome"
tell front window to set active tab index to _tab
end tell
else
tell application "Google Chrome"
set newWin to make new window
tell newWin to set URL of active tab to "https://mail.google.com/mail/u/0/?tab=wm#inbox"
end tell
end if
-----------------------------------------------------------------
Likewise, I just put this in place with a Hot Key and it works really nicely. Thanks very much for contributing the script. Being able to jump instantly to my Gmail tab from anywhere is just wonderful.
If you want to create macros that manage other Google services all you have to do is find the shortest portion of the URL of the service that is consistent and replace the URL in the script.
I have altered the script, so you only have to enter the URL in 1 place.
I already installed chrome and just keep getting the sign in page. I guess I was between facebook and Pinterest more so they dropped my gmail acct. I created a new one but now the say they can’t find it! I’ve created another acct on google and this one is sticking with 2 emails from google. I gave the second email address to a friend who has also left facebook and now I have no way to contact him
After using Keyboard Maestro for the sole purpose of opening the Finder with a shortcut button for more than a year, I finally started to make use of the combining powers of Alfred and KM, and am blown away by it. I am not a coder but look at optimizing workflows in daily operations for product management.
I stumbled across this one and got it working for my specific case, where I embed the Script in another Macro. However, what do you have to change if you want the new Gmail tab to open in the same window and not in a new one? I tried to steal from other Scripts, but it did not do the trick in my case.
I am sure it is something embarrassingly easy in the last part of the script, where I want to replace the “newWin” for newTab parameters:
tell application "Google Chrome"
set newTab to make new tab
tell newTab to set URL of active tab to "NEWURL"
end tell
Thanks for the fast response! I know about the “new tab/new window” KM actions, but looked at something like that:
Scans Chrome for an open tab with certain values
if tab is in place
–> do x
if tab is not in place,
–> create new tab
–> open URL in new tab,
–> do x
Yep; it's dead simple – if you know how. If you don't then it's a headache.
Here's my script above updated to do what you want.
-Chris
----------------------------------------------------
# Auth: Christopher Stone <scriptmeister@thestoneforge.com>
# dCre: 2015/05/14 12:30
# dMod: 2018/03/31 00:39
# Appl: Google Chrome, System Events
# Task: Bring Chrome Tab with Google Calendar to front if it exists - otherwise open Calendar in new tab.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Google_Chrome, @System_Events, @Tab
----------------------------------------------------
set googleServiceURL to "https://calendar.google.com/calendar/"
set _win to false
tell application "Google Chrome"
set {idList, urlList} to {id, URL} of every tab of every window
end tell
set AppleScript's text item delimiters to return
set urlListText to urlList as text
if urlListText contains googleServiceURL = true then
set theWin to 1
repeat with i in urlList
set theTab to 1
repeat with n in i
if n starts with googleServiceURL then
set {_win, _tab} to {theWin, theTab}
end if
set theTab to theTab + 1
end repeat
set theWin to theWin + 1
end repeat
end if
if _win ≠ false then
tell application "System Events"
if quit delay ≠ 0 then set quit delay to 0
tell process "Google Chrome"
perform action "AXRaise" of window _win
end tell
end tell
tell application "Google Chrome"
tell front window to set active tab index to _tab
end tell
else
tell application "Google Chrome"
set newWin to make new tab at end of tabs of front window with properties {URL:googleServiceURL}
end tell
end if
----------------------------------------------------
Chris, this is amazing. I just realized that the googleServiceURL is nothing but a placeholder in your script that is defined by the specific URL. Hence, I can use it for many different cases such as scanning for Jira, Intercom, Product-Tabs that are open, and embed the script in those workflows. Thanks a lot!