{"id":3912,"date":"2022-09-26T10:54:31","date_gmt":"2022-09-26T14:54:31","guid":{"rendered":"https:\/\/redsweater.com\/blog\/?p=3912"},"modified":"2022-10-04T13:04:36","modified_gmt":"2022-10-04T17:04:36","slug":"fastscripts-3-2","status":"publish","type":"post","link":"https:\/\/redsweater.com\/blog\/3912\/fastscripts-3-2","title":{"rendered":"FastScripts 3.2: Script Collections, Parameterized Scripts, Search Improvements"},"content":{"rendered":"<p>FastScripts 3.2 is now available on the <a href=\"https:\/\/redsweater.com\/fastscripts\/\">FastScripts home page<\/a>, or by selecting \u201cCheck for Update\u201d from the FastScripts menu.<\/p>\n<p>This is a substantial update featuring support for custom script collections, parameterized scripts, improvements to the Scriptlight search feature, and more.<\/p>\n<h3>Script Collections<\/h3>\n<p>By default, FastScripts searches for scripts in the same standard &#8220;Scripts&#8221; folders that Apple&#8217;s Script Menu searches. Notably: &#8220;\/Library\/Scripts&#8221; for system-wide scripts, and &#8220;[Home]\/Library\/Scripts&#8221; for your personal collection of scripts. Anything in these standard folders shows up in the FastScripts menu, can be searched with the Scriptlight search feature, and can be configured with keyboard shortcuts via FastScripts&#8217;s Preferences.<\/p>\n<p>But not everybody keeps their script collections in these standard locations, and for that matter, not everybody keeps only one or two collections of scripts. That&#8217;s why I&#8217;ve expanded FastScripts to support an arbitrary number of user-determined locations, whose script contents will all be available to the app. To customize these collections, you can add your own folders, remove the default ones, or both:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"ScriptCollections.png\" src=\"https:\/\/redsweater.com\/blog\/wp-content\/downloads\/2022\/09\/ScriptCollections.png\" alt=\"UntitledImage\" width=\"400\" height=\"164\" border=\"0\" \/><\/p>\n<h3>Parameterized Scripts<\/h3>\n<p>For advanced workflows, FastScripts supports the ability to invoke any script &#8230; from within another script. I know, pretty meta, right? This can be useful for nesting behaviors from multiple scripts, or for conditionalizing whether particular scripts are run or not.<\/p>\n<p>The ability to run scripts has gotten a lot more powerful in FastScripts 3.2, with the addition of robust support for specifying parameters to invoked scripts. As a trivial example, you might have a script called &#8220;Say Hello&#8221; that expects parameters for first and last names:<\/p>\n<pre><p style=\"margin: 0px 0px 0px 41.6px; text-indent: -41.6px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana; color: #408000;\"><span style=\"font-variant-ligatures: no-common-ligatures; color: #000000;\"><b>on<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">sayHi<\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #000000;\">(<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">firstName<\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #000000;\">, <\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">lastName<\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #000000;\">)<\/span><\/p><p style=\"margin: 0px 0px 0px 83.2px; text-indent: -83.2px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">\t<b>tell<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #0000ff;\"><i>application<\/i><\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> \"FastScripts\"<\/span><\/p><p style=\"margin: 0px 0px 0px 124.8px; text-indent: -124.9px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">\t\t<b>set<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #408000;\">greeting<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> <b>to<\/b> \"Hi \" &amp; <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #408000;\">firstName<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> &amp; \" \" &amp; <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #408000;\">lastName<\/span><\/p><p style=\"margin: 0px 0px 0px 124.8px; text-indent: -124.9px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana; color: #0000ff;\"><span style=\"font-variant-ligatures: no-common-ligatures;\"><b>\t\tdisplay message<\/b><\/span> <span style=\"font-variant-ligatures: no-common-ligatures; color: #408000;\">greeting<\/span><\/p><p style=\"margin: 0px 0px 0px 83.2px; text-indent: -83.2px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">\t<b>end<\/b> <b>tell<\/b><\/span><\/p><p style=\"margin: 0px 0px 0px 41.6px; text-indent: -41.6px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana; color: #408000;\"><span style=\"font-variant-ligatures: no-common-ligatures; color: #000000;\"><b>end<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">sayHi<\/span><\/p><p style=\"margin: 0px 0px 0px 41.6px; text-indent: -41.6px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana; min-height: 15px;\">\u00a0<\/p><p style=\"margin: 0px 0px 0px 41.6px; text-indent: -41.6px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana; color: #408000;\"><span style=\"font-variant-ligatures: no-common-ligatures; color: #000000;\"><b>on<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #0000ff;\"><b>run<\/b><\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #000000;\"> {<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">firstName<\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #000000;\">, <\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">lastName<\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #000000;\">}<\/span><\/p><p style=\"margin: 0px 0px 0px 83.2px; text-indent: -83.2px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana; color: #408000;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">\tsayHi<\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #000000;\">(<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">firstName<\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #000000;\">, <\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">lastName<\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #000000;\">)<\/span><\/p><p style=\"margin: 0px 0px 0px 41.6px; text-indent: -41.6px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures;\"><b>end<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #0000ff;\"><b>run<\/b><\/span><\/p><\/pre>\n<p>Now you can run a script like this, either from within FastScripts, or invoked by another AppleScript utility:<\/p>\n<pre><p style=\"margin: 0px 0px 0px 41.6px; text-indent: -41.6px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures;\"><b>tell<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #0000ff;\"><i>application<\/i><\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> \"FastScripts\"<\/span><\/p><p style=\"margin: 0px 0px 0px 78.5px; text-indent: -78.6px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">\t<b>set<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #408000;\">myScript<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> <b>to<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #0000ff;\"><i>script item<\/i><\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> \"Say Hi\"<\/span><\/p><p style=\"margin: 0px 0px 0px 78.5px; text-indent: -78.6px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">\t<b>set<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #408000;\">myTask<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> <b>to<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #0000ff;\"><b>run<\/b><\/span> <span style=\"font-variant-ligatures: no-common-ligatures; color: #408000;\">myScript<\/span> <span style=\"font-variant-ligatures: no-common-ligatures; color: #0000ff;\">with parameters<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> {\"Daniel\", \"Jalkut\"}<\/span><\/p><p style=\"margin: 0px 0px 0px 39.2px; text-indent: -39.3px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures;\"><b>end tell<\/b><\/span><\/p><\/pre>\n<p>And running it will yield the expected result:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"HiDaniel.png\" src=\"https:\/\/redsweater.com\/blog\/wp-content\/downloads\/2022\/09\/HiDaniel.png\" alt=\"Screenshot of heads-up-display display text reading 'Hi Daniel Jalkut'\" width=\"288\" height=\"118\" border=\"0\" \/><\/p>\n<h3>Script Results<\/h3>\n<p>If you look carefully at the examples above, you&#8217;ll see that unlike Apple&#8217;s built-in &#8220;run script&#8221; command, FastScripts doesn&#8217;t immediately return the result of running a script. This is because you are free to kick off multiple scripts and, thanks to FastScripts&#8217;s multi-process design, they will each run in parallel.<\/p>\n<p>Instead of a result, the &#8220;run&#8221; command in FastScripts returns a <em>script task<\/em> object. You can use this reference to &#8220;force stop&#8221; a running script, but perhaps more importantly, you can now use it to await the script&#8217;s result. When your script requests the &#8220;result&#8221; of a script item, FastScripts will suspend the execution of your script until the result is available. So if you wanted to kick off 5 scripts and wait for all of them to return results, you could &#8220;run&#8221; them, and then ask for the result of each of them.<\/p>\n<p>Here&#8217;s a simple example, wherein a script called &#8220;Add Numbers&#8221; is designed to take two parameters:<\/p>\n<pre>\n<p style=\"margin: 0px 0px 0px 39.2px; text-indent: -39.3px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures;\"><b>tell<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #0000ff;\"><i>application<\/i><\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> \"FastScripts\"<\/span><\/p><p style=\"margin: 0px 0px 0px 78.5px; text-indent: -78.6px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">\t<b>set<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #408000;\">myScript<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> <b>to<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #0000ff;\"><i>script item<\/i><\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> \"Add N<\/span><span style=\"font-stretch: normal; line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures; color: #800080;\">u<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\">mbers\"<\/span><\/p><p style=\"margin: 0px 0px 0px 78.5px; text-indent: -78.6px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">\t<b>set<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #408000;\">myTask<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> <b>to<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #0000ff;\"><b>run<\/b><\/span> <span style=\"font-variant-ligatures: no-common-ligatures; color: #408000;\">myScript<\/span> <span style=\"font-variant-ligatures: no-common-ligatures; color: #0000ff;\">with parameters<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> {19, 7}<\/span><\/p><p style=\"margin: 0px 0px 0px 78.5px; text-indent: -78.6px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures;\">\t<b>set<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #408000;\">answer<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> <b>to<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #6c05d3;\">result<\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> <b>of<\/b> <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #408000;\">myTask<\/span><\/p><p style=\"margin: 0px 0px 0px 78.5px; text-indent: -78.6px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures; color: #0000ff;\">\t<b>display message<\/b><\/span><span style=\"font-variant-ligatures: no-common-ligatures;\"> \"The answer is \" &amp; <\/span><span style=\"font-variant-ligatures: no-common-ligatures; color: #408000;\">answer<\/span><\/p><p style=\"margin: 0px 0px 0px 39.2px; text-indent: -39.3px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Verdana;\"><span style=\"font-variant-ligatures: no-common-ligatures;\"><b>end tell<\/b><\/span><\/p><\/pre>\n<p>For practical purposes, you can think of asking for the &#8220;result&#8221; of a script task as repeatedly checking to see if the script has completed, and &#8220;delaying&#8221; the script until it&#8217;s done. In reality, the behavior is far more efficient than this!<\/p>\n<h3>Search Improvements<\/h3>\n<p>Scriptlight, the built-in search feature that allows you to quickly locate scripts matching a particular name or substring, can sometimes identify two scripts that have the exact same name, but are located at different locations in your script collections. Until now, this had the unwanted effect of turning the process of searching for and running one of these scripts a kind of gamble. Would it be the one you wanted, or not?<\/p>\n<p>In FastScripts 3.2 special care is taken to differentiate search results so that identically named items are further identified by the folder that contains them. There is still some risk of ambiguity if you have identically named scripts inside identically named folders, but this should solve the problem for most scenarios:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"SearchConflict.png\" src=\"https:\/\/redsweater.com\/blog\/wp-content\/downloads\/2022\/09\/SearchConflict.png\" alt=\"Screenshot of FastScripts search results showing two identically named files with a differentiating label showing the name of the containing folder\" width=\"411\" height=\"200\" border=\"0\" \/><\/p>\n<h3>FastScripts 3.2 Summary<\/h3>\n<p>In sum, this update packs a powerful punch, including a number of new features to supercharge workflows, as well as a number of minor updates and bug fixes. Here&#8217;s the complete list of changes for this update:<\/p>\n<ul>\n<li>New settings for custom Script Collections allows for arbitrary script folder locations<\/li>\n<li>Built-in script running command now supports specifying script parameters and awaiting a result<\/li>\n<li>Shortuts integration: new &#8220;Display Message&#8221; action for heads-up display messages<\/li>\n<li>Identically named scripts are now differentiated in search results by showing their containing folder name<\/li>\n<li>Fixed a bug that could caused the wrong color to appear in the menu bar color preference<\/li>\n<li>Fixed a bug that in rare cases prevented changed keyboard shortcuts from showing as expected in the menu<\/li>\n<li>Improved reliability of keyboard shortcuts staying set when scripts are moved<\/li>\n<li>Changed name of &#8220;Preferences&#8221; to Settings&#8221; if running on macOS 13 or greater<\/li>\n<\/ul>\n<p>If you enjoy FastScripts, please consider spreading the word on <a href=\"https:\/\/facebook.com\/fastscriptsapp\">Facebook<\/a> or <a href=\"http:\/\/twitter.com\/fastscripts\">Twitter<\/a>! Thanks for your support.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>FastScripts 3.2 is now available on the FastScripts home page, or by selecting \u201cCheck for Update\u201d from the FastScripts menu. This is a substantial update featuring support for custom script collections, parameterized scripts, improvements to the Scriptlight search feature, and more. Script Collections By default, FastScripts searches for scripts in the same standard &#8220;Scripts&#8221; folders [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,16],"tags":[],"class_list":["post-3912","post","type-post","status-publish","format-standard","hentry","category-fastscripts","category-red-sweater-news"],"_links":{"self":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/3912","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/comments?post=3912"}],"version-history":[{"count":7,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/3912\/revisions"}],"predecessor-version":[{"id":3925,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/3912\/revisions\/3925"}],"wp:attachment":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/media?parent=3912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/categories?post=3912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/tags?post=3912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}