Every morning when I sit down at the computer I usually open the same browser windows: GMail, New Relic, Twitter, SoundCloud, and AWS. This usually doesn’t take too long. But I do spend a fair number of keyboard clicks to do it. One of the great things about working with OSX (macOS now) is being able to write automation scripts in JXA to simplify regularly performed tasks.
Now we will need to get some documentation on how to interact with Chrome. Select Window -> Library, the library has a list of programs that can be clicked to open up the JXA documentation.
Next let’s write a quick script that opens up a new Chrome window and a bunch of useful tabs.
Pretty straight forward! Its a very helpful script if you are opening the same websites every day.
If you are like me you spend a lot of time listening to podcasts and DJ sets on YouTube and SoundCloud. If you’re also like me you’ll usually have a lot of tabs open and the one that you are looking for is usually backgrounded in some other Space. When a call comes in or a co-worker comes by to chat you’ll need to take that time to look for the tab that is playing your media and pause it. This could take seconds! Let’s write a script to help us play and pause our media.
Did you try and run the code in the AppleScript Editor? Did you get this error?
Pretty sweet! Now we can pair this with a Alfred Workflow with the shortcut “SCP” and we can quickly and conveniently play and pause our sets on SoundCloud.
Need to play and pause YouTube videos quickly? Easy stuff.
JXA is pretty powerful and allows you to automate repetitive tasks very quickly. I use these scripts just about every day with out even thinking about it.
Is there a repetitive task that you run often that can be automated? I’d love to hear what scripts you have written and that have helped improve your workflow.