Skip to content

Instantly share code, notes, and snippets.

@dougtoppin
Last active December 15, 2015 08:49
Show Gist options
  • Save dougtoppin/5233653 to your computer and use it in GitHub Desktop.
Save dougtoppin/5233653 to your computer and use it in GitHub Desktop.
I regularly have a thunderbolt cinema display on my MacBook Pro with the Kindle app running on it for reference while I'm working on the MBP screen. To go to the next page on the Kindle I have to move the cursor, select the app and hit return. This is the start of coming up with an easier way to do that. Using shortcuts I added option-return to …
(*
Simple OSX ML Automator/Applescript to send a carriage return to a running Kindle app
*)
on run {input, parameters}
global okflag
set appname to "Kindle"
set okflag to false
tell application "System Events"
if process appname exists then
set okflag to true -- kindle app is running
end if
end tell
if okflag is true then
(* let the user know what we are doing, this will go away once this all works *)
(* capture what app is active right now *)
set theApp to ((path to frontmost application) as text)
set theMsg to "Kindle is running, current app is " & theApp
display dialog theMsg
(* this floats the app which I would rather not do but have not found a better way yet *)
tell application appname to activate
(* now send 36 (enter) to the app *)
tell application "System Events" to tell process appname to key code 36
(* go back to the original app *)
tell application theApp to activate
else
set dialogResult to display dialog "Kindle is not running"
end if
return input
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment