I mean, I wrote the thing and even to me years later it’s still like freaking voodoo! :) Tell app "finder" to count every folder of home whose name begins with "D"Īpp("TextEdit").documents.at(1).name.get()Īpp("Finder").(("D")).count() Tell app "textedit" to get name of document 1 It’s not codesigned so you’ll have to right-click the app to Open it, overriding the security warnings, but it still works even on 10.15 (caveat any bugs in the underlying JavaScript Apple event bridge, of which there were a few, plus the endless string of permission requests whenever you try to control another app). Just d/led the JavaScriptOSA zip from the appscript project page on SourceForge, and the bundled JABDemo.app still works. Needless to say, Sal Soghoian completely ignored my expert recommendation for this killer feature which could be implemented in a day, choosing instead to dump JXA and its few hapless users down the same black hole of nothingness as all his other product failures. While it only translates outgoing Apple events, not native AS code, 99% of the time JS users already know how to write general JS code, and it’s the application-specific references and commands they’re struggling to form.īack when appscript was still a thing I hacked together a quick-n-dirty AppleScript-command-to-Python/Ruby/ObjC translator app which appscript users absolutely adored, plus it greatly reduced the number of “How do I…” support questions because, more often than not, users already had a working example in AppleScript which they could just run through the translator to get the answer for themselves. You're really better off with Keyboard Maestro for this specific kind of task.Funny enough, back when the Mac Automation devs were still getting JXA ready to throw away, one of the things I told Sal Soghoian to do was to add automatic AS-to-JS syntax translation to Script Editor’s Log pane. This is tedious, but I wrote about how to do it, among other methods of running AppleScript. You can then bind hotkeys to those services from Keyboard Preferences in System Preferences. If you want to get fancy with the AppleScript approach, you can throw both of those scripts into separate "Service" workflows in Automator. You'll probably want to export that as an App and stick it on your dock to double-click to kill this bastard. To turn it off, you'll make a new script: do shell script "killall applet" Now, you run that app to mash the space key, but you'll need a way to turn it off. You need to take the first script up there, throw it in Script Editor and "Export" it as an Application. Tell application "System Events" to keystroke spaceįor testing, you can repeat a specific number of times like so: repeat with i from 1 to 10 Don't run this script, since it'll just hit space forever, but you'd set up a script like this: repeat until false If you still want to go the AppleScript approach, here's what I might suggest. In Keyboard Maestro you might make one hotkey-triggered macro to run the "repeat until false" applescript below, and another to cancel all macros. You can set up Keyboard Maestro macros to alternately start or cancel other macros, which is pretty much what you're asking for. Instead, you should probably look at something like Keyboard Maestro for this kind of keystroke automation. In AppleScript, the repeat part is easy, but the toggle part is not something AppleScript is well-suited for. If you're just looking for repeats on the spacebar, why not just put a paperweight on the space bar and let key repeat do the job?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |