Skip to content

Instantly share code, notes, and snippets.

@trws
Created June 12, 2013 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trws/5766599 to your computer and use it in GitHub Desktop.
Save trws/5766599 to your computer and use it in GitHub Desktop.
tell application "Google Chrome"
repeat with windowId from 1 to counts windows
if title of window windowId contains "tom.scogland@gmail.com - Gmail" then
activate window windowId
end if
end repeat
end tell
tell application "System Events"
set theProcesses to application processes
repeat with theProcess from 1 to count theProcesses
set theName to (name of process theProcess)
if theName contains "Chrom" then
tell process theProcess
try
repeat with x from 1 to (count windows)
if name of window x contains "tom.scogland@gmail.com - Gmail" then
click menu item (name of window x) of menu of menu bar item "Window" of menu bar 1
end if
end repeat
end try
end tell
end if
end repeat
end tell
tell application "System Events"
set theProcesses to application processes
repeat with theProcess from 1 to count theProcesses
set theName to (name of process theProcess)
if theName contains "Chrom" then
tell process theProcess
try
repeat with x from 1 to (count windows)
if name of window x contains "tom.scogland@gmail.com - Gmail" then
click menu item (name of window x) of menu of menu bar item "Window" of menu bar 1
if theName contains "Chromium" then
log "found you! Cromium"
tell application "Chromium" to activate
else
log "found you! Chrome"
tell application "Google Chrome" to activate
end if
tell me to quit
end if
end repeat
end try
end tell
end if
end repeat
end tell
property NSWorkspace : class "NSWorkspace"
set workspace to NSWorkspace's sharedWorkspace()
tell application "System Events"
set theProcesses to application processes
repeat with theProcess from 1 to count theProcesses
set theName to (name of process theProcess)
if theName contains "Chrom" then
tell process theProcess
try
repeat with x from 1 to (count windows)
if name of window x contains "tom.scogland@gmail.com - Gmail" then
click menu item (name of window x) of menu of menu bar item "Window" of menu bar 1
if theName contains "Chromium" then
log "found you! Cromium"
workspace's launchApplication_("Chromium")
else
log "found you! Chrome"
workspace's launchApplication_("Google Chrome")
end if
tell me to quit
end if
end repeat
end try
end tell
end if
end repeat
end tell
property NSWorkspace : class "NSWorkspace"
on raiseWindow()
set workspace to NSWorkspace's sharedWorkspace()
tell application "System Events"
set theProcesses to application processes
repeat with theProcess from 1 to count theProcesses
set theName to (name of process theProcess)
if theName contains "Chrom" or theName contains "Safari" then
tell process theProcess
try
repeat with x from 1 to (count windows)
if name of window x contains "tom.scogland@gmail.com - Gmail" then
try
click menu item (name of window x) of menu of menu bar item "Window" of menu bar 1
end try
workspace's launchApplication:theName
return 0
end if
end repeat
end try
end tell
end if
end repeat
end tell
end raiseWindow
raiseWindow()
tell me to quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment