Last active
September 9, 2016 10:28
-
-
Save gpessia/1c35ed119057c328d8f5d820def221d4 to your computer and use it in GitHub Desktop.
Keyboard Maestro Chrome Tab to Tweetdeck
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Auth: Christopher Stone <[email protected]> | |
# 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 | |
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://tweetdeck.twitter.com/" = 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://tweetdeck.twitter.com/" 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://tweetdeck.twitter.com/" | |
end tell | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment