topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday March 19, 2024, 1:16 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: SelectoSurf v1.1.0 - Jan 25,2008 - AutoHotkey script to open plaintext URLs  (Read 63307 times)

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
mouser

I try "this word". Wonderful !!!!

IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,540
  • @Slartibartfarst
    • View Profile
    • Read more about this member.
    • Donate to Member
@mouser: I had seen neither this discussion thread nor this NANY AHK app before, so I downloaded the app and cribbed the AHK code, inserting it into my main AHK file (maintaining references to the source).
I made a change to the code because my default search engine is DuckDuckGo, so, where the code had:
Code: Autohotkey [Select]
  1. theurl = http://www.google.com/search?hl=en&q=`%22%theurl%`%22
- I put:
Code: Autohotkey [Select]
  1. ;theurl = http://www.google.com/search?hl=en&q=`%22%theurl%`%22
  2. theurl = http://duckduckgo.com/?q=`%22%theurl%`%22
(i.e., commenting out the Google search.)

Also, where you had written in the code comments:
Code: Autohotkey [Select]
  1. ; otherwise a google (or other) search will be confucted with the phrase.
- by "confucted"did you mean "conflated"?    :tellme:

I have for a long time now been wanting to automate this URL/search string process, as it is something that I frequently need to do and it is tedious (manually repetitive) and inefficient.
Using the code you provide could potentially save me accumulated hundreds of hours in the future, so thankyou very much.

By the way, whilst I was playing about with the code, I compared using the code to search for a string with Google and then with DuckGo, there was an interesting difference (see below). The text I selected for the search was "SelectoSurf":

Google gave 4 results:

SelectoSurf AHK - 01 Google search.jpg


DuckGo gave 1 summary result:

SelectoSurf AHK - 02 DuckGo search.jpg


I'd say the DuckGo output was the more efficiently organised.
« Last Edit: February 05, 2014, 09:49 PM by IainB »

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
 ;D

Since Skwire made the wonderful ControTextTool I use duckduck for reasonable reasons !!!!!!!
I specially like the only page browsing method to select all about the string searched.
Sometimes I don't feel confortable because of the reasons given by IainB, but at the present time I am 75% DDG and 25% Google or other search engines.

A few days ago I found Yandex that seems to be in the backyard of DDG. And the Yandex browser seem very familiar with Google Chrome....

Since last year I was trying to download the Oscar Ceremony Awards 2012 from everywhere : emule, torrents, etc. with no success until finally i get a copy in russian.
Here in Spain is very difficult to obtain a copy of those events. Even two or more years ago. Now seems easy with torrents. I am not talking about see that ceremony a month after the celebration. I am talking about see the ceremony of the oscars 2012 now, and the oscars 2013 next year.....

Even I obtain my first yandex account. Just because more and more russians come to canary islands and is interesant to learn russian or at least have an account from russian specially now they translate to english everything.

In my opinion there is a total globalization with impredictible results. Not obviously in the knowledge of people or feel more near. I refer to this race where seems only a winner must stay.

And the winner seems to be google......

 :P






IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,540
  • @Slartibartfarst
    • View Profile
    • Read more about this member.
    • Donate to Member
@Contro: Ah, I begin to see why you would be interested in searches.
I am not sure whether you know it, but there are also some rather good search aids in @mouser's FARR - the built-in search aliases:

SelectoSurf - FARR search comparison (850x530).png

The default is the first one - Google. If you wanted to change the order and make another one the default, you could do that, but you'd presumably need to ask @mouser to change it as those aliases are apparently locked (read-only). Similarly, if you wanted to add a new search engine - e.g., (say) Yandex - then you'd need to ask @mouser to make a change for that too.
(I suppose it might be better if the FARR search alases were preset as now, but editable, with a "Restore to default" button for if the user had made a mess of things or just wanted to get whatever were the current FARR version's search alias defaults/presets.)

IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,540
  • @Slartibartfarst
    • View Profile
    • Read more about this member.
    • Donate to Member
Posted at: Re: hotkey to launch google search in a new firefox tab
@mouser provided a rather nifty bit of code for AutoHotKey use (called Selectosurf) to do what you seem to want. You just select the text or URL that you want to search for, press the hotkeys Ctrl+Space (this can be changed), and the search engine of your choice (see lines 88, 89 in the code window below), and your browser opens a search result panel/window.
If you search on the DC Forum for Selectosurf, you will come up with these discussion threads:

I use it as per below, to invoke a duckduckgo search. It's rather fast. It puts the search string as a specific literal inside double quotes though, which you might want to change or vary.

Code: Autohotkey [Select]
  1. SelectoSurf:    ;Sends selected plaintext url or other string and opens it in a browser or search.
  2. ;  Based on SelectoSurf by [email protected]
  3. ;  see https://www.donationcoder.com/Forums/bb/index.php?topic=6714.0
  4. ; v 1.1.0, Jan 25, 2008 - improved browser option, added split-line reconstruction, added about box
  5. ; v 1.0.2, Nov 10, 2006 - initial release
  6. ;
  7. ; Select plaintext in any program and hit the hotkey (ctrl+space)
  8. ; If the text looks like a url or website name (like donationcoder.com), it will be opened
  9. ;  otherwise a google (or other) search will be confucted with the phrase.
  10. ;------------------------------------------------------------------
  11. ; ATTN, OPTIONAL: configure a specific browser overide, to bypass using default
  12. ;browserexe = iexplore.exe
  13. ;browserexe = C:\Program Files\Mozilla Firefox\firefox.exe
  14. ;------------------------------------------------------------------
  15. temp = %clipboard%      ; grab old clipboard
  16. Send, ^c                ; send ctrl+C to copy new text to clipboard
  17. Sleep 100               ; sleep a tiny bit to give a chance for clipboard to propage
  18. theurl = %clipboard%    ; *potential* url
  19. ;
  20. ; merge split lines
  21. StringReplace, theurl, theurl, `r`n,, All
  22. StringReplace, theurl, theurl, `r,, All
  23. StringReplace, theurl, theurl, `n,, All
  24. ;
  25. ; clean spaces
  26. StringReplace, theurl, theurl, %A_Space%,`%20, All
  27. ;
  28. ; Lets do some other common replacements
  29. StringReplace, theurl, theurl, hxxp:,http:, All
  30. StringReplace, theurl, theurl, hxxps:,http:, All
  31. StringReplace, theurl, theurl, h??p:,http:, All
  32. StringReplace, theurl, theurl, h??ps:,http:, All
  33. ;
  34. ; remove any leading or trailing () [] . " '
  35. theurl := RegExReplace(theurl, "^[\.\(\)\'\[\]""]+")
  36. theurl := RegExReplace(theurl, "[\.\(\)\'\[\]""]+$")
  37. ;--------------------------
  38. ; is it a full url
  39. isaurl = 0
  40. IfInString, theurl, http:
  41. {
  42.         isaurl = 1
  43. }
  44. else IfInString, theurl, https:
  45. {
  46.         isaurl = 1
  47. }
  48. else IfInString, theurl, mailto
  49. {
  50.         isaurl = 1
  51. }
  52. else IfInString, theurl, ftp:
  53. {
  54.         isaurl = 1
  55. }
  56. else IfInString, theurl, www.
  57. {
  58.         isaurl = 1
  59. }
  60. else IfInString, theurl, .com
  61. {
  62.         isaurl = 1
  63.         theurl = www.%theurl%
  64. }
  65. else IfInString, theurl, .net
  66. {
  67.         isaurl = 1
  68.         theurl = www.%theurl%
  69. }
  70. else IfInString, theurl, .org
  71. {
  72.         isaurl = 1
  73.         theurl = www.%theurl%
  74. }
  75. else
  76. {
  77.         ; @sign with no spaces is an email
  78.         ; ATTN: toddo
  79.         if (0==1)
  80.                 {
  81.                 ; add a mailto
  82.                 theurl = mailto:%theurl%
  83.                 isaurl = 1
  84.                 }
  85.         else
  86.                 {
  87.                 ; search for the string - note this makes isaurl true always, which is what we want.
  88.                 ;theurl = http://www.google.com/search?hl=en&q=`%22%theurl%`%22
  89.                 theurl = http://duckduckgo.com/?q=`%22%theurl%`%22
  90.                 isaurl = 1
  91.                 }
  92. }
  93. ;--------------------------
  94. ; launch it?
  95. if (isaurl = 1)
  96. {
  97.         ; beep?
  98.         ; SoundBeep
  99.        
  100.         ; launch explorer with url
  101.         if (browserexe != "")
  102.                 {
  103.                 Run, %browserexe% %theurl%
  104.                 }
  105.         else
  106.                 {
  107.                 Run %theurl%
  108.                 }
  109. }
  110. ;--------------------------
  111. ; restore clipboard
  112. clipboard = %temp%
  113. ;--------------------------
  114. ; all done
  115. return
  116. ;--------------------------

IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,540
  • @Slartibartfarst
    • View Profile
    • Read more about this member.
    • Donate to Member
Posted at: Re: hotkey to launch google search in a new firefox tab
Thanks a ton IaianB!
Riding on your script from Mouser, I made an ahk script to find Firefox, create a new tab, and open the search results:
...
_______________________________

I'm very pleased to see that it was of use/help.
I see that your nice and short script uses the AHK InputBox, and is browser-specific.

I am always interested in trying out scripts and proggies to test them to see whether they do what they were intended/designed for, and what makes them fail, and what they do when they fail or are presented with input that was not necessarily intended in their design - for example, what they might do when things cause them to fail in some manner.

Testing a script under different conditions is useful, because the good/effective or bad things about a script might not always be immediately apparent. In the case of Selectosurf some interesting points/features/possibilities are:
  • 1. Housekeeping: The script makes a copy of the Clipboard current state before sending a copy command to capture the text highlighted by the user. At the end of the script, the saved clipboard state is replaced, overwriting any changes that the script may have made to the clipboard whilst the script was running. So you won't see the copied text in (for example) the CHS (Clipboard Help and Spell) list of recently copied text (it's called the "QuickPaste" list in CHS). It is good practice for a script to do some tidy up housekeeping after itself like this. But you might not want that. You might want to (say) keep any text you searched for, retained in QuickText. You can modify the script to do that by commenting out the housekeeping bits.

  • 2. Browser: You can get it to use either the system default browser, or a specific browser which might not be the system default browser. This allows flexibility under the user's control.

  • 3. Search engine: You have to specify the search engine in the parameters sent to the browser. This allows flexibility/choice under the user's control. However, you could modify this to just passing the assembled search text to the browser address bar ("awesome bar"), which could have been already set to apply that browser's default search engine to whatever was put in the address bar. More user choice.

  • 4. Failure state: (Potentially very useful.) If the user does not select any text and presses the hotkeys to activate Selectosurf anyway, then the script does not fail (it makes a null copy capture) but picks up the last thing you happened to copy into the clipboard - could be an image or text, for example.
    If you happen to be setting about collecting lots of material and references to search, then knowing this enables you to turn the combination of Selectosurf and CHS' QuickPaste (or whatever other Clipboard manager you might be using) into an incredibly useful. time-saving combination tool. You could go around copying the chunks of text - which may be either specific strings of text that you want to research or which may include some such specific strings in disconnected form. You can then select (click on) each item in turn from the CHS QuickPaste list and invoke Selectosurf in the usual way, for that item (ensure your mouse is not selecting any text at the time).
    This works because selecting the item from the QuickPaste list pushes it into the Clipboard as "the last copied item", which is what Selectosurf falls back on when it makes a null copy capture (as above).
    Before you do that though, if the item is a larger lump of text containing some text that would be irrelevant for a required search, then you can quickly edit it in CHS to reduce it to just that specific text string that you want to search for, and that goes into the QuickPaste list.
    General note: You probably need to be mindful of whether you want the script to constrain the string to be an explicit literal field (inside double quotes):
    e.g. something like:
    •          
Code: Autohotkey [Select]
  1. theurl = http://duckduckgo.com/?q=`%22%theurl%`%22
or approximate (without quotes):
  •          
Code: Autohotkey [Select]
  1. theurl = http://duckduckgo.com/?q=%theurl%
    - when it is sent/put into the search box, as this will necessarily govern the outcome - i.e., the search result.
    (After some experiment, I think I find the latter more useful.)

    [/li]
    [li]5. Autocopy: If you have Firefox, you can use the AutoCopy extension:
    Select text on any web page and it will be automatically copied to the clipboard. It works in much the same way as does Trillian or mIrc.
    Paste on middle click into textboxes, the url bar, and the search bar.
    _______________________________________________
    For capturing text strings containing more than one word, you have to select them all using the mouse, whereupon they are copied to the Clipboard.
    For capturing text strings containing just one word, double-clicking on the single word selects and copies that single word to the Clipboard.
    As above in point 4, if using (say) CHS:
    You can then select (click on) each item in turn from the CHS QuickPaste list and invoke Selectosurf in the usual way, for that item. This works because selecting the item from the QuickPaste list pushes it into the Clipboard as "the last copied item".  Before you do that though, if the item is a larger lump of text containing some text that would be irrelevant for a required search, then you can quickly edit it in CHS to reduce it to just that specific text string that you want to search for, and that goes into the QuickPaste list.
    _____________________
    With a clipboard manager such as (say) CHS, this can be very handy/speedy when gathering reference strings, as it puts them into the "latest captures" list - the QuickPaste list. If you select a string, using the mouse, and then invoke Selectosurf, the selected item goes into the Clipboard (and thus the CHS QuickPaste list) before Selectosurf saves the Clipboard state and makes its own copy of the selected item (which copy is later expunged when the script exits).
    The degree of control possible over CHS puts the user in full control of using things like the QuickPaste list and even the content and order/sequence of items on it, making it an ideal tool for this sort of repetitive collection-and-research process.
    [/li]

I mention these points/features/possibilities because you describe your nice and short script as being derived from ("Riding on") the Selectosurf script, and your script uses the AHK InputBox, and is browser-specific.
The InputBox could be an area for potential process improvement, by eliminating it altogether when/if it is redundant.
It thus occurred to me that you might be unaware of the above Selectosurf points/features/possibilities. I imagined you manually typing each search string (text item) into the InputBox, and wondered how many times that might be repeated with different/new strings and how many hours that might consume over a researcher's lifetime, when one could perhaps easily automate the data capture aspect to a major extent, thus avoiding most/all of the manual input, and leaving you at liberty to use the freed up cognitive surplus for something more interesting/enjoyable.

So, just some thoughts. Hope they are not too jumbled.

I abhor using manual processes where automation can be more usefully applied, and I am often appalled when I come across some unnecessary and repetitive tedium that we have unwittingly imposed upon ourselves or others.

All kudos to @mouser and his Selectosurf and CHS.

IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,540
  • @Slartibartfarst
    • View Profile
    • Read more about this member.
    • Donate to Member
After making the above posts, I commented out the "housekeeping" lines 15 and 112 in my SelectoSurf script (above), so now CHS and the QuickPaste menu also contain any recent search strings passed to SelectoSurf (they would previously have been expunged).
My view is that this is collecting potentially useful clipboard detritus which I can always delete later if I don't need it for anything.

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Running to see  ;D
Best Regards