I wrote about the Mac application “Fake” awhile ago. From my very first use, I thought it was an incredibly clever tool. Fake is like a super-charged automator for Webkit. It makes automating interactions with webpages easy and simple. But why would I want to use Fake instead of Automator or curl or even a Python script? Here’s an example that I just started using.
If I want to add an affiliate link for a Mac or iOS app, I need to visit the Apple Link Maker page with my affiliate id as a get-parameter in the link. Then I need to choose iOS or Mac apps and type in the application name. I hit search and get back a list of apps. If I typed the name correctly, then the app I want will be on the top of the list.
With Fake, I can automate the entire process. I build a Fake workflow much like I build an Automator workflow. Drag and drop actions and set variables. Fake has auto-discovery for form fields too. Just ctrl-drag from the action to the location on the page to auto-discover the element id. Fake will automatically determine the proper tag hierarchy to find it in the future.
Here’s the workflow:
But how can I automate this process? Well, I kind of like Keyboard Maestro for this kind of stuff. Luckily, Fake has good AppleScript support. In my macro, KM pops up a form where I choose an app type and type an app name to query. Next, an AppleScript is executed to launch the Fake workflow.
tell application "Fake"
activate open "Macintosh HD 2:Dropbox:Development:Fake Workflows:getAppLink.fakeworkflow" delay 1 run workflow wait until done close front document quit
Fake can also run AppleScript so it can also get variables from Keyboard Maestro. Here’s the code from the first Fake action that grabs the input from the form:
set kmVarAppLink to ""
tell application "Keyboard Maestro Engine"
set kmVarAppName to (process tokens "%Variable%AppName%") set kmVarAppType to (process tokens "%Variable%AppType%")
tell application "Fake"
set variable with name "appName" to kmVarAppName set variable with name "appType" to kmVarAppType
The final workflow goes something like this:
- cmd-opt-M to open my Markdown palette of macros
- Type C to choose the macro for appstore affiliate links
- Fill out the popup form and click ok
- wait for the alert that the macro is complete
- paste the affiliate link
Nice. I’m starting to play with Fake as more than just a way to probe web pages. It has some great potential. I haven’t even touched the more powerful actions that allow custom JS to be run against a page.
I would like to see more options to export a workflow to a stand-alone applet or script. Or perhaps a separate headless engine that could run independent of the application (like Keyboard Maestro). I’d also like integration with 1Password for autofill of passwords. I have a couple other ideas for automation that would require hard-coding login credentials and I’m not a fan of that.
- Affiliate Link ↩
- There are things like Selenium that provide a JS engine to Python but I find it to be overly difficult and time consuming to use. I’m also not good at Python. So there’s that. ↩
- I find it interesting that the form value submitted for iOS apps is “software” and the form value for Mac apps is “macSoftware” ↩