Some background on why this is.) This work is licensed under aĬreative Commons Attribution 4.0 International License. I learned that the constructor doesn’t take a month argument but instead a monthIndex, in the range 0–11. (Another oddity: I initially created the Date (now in line 10) manually with the date components extracted from the ISO-format date string. You could strip out any of your custom properties, but here I just use the ISO-format date string from the filename as it works just as well for the sorting comparison. One oddity: I did try to store a JavaScript Date in the result objects, to use in the final sorting, but LaunchBar displays an error if a Date in the returned items. Windows 11 Tips Add the Quick Launch Toolbar to the Taskbar in Windows 11 OnlineComputerTips 6. And in lines 9–12 we use the formatDate function on the LaunchBar object, which gives us access to the system’s date formatting, which is both locale-aware and respects the user’s date & time preferences.īy providing the path in the result object, LaunchBar treats each entry in the list as a file, so you can press return to open it, or press the right arrow to inspect its details. In line 3, we make use of the File object, which is provided by LaunchBar. sorting those objects on the ISO date string, newest to oldest (lines 25–29).creating an object containing a human-readable date, the path to the file, and an ISO-format date string (lines 7–24).keeping only those whose filenames match dated shortlog files (lines 5 & 6).reading the contents of a directory (lines 3 & 4).We treat this as a simple pipeline of transformations on data: This is just a “default script”, and while run takes an argument, it’s ignored. You can read about the properties items can have in the LaunchBar action developer documentation.ġ function run ( argument ) One thing to note is that it returns a result of type “Item” - an array of JavaScript objects with particular keys. However, in macOS, there is no built-in way to launch an application by pressing a keyboard shortcut. This is a default script, taking no input. In macOS, there are many ways to launch an application.You can click an icon in the Dock or the Launchpad, or type the name of the app in the Spotlight search box. Here are the settings in the scripts pane in LaunchBar’s Action Editor: (And, to be clear, this isn’t JXA either.) LaunchBar provides some additional tools to make interacting with the system straightforward from JavaScript. I wrote it in JavaScript as the documentation leads you that way, and you don’t have to serialise to JSON and write to stdout to return values. So I thought I would write a LaunchBar action to do both.ĭespite being my first, it was really very easy. However, that doesn’t resolve the problem that it’s not always easy to realise that is “Monday”. You can reverse this by holding down command when navigating into the folder in LaunchBar. By default these are listed in lexicographically ascending order. I have my shortlog folder indexed by LaunchBar, so I can browse the files that way. If not, is it possible to call/run AppleScript from within JavaScript? (So I could insert AppleScript into the JavaScript example I have.Listing shortlog files chronologically with LaunchBarīuilding on my introductory post about maintaining “shortlog” diary files, I quite often want to have a look at recent shortlog files. Is it possible to do this via AppleScript? (I don't really know JavaScript) 'string' : 'You didn\'t hold down any modifier keys!' 'string' : 'You held down the Control key!' 'string' : 'You held down the Option key!' 'string' : 'You held down the Command key!' Test notifications with modifier keys pressed I have a rough example script (JavaScript) that shows how to run different scripts if you hold down specific modifier keys (⌘, ⌥, ⌃) when running a LaunchBar action.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |