Created
April 12, 2021 15:32
-
-
Save sughodke/f790401e4009646b209388c0766e6d89 to your computer and use it in GitHub Desktop.
Export your watchlist from Stocks.app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
Exports the Stocks.app watchlist | |
This script will use system events to read the window title of the Stocks App and press the up arrow to move to the next stock. The title contains the stock ticker and recent price. This is appended to a running list and is returned at the end of the run. Currently only 90 stocks are returned per run. | |
Future: Terminate script when the value being appended is the same as last value. | |
*) | |
set the_list to {} | |
repeat 90 times | |
tell application "Stocks" | |
activate | |
end tell | |
tell application "System Events" | |
key code 126 | |
delay 1 | |
# Get the frontmost app's *process* object. | |
set frontAppProcess to first application process whose frontmost is true | |
end tell | |
# Tell the *process* to count its windows and return its front window's name. | |
tell frontAppProcess | |
if (count of windows) > 0 then | |
set window_name to name of front window | |
set beginning of the_list to window_name | |
end if | |
end tell | |
end repeat | |
return the_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment