This content originally appeared on DEV Community and was authored by DEV Community
ShortStory.
A few weeks ago, I was curious about accessing different devices on my network. After a long time researching, I found that it's accessible simple to ssh into my local machine IP address.
In my subsequent work, I found something exciting. I was able to control the brightness of my Macbook Pro from my iMac terminal, and one time I left my table to take a quick break for breakfast, and the monitor on my laptop went to sleep. I pressed enter and saw the log-in page, BUT I could still use my laptop via ssh on the terminal.
I thought it would be interesting to access the keyboard via terminal, but it is hard to do with .sh/bs.
Behind a research work, I found that AppleScript is a thing. We can automate and ask it to do something exciting.
The first thing I did was create a "google" function in the terminal that opens google search with the flag as a query input -
google "What's your search?".
Second thing was this code, that opens: Spotlight - type Notepad and prints HelloWorld.
Code >
tell application "System Events"
delay 0.5
keystroke space using command down
delay 0.5
keystroke "Text"
delay 0.5
keystroke "Edit"
delay 0.5
keystroke return
delay 1
keystroke "Hello world!"
end tell
Conclusion
Automation!
⚠️ Previous Blog Post Tips And Tricks About Shell & CURL [Link]
This post is the best for short commands.
⚠️ Future Blog Post About Collaborative WhiteBoard with Node.js + React.js + AWS(EC2): [Link]
Links
🖇 Follow me on GitHub
🖇 Follow me on Twitter
_p.s This post was made out of my curiosity
This content originally appeared on DEV Community and was authored by DEV Community
DEV Community | Sciencx (2022-02-26T01:26:26+00:00) AppleScript Automation.. Retrieved from https://www.scien.cx/2022/02/26/applescript-automation/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.