Skip to content

Instantly share code, notes, and snippets.

@albb0920
Last active August 14, 2022 16:34
Show Gist options
  • Save albb0920/ca2c2c89784bf761215ad6ea7439ecf1 to your computer and use it in GitHub Desktop.
Save albb0920/ca2c2c89784bf761215ad6ea7439ecf1 to your computer and use it in GitHub Desktop.
Cast entire desktop to Google Cast (Chromecast)
tell application "Google Chrome"
set need_delay to false
if not running then set need_delay to true
activate
if need_delay then delay 5
end tell
tell application "System Events"
tell process "Google Chrome"
-- Click View
repeat with menuBarItem in every menu bar item of menu bar 1
set itemName to name of menuBarItem
if itemName is "檢視" or itemName is "View" or itemName is "表示" then
click menuBarItem
exit repeat
end if
end repeat
-- Click Cast
repeat with menuDropdownEntry in every menu item of menu 1 of menuBarItem
set itemName to name of menuDropdownEntry
repeat with keyword in {"投放", "Cast", "キャスト"}
if keyword is in itemName then
click menuDropdownEntry
exit repeat
end if
end repeat
end repeat
delay 2 -- Wait for popup
key code 48 -- Tab (Move focus to drop down button)
key code 36 -- Enter
delay 1
key code 48 -- Tab (move focus to "X" button)
key code 48 -- Tab (move focus to option: single tab)
key code 125 -- Down (option: Entire desktop)
key code 36 -- Enter
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment