yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

AppleScript and Automator Tutorial


3m read
·Nov 3, 2024

Processing might take a few minutes. Refresh later.

Hey guys, this is ma kids11 with a video I've been wanting to make for a while, but I haven't really gotten around to it, and I haven't taken enough time to make it. Um, but this video is going to be on, uh, things that you can do on your Mac if you're a programmer or you're, um, interested in programming or something that'll make your life easier.

Um, because a lot of the time I find that, you know, Apple, they made like AppleScript, they made Automator, and a bunch of other stuff to make your life easier, and no one uses them. And so this is mainly going to be a tutorial on Automator and AppleScript, and I hope a lot of you out there who either want to learn programming or who want to just make their life easier, we, uh, watch this and see.

So, first thing I'm going to be teaching you is AppleScript. You have to have AppleScript Editor. I think you get it with Xcode; it might just come with your Mac, I don't know. Um, AppleScript, it's like a, it's like, uh, it, it's, it's a fully functional programming language.

Um, but it's mainly used not for big things, but for small little scripts, obviously. So the first thing I'm going to be teaching you how to do is deal with other applications using AppleScript, and that's the main thing that I do with AppleScript at this point.

So you can say tell application, and then I'll say TextEdit, for instance. And here you say entel, and in here you're writing AppleScript, the text that it will do. And I can say activate, and this, if TextEdit isn't open, will open it, and if it is open, it'll activate it.

And so now if we run this, TextEdit opens up, and it opens up real quickly too. And let's say we want to make it type something in TextEdit. We're going to tell the application System Events. And in here, we're going to write something like, well, let's say we want to type something.

We'll type keystroke hello or, for instance, and now if we run this, it'll type hello world. The reason we can't just say tell application TextEdit to do this is because System Events is a special application.

Um, I don't know if it's actually a process or not; maybe it's just AppleScript magic that responds to the keystroke stuff and a bunch of other stuff that nothing else responds to. Other, I think Finder responds to a lot of stuff too.

Um, let's say we want to hit enter; you can type key code 36, and this is once again another System Events magic key code. And then we enter the key code, and 36 happens to be the key code for new line.

Now if we do that, it'll hit enter. I'll clear this out if we do it again, and I'll type it. We keep, keep on running it, keep on typing, same thing. Um, how about we write another line in here just to prove that it actually does that? And there, there you go.

You can see, I'll just hit enter again, and you can run it, and it'll write that thing again and again. Unfortunately, it doesn't put an error and new line at the end.

Um, next thing, that's how to type stuff into apps. You can obviously make it, I am someone in iChat or anything like that. Um, so that's pretty useful.

Um, the next thing I'm going to show you is dialogues. Um, you can type display dialog, and you have a couple of things you can say. Here's the contents of the dialogue, so I'll make it say, what's your name? And this will be something where they have to give an answer.

And in order I tell them that they have to give an answer, we have to say default answer or something. And we'll say the buttons are okay, and I'll say default button one. That means the first button in the window will be highlighted and glowing.

And now if we run this, it'll say, what's your name? Alright, Alex, I'll hit enter, and there we go. It'll leave, say that and text returned. That's pretty cool.

So now we can say set my variable to the text returned of the result. And I think this is, um, it's a quite verbose language, AppleScript in general, because you can tell exactly what this is doing even if you don't know code because it's in English.

You're setting my variable to the text returned of the result. That's pretty verbose if you ask me. So let's run this. It won't d...

More Articles

View All
Behind the Scenes of Marvel Studios' Moon Knight | National Geographic
I’d love to take this opportunity to show you around with Moon Knight. We’re in a very different world. The world building is so complete and interesting, and it’s hard to paint such a big canvas. While you watch the show, you will learn about ancient Eg…
The Video Chat That Existed In The 1870s | How Sci-fi Inspired Science
You hear your phone. You look down, and what do you see? Incoming video call. After you hit the client, think about how commonplace video chats have become. For a long time, the idea of seeing someone from across the world was only in science fiction. So,…
m͏̺͓̲̥̪í͇͔̠ś̷͎̹̲̻̻̘̝t̞̖͍͚̤k̥̞à̸͕̮͍͉̹̰͚̰ẹ̶̢̪s͏̨͈̙̹̜͚̲ ̛̬͓͟
Hey, Vsauce. Michael here. The title of this video is misspelled in honour of mistakes. Mistakes are everywhere; they surround us like air. To err is human. Faults, flaws, faux pas, fumbles and fallacies are as much a part of who we are today as the stuff…
Clattering Penguins and Naughty Seals | Epic Adventures with Bertie Gregory on Disney+
Chin straps get their name from that black marking that runs under their chin. Uh, and they’re also sometimes called stone breaker penguins because of that ear-piercing screech. They’re really sociable birds that waddle ashore in these massive numbers to…
Start Your Affordable Watch Collection Here
[Applause] [Music] In the last year, a lot of people have been writing me saying, “Okay Kevin, this is just absolutely great! Every time you’re talking about a watch, it’s a one-of-a-kind that no one else can get, and you’re such a rich person talking ab…
Forest Flyover with Gisele | Years of Living Dangerously
[Music] This was good. Gross forest was not like that. What you can see now, this whole thing that we are seeing, that is dry land right now, was not here then. In 50 years, have this destruction. You can see forest, and next to a clear cut for a mile lo…