{"id":3999,"date":"2023-03-03T17:07:18","date_gmt":"2023-03-03T22:07:18","guid":{"rendered":"https:\/\/redsweater.com\/blog\/?p=3999"},"modified":"2023-04-12T08:25:16","modified_gmt":"2023-04-12T12:25:16","slug":"smart-web-page-opening","status":"publish","type":"post","link":"https:\/\/redsweater.com\/blog\/3999\/smart-web-page-opening","title":{"rendered":"Smart Web Page Opening with FastScripts"},"content":{"rendered":"<p><a href=\"https:\/\/redsweater.com\/fastscripts\/\">FastScripts<\/a>, our macOS scripting utility, facilitates organizing and running your scripts from its menu bar icon, or by keyboard shortcut. It serves many roles as a <em>script runner<\/em>, but also includes a number of built-in features that augment the baseline features available to AppleScript scripts.<\/p>\n<p>One of those useful features is the <strong>open web page<\/strong> command, which abstracts the surprisingly complex notion of &#8220;navigating to a given web page URL in your current browser, or default browser&#8221; to a simple command you can invoke from any script.<\/p>\n<p>The basic idea is: given a URL you&#8217;d like to visit, how do we open it in an appropriate browser, creating a new window if necessary, or replacing the current page when appropriate? FastScripts builds a lot of <em>common sense<\/em> into its handling of the <strong>open web page<\/strong> command, so that for example, if you configure a FastScripts script called &#8220;Google News&#8221;:<\/p>\n<pre>\ntell application \"FastScripts\"\n   open web page \"http:\/\/news.google.com\/\"\nend tell\n<\/pre>\n<p>It will open the web page by instructing a web browser on your Mac to open the URL. First, it identifies the ideal browser to open the URL in, based on the following criteria:<\/p>\n<ol>\n<li>The frontmost app, if it&#8217;s a known browser<\/li>\n<li>Your default browser, if it is running<\/li>\n<li>Any known browser, if it is running<\/li>\n<li>Launching your default browser, if configured<\/li>\n<li>Launching any known browser on your system\n<\/li>\n<\/ol>\n<p>The long and short of this is you can use FastScripts&#8217;s &#8220;open web page&#8221; command to create scripts that <em>open web pages intelligently.<\/em> That intelligence goes farther than just choosing which browser to open the link in. Where possible, FastScripts also decides whether to create a new window or tab. By default it favors replacing the current page in the current browser.<\/p>\n<p>I use this command extensively in my own collection of &#8220;Frequent Web Pages&#8221;. I configure these to have the same <em>app-specific keyboard shortcuts<\/em> in Safari, Brave, Chrome, Firefox, and any other browser I might be using at any time. That way when I press <strong>Ctrl-N<\/strong>, for example, in a browser, it always takes me to Google News.<\/p>\n<p>If your scripts ever call for opening web pages in <em>either<\/em> the current browser <em>or<\/em> your default browser, I&#8217;m sure you&#8217;ll enjoy the functionality of FastScripts&#8217;s <strong>open web page<\/strong> command.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>FastScripts, our macOS scripting utility, facilitates organizing and running your scripts from its menu bar icon, or by keyboard shortcut. It serves many roles as a script runner, but also includes a number of built-in features that augment the baseline features available to AppleScript scripts. One of those useful features is the open web page [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-3999","post","type-post","status-publish","format-standard","hentry","category-fastscripts"],"_links":{"self":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/3999","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=3999"}],"version-history":[{"count":4,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/3999\/revisions"}],"predecessor-version":[{"id":4012,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/3999\/revisions\/4012"}],"wp:attachment":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/media?parent=3999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/categories?post=3999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/tags?post=3999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}