![]() ![]() Take Keyboard Maestro to the front, run the Reload Plugins macro we created earlier, and create a new macro to test your action. Keep that file open, as we'll edit it soon. Then copy and paste the full XML above into it, and save it as Keyboard Maestro ist into the Loud Comment folder you created earlier. So create a new file in your text editor of choice (making sure it's plain text, not rich text). But by using TokenString and TokenText instead, we get the same interface and we also make it possible to insert tokens into those fields (in the action), and have them evaluated at run time. We could be using respectively the types String and Text, in this case, which would be rendered in the action as a one line text field for the title and a multiline field for the comment. String, TokenString, Calculation, Text, TokenText, Checkbox, PopupMenu. Again, they're made of key/value pairs: Label, which is the label that will appear in the action and the name of the associated variable, and Type, that defines the type of user interface element to use (text field, checkbox, popup menu, etc). Here we have two text fields, one for the title and one for the comment. Each dict defines a variable and an interface element in the action: (.) Make sure to respect that rule because name or window wouldn't be recognized!Īnd finally we have the Parameters key, whose value is an array of dictionaries (dict for short). Warning: All the key names and predefined values like these are capitalized and case sensitive. This particular pair declares the name of our action as it will appear in KM, and it should match the name of the folder that contains it. The key is named Name, and the value is Loud Comment. If that sounds complicated to you, trust me, it's not. ![]() It is formatted in XML and its contents is mostly made of key/value pairs. This file tells KM how to draw the action and how to execute it. ![]() The only required file, in that folder (if you don't want your action to do anything, that is), is a plist file named Keyboard Maestro ist. So if you rename this folder after you started using your plugin, its action will be broken in all the macros that contain it. The folder name is what KM internally uses in macros to reference actions. Getting StartedĪ plugin is simply made of a set of files, stored in a folder, stored in: Now we're ready, so let's start with the plugin. Then insert an "Execute AppleScript" action and set it like this: Give it a hot key and/or a Status Menu trigger. Otherwise, we wouldn't see our changes.Ĭreate a new macro in a group available when KM is frontmost, and name it Reload Plugins. KM and KM Engine both keep the plugins in memory, so while developing plugins, we need a way to reload them. Then we'll progressively improve it, until we get an action that's also very useful to debug macros.īut before, we have to make a little tool. So we'll start by making a comment action with a more contrasted icon. But in my experience, KM's comments don't stand out quite enough to make it easy to scan a long macro by reading only the comments. Before we startįirst I have to say that I find comments indispensable, especially in long macros (Peter added the Comment action a long time ago in response to a feature request of mine, BTW). Plugins aren't compiled, so the source code is entirely accessible. You can download the plugin we're going to make from here. It will show you how powerful and how well thought this feature is, and you'll learn a few things that are not mentioned in the documentation. But if you have a few minutes to spare, I'd suggest you to still have a quick read. If you're a developer or an expert at scripting and editing plists, though, I wouldn't blame you if you found it boring and felt like jumping directly to the official documentation. If you're comfortable with a bit of scripting and have no or little experience with plist files and XML, then yes, definitely! In fact, this tutorial was made just for you! This will allow us to create a plugin without having to focus too much on the script. In this tutorial, we will create a Comment action a bit more advanced than KM's. What that means is that now you can create your own actions! Yes, you read that right! Keyboard Maestro 6 brought a major and awesome new feature: Plug In Actions. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |