Script Editor can be used to automate mundane things or convert a simple shell script to a Mac app.
I’m using Script Editor for a few such cases.
Proguard GUI
I’m an Android developer and I often have to use the Proguard retrace tool to retrace obfuscated stack traces. If you have Android Studio, then the retrace tool would be already in your machine.
But to access it via GUI, you have to invoke a shell script (the one from ~/Library/Android/sdk/tools/proguard/bin/proguardgui.sh). And doing this manually by opening the terminal and entering this script every time you want to open the retrace tool is just boring.
With AppleScript, you can just place this
do shell script "sh ~/Library/Android/sdk/tools/proguard/bin/proguardgui.sh"
in a New Script Editor window and you can run it from there.
You can also export it as a Mac app by going to File -> Export and selecting Application in File Format. Then you can save it anywhere you like (I personally save it in the Applications folder) and then you can use Spotlight to open the app.
JD-GUI
I use this tool to decompile Jar files and view the Java classes often. Recently there was an issue in Mac OS where we can’t open this tool. While the issue is being fixed, a workaround was suggested which was to use a command to launch the tool instead of directly opening the application through GUI.
java -jar /Applications/JD-GUI.app/Contents/Resources/Java/jd-gui-1.6.6-min.jar
Again, I used Script Editor to convert this into a Mac app, so that I can use Spotlight to open the tool instead of going through Terminal.
do shell script "java -jar /Applications/JD-GUI.app/Contents/Resources/Java/jd-gui-1.6.6-min.jar"
Pulling files through ADB
I save log files and other debug-related info on the device in the application's internal folder during development. And I often have to pull these files into my Mac to go through the logs.
For this, initially, I used Device Explorer from Android Studio to manually navigate to the internal folder and save it to my Mac. Then I started using adb command to do this job.
Then I automated this task and converted it into a Mac app using Script Editor.
do shell script "~/Library/Android/sdk/platform-tools/adb pull sdcard/Android/data/{applicationId}/files/ ~/Desktop/"
Although, this stopped working from Android 11 as this internal folder was not visible to others from this version.
Opening apps when I start the day
We all open some specific set of apps when we start the day in the morning, right? I automated that too.
tell application "Google Chrome"
activate
tell application "System Events"
keystroke "f" using {command down, control down}
end tell
open location "https://{our mail URL}"
delay 1
activate
end telltell application "Google Chrome"
activate
open location "https://{our chat service URL}"
delay 1
activate
end telltell application "Google Chrome"
activate
open location "https://trello.com/b/{my private project}"
delay 1
activate
end telldelay 5
tell application "Android Studio 4.0 Preview.app"
activate
tell application "System Events"
keystroke "f" using {command down, control down}
end tell
end tell
delay 5tell application "Notes"
activate
end tell
I saved this as Start apps as a Mac application. When I start my day, I’ll just open my laptop, open this Start apps app and go to get some tea. When I come back with a tea, all apps would be opened readily for me.
Let me know if this is helpful for you and for which cases you would like to use Script Editor :)