Skip to content

Instantly share code, notes, and snippets.

@ianb
Last active March 27, 2023 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianb/2a81e219ec38ea46bac1ad7156f5f711 to your computer and use it in GitHub Desktop.
Save ianb/2a81e219ec38ea46bac1ad7156f5f711 to your computer and use it in GitHub Desktop.
AppleScript to send current selection to Midjourney
tell application "Google Chrome"
delay 1.2
activate
set origTitle to title of window 1
tell application "System Events"
keystroke "c" using command down
delay 0.2
end tell
set targetTitle1 to "Discord"
set targetTitle2 to "Powderhorn Compound"
repeat with theWindow in every window
set windowTitle to title of theWindow
if windowTitle contains targetTitle1 and windowTitle contains targetTitle2 then
set index of theWindow to 1
exit repeat
end if
end repeat
activate
tell application "System Events"
-- Get rid of image preview (53=escape)
key code 53
delay 0.5
keystroke "/imagine"
delay 0.7
keystroke space
delay 0.4
keystroke "v" using command down
delay 0.2
keystroke return
delay 0.2
end tell
repeat with theWindow in every window
set windowTitle to title of theWindow
if windowTitle is equal to origTitle then
set index of theWindow to 1
exit repeat
end if
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment