----------------------------------------------------------------------
--- Knud van Eeden --- 12 August 2009 - 10:27 pm ---------------------

Computer: Editor: TSE: URL: Link: How to possibly run hyperlinks in any text document?

---

Steps: Overview:

 1. -E.g. create the following program:

--- cut here: begin --------------------------------------------------
FORWARD PROC Main() FORWARD PROC PROCTextRunProgramUrlCase() // --- MAIN --- // /*****************************-******************************-**** If something passed on the cmdline, run it elseif there is a single line marked block, run it in search engine (e.g. Google) elseif there is a marked block, run it as a .htm file else check if it is a URL, if so run it ******************************-******************************-***/ constant SW_SHOWNORMAL = 1 // DLL "<shell32.dll>" integer proc ShellExecute( integer h, // handle to parent window string op:cstrval, // specifies operation to perform string file:cstrval,// filename string string parm:cstrval,// specifies executable-file parameters string dir:cstrval, // specifies default directory integer show) // whether file is shown when opened :"ShellExecuteA" END PROC Main() PROCTextRunProgramUrlCase() END <F12> Main() // --- LIBRARY --- // // library: text: run: program: url: case <description></description> <version>1.0.0.0.21</version> (filenamemacro=runteuca.s) [kn, bu, we, 12-08-2009 21:47:00] PROC PROCTextRunProgramUrlCase() // e.g. /*****************************-******************************-**** // e.g. If something passed on the cmdline, run it // e.g. elseif there is a single line marked block, run it in search engine (e.g. Google) // e.g. elseif there is a marked block, run it as a .htm file // e.g. else check if it is a URL, if so run it // e.g. ******************************-******************************-***/ // e.g. constant SW_SHOWNORMAL = 1 // e.g. // // e.g. DLL "<shell32.dll>" // e.g. integer proc ShellExecute( // e.g. integer h, // handle to parent window // e.g. string op:cstrval, // specifies operation to perform // e.g. string file:cstrval,// filename string // e.g. string parm:cstrval,// specifies executable-file parameters // e.g. string dir:cstrval, // specifies default directory // e.g. integer show) // whether file is shown when opened // e.g. :"ShellExecuteA" // e.g. END // e.g. // e.g. PROC Main() // e.g. PROCTextRunProgramUrlCase() // e.g. END // e.g. // e.g. <F12> Main() // // For example: http://www.semware.com // For example: ftp://semware.com // For example: file:///c:\windows\notepad.exe // For example: semware@googlegroups.com // For example: \\myserver\mydirectory\myfile // For example: news://news.semware.com/support // STRING s[255] = "" // INTEGER cp = CurrCol() // // If something passed on the command line, use that // IF ( Query( MacroCmdLine ) <> "" ) // s = Query( MacroCmdLine ) // // Otherwise if a single block line is marked // ELSEIF ( isBlockMarked() AND ( ( Query( BlockEndLine ) - Query( BlockBegLine ) ) == 0 ) ) // s = GetMarkedText() // this will be the *first* line (only) of a marked block of text // // Otherwise if more than one block line is marked (multiple lines) start the whole block in your browser // extract the whole block and run it in your browser as a .html file // ELSEIF ( isBlockMarked() AND ( ( Query( BlockEndLine ) - Query( BlockBegLine ) ) > 0 ) ) // Copy() // s = MakeTempName( ".", ".htm" ) // EditFile( s ) // Paste() // SaveFile() // ShellExecute( GetWinHandle(), "open", s, "", "", SW_SHOWNORMAL ) // Warn( "press any key to delete this temporary file" ) // EraseDiskFile( s ) // EditFile( s ) // AbandonFile() // RETURN() // // Otherwise when no block is marked an no command line is passed, extract a possible URL at the current position // ELSE // // first search for the first position on the current line of a space, single quote "'" or double quote '"' to the left // WHILE ( ( NOT (GetText( cp, 1 ) IN " ","'",'"') ) AND ( cp >= 1 ) ) // cp = cp - 1 // ENDWHILE // cp = cp + 1 // // then search on the current line to the right until the first position of a a space, single quote "'" or double quote '"' // WHILE ( NOT ( GetText( cp, 1 ) IN " ","'",'"') ) AND ( cp <= CurrLineLen() ) // s = s + GetText( cp, 1 ) // cp = cp + 1 // ENDWHILE // ENDIF // // Check if the extracted text contains a URL // IF ( ( Lower( LeftStr( s, 7 ) ) == "http://" ) OR ( Lower( LeftStr( s, 4 ) ) == "www." ) ) // // it is a URL, thus start browser with that URL // ShellExecute( GetWinHandle(), "open", s, "", "", SW_SHOWNORMAL ) // ELSEIF ( // // it is a news reader // ( Lower( LeftStr( s, 7 ) ) == "news://" ) // // it is ftp // OR ( Lower( LeftStr( s, 6 ) ) == "ftp://" ) // // it is a file // OR ( Lower( LeftStr( s, 8 ) ) == "file:///" ) ) // // call your browser with a parameter // ShellExecute( GetWinHandle(), "open", "iexplore", s, "", SW_SHOWNORMAL ) // // it is a UNC path (e.g. \\yourserver\yourdirectory\yourfile) // ELSEIF ( Lower( LeftStr( s, 2 ) ) == "\\" ) // // call Explorer with a parameter // ShellExecute( GetWinHandle(), "open", "explorer", s, "", SW_SHOWNORMAL ) // // It is a TSE macro // ELSEIF ( Lower( RightStr( s, 4 ) ) == ".mac" ) // ExecMacro( s ) // // It is an e-mail address // ELSEIF ( NOT( Pos( "@", s ) == 0 ) ) // s = "mailto:" + s // ShellExecute( GetWinHandle(), "open", s, "", "", SW_SHOWNORMAL ) // ELSE // // Otherwise thus start search engine browser (e.g. Google) with that text // ShellExecute( GetWinHandle(), "open", "http://www.google.com/search?q=" + s, "", "", SW_SHOWNORMAL ) // // alternative search engines (remove the // to activate one or more) // // ShellExecute( GetWinHandle(), "open", "http://books.google.com/books?q=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://safari.oreilly.com/search?searchmode=simple&searchtextbox=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://en.wikipedia.org/wiki/" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.powerset.com/explore/pset?q=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.alltheweb.com/search?cat=web&cs=utf-8&l=any&q=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.ask.com/web?qsrc=62&q=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.dogpile.com/dogpile/ws/results/Web/" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.hotbot.com/?cobrand=&matchmode=all&datedelta=0&language=any&recordcount=10&descriptiontype=2&modsign1=MC&dateoption=within&placeselection=georegion&query=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://ixquick.com/do/metasearch.pl?cat=web&cat=web&cmd=process_search&language=english&query=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.mamma.com/Mamma?qtype=0&query=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://clusty.com/search?input-form=clusty-simple&v%3Asources=webplus&query=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.webcrawler.com/webcrawler/ws/redir/rfcp=Other/rfcid=999915/_iceUrlFlag=11?qcat=web&_IceUrl=true&submit=Search&qkw=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://search.yahoo.com/bin/query?p=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://s.teoma.com/search?qcat=1&qsrc=0&q=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://search.live.com/results.aspx?q=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://search.dmoz.org/cgi-bin/search?search=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.faqfarm.com/Q/" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.faqts.com/knowledge_base/search/index.phtml?fid=1&search=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.google.com/search?btnG=Search+Directory&hl=en&cat=gwd%2FTop&q=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://search.yahoo.com/search/dir?h=c&p=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.answers.com/" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.hakia.com/search.aspx?q=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.britannica.com/bps/search?query=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.cuil.com/search?q=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.youtube.com/results?search_type=&aq=f&search_query=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.wolframalpha.com/input/?i=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "http://www.bing.com/search?q=" + s, "", "", SW_SHOWNORMAL ) // ShellExecute( GetWinHandle(), "open", "copernicagentsearch:" + s, "", "", SW_SHOWNORMAL ) // ENDIF // END
--- cut here: end ---------------------------------------------------- 2. -Run the program 3. -Then put your cursor on the line containing (and press <F12> to do the action) 1. -URL E.g. http://www.semware.com E.g. www.semware.com 2. -FTP E.g. ftp://semware.com 3. -NEWS READER E.g. news://news.semware.com/support 4. -UNC PATH E.g. \\myserver\mydirectory\myfile 5. -FILE E.g. file:///c:\windows\notepad.exe 6. -E-MAIL ADDRESS E.g. semware@googlegroups.com it will start the appropriate application 4. -If you mark a one line block or a single line, it will take that line and do a search in your favorite search engine (Google, ...). There are more search engines present (Yahoo, Bing, ...). Just remove the '//' in front of the line in this program to activate that option. 5. -If you mark a block of multiple lines (more than one line), it will take that lines (e.g. containing HTML tags) and load it as a file in your default browser === Book: see also: === Diagram: see also: === File: see also: The TSE macro file 'ShellExe' in the TSE Potpourri menu of TSE v4.x === Help: see also: === Image: see also: === Internet: see also: TSE: Mouse: Macro: Link: Click: How to possibly create hyperlinks in any text document? http://www.faqts.com/knowledge_base/view.phtml/aid/30102/fid/1010 === Podcast: see also: === Screencast: see also: === Table: see also: === Video: see also: --- ----------------------------------------------------------------------