Skip to content

Instantly share code, notes, and snippets.

@oblitum
Forked from trws/1.applescript
Created January 27, 2018 01:25
Show Gist options
  • Save oblitum/16a63468535ef1f1f6a7965d77e93b56 to your computer and use it in GitHub Desktop.
Save oblitum/16a63468535ef1f1f6a7965d77e93b56 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 "[email protected] - 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 "[email protected] - 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 "[email protected] - 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 "[email protected] - 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 "[email protected] - 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
@vinipsmaker
Copy link

@oblitum pepper_chico, dá uma olhada nisso: http://www.hammerspoon.org/

O que tu acha?

@oblitum
Copy link
Author

oblitum commented Nov 20, 2020

@vinipsmaker interessante, mas provavelmente nem chegaria a avaliar pro caso de uma tarefa simples ou outra, iria de applescript msm (apesar de não relar em mac há anos).

@vinipsmaker
Copy link

apesar de não relar em mac há anos

🤔... entendi

btw, ainda estou lhe devendo algum bom álcool pela indicação da ferramenta hugo. Algum ano precisamos ver isso ainda.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment