Launch URL

A script for PocoMail that launches "unclickable" URLs


{  Launch URL
{  -------------------------------------------------------------
{  This script launches "unclickable" URLs in plain-text
{  messages and other text areas.
{  Usage:  copy an URL, then run the script to launch it.
{  Notes:  Poco may not highlight an URL that spans more than
{  one line, or is on a page with many other URLs, or is in
{  the compose window or address book. Operating on copied text,
{  this script
{    * reconnects the URL if it is spilt over two or more lines
{    * deletes certain extraneous characters (spaces, >) from
{      the URL
{    * launches the URL in the default Web browser
{  For example, the script removes all spaces, newlines and
{  greater-than characters from the following four quoted lines,
{  then launches the Google search:
{     >
{     > http://www.google.com/search?hl=en&q=%22Caps+Lo
{     > ck%22+site%3Asupport.microsoft.com&btnG=Google+Search
{     >
{  Mark Breault
{  From an idea by www.cheztabor.com/projects.htm
{  2002.03.31
{  Updates at www.mts.net/~mbreault/scripts/launchurl.htm
{  -------------------------------------------------------------


{  Check run mode.
{  5--manually on selected; 7--dry run
{  Assumes that some message or other is always selected.
If #PocoScriptMode = 5 Then ModeOK
If #PocoScriptMode = 7 Then ModeOK
Goto WrongMode
:ModeOK


{  Get Clipboard contents.
PasteFromClipboard $url


{  Check size.
{  When $url is huge, Cleanup is slow.
CharCount #cc $url
If #cc < 5 Then NotAnUrl
If #cc > 900 Then NotAnUrl


{  Cleanup  -- join lines, strip unwanted characters.
TrimLines $url
Set $s "\n"
Call StripChars
Set $s ">"
Call StripChars
Set $s " "
Call StripChars


{  Check whether $url is an URL.
{  This is a light check only. The Execute command bums out --
{  doesn't even generate an error -- when the parameter doesn't
{  begin with http, mailto, etc.
Set $t $url
LowerCase $t
StringPos #p "http" $t
If #p = 1 Then IsUrl
StringPos #p "ftp://" $t
If #p = 1 Then IsUrl
StringPos #p "www." $t
If #p = 1 Then IsUrl
StringPos #p "mailto:" $t
If #p = 1 Then IsUrl
Goto NotAnUrl
:IsUrl


{  Launch the URL and quit.
Execute $url
Goto Done


:StripChars
:Loop
   StringPos #p $s $url
   If #p = 0 Then ExitLoop
   SubStrings $url $s
GoTo Loop
:ExitLoop
Trim $url
Return


:WrongMode
MessageBox "This script should be run manually"
Goto Done


:NotAnUrl
MessageBox "The copied text does not appear to contain an URL"
Goto Done


:Done
Exit

 


Links

A more powerful script in AutoIt v3

PocoMail

The PocoMail FAQ - Assigning a script to a button and keyboard shortcut


Write to Mark Breault  ·  More scripts