1

I usually run several browsers at once. And keep changing my default browser randomly because i hate the concept of having a default at any time. I tried using an application that shows me a list instead, but it does not account for the ones that are running or not etc...

Now i just realized, that copying and pasting the URL is the way to go. I know which browsers are open, i know whats on the other tabs. I can look before pasting and change my mind. I can decide if i open a new tab or if i reuse one. i can decide where in the tab list i will open a new one. etc. pasting has several advantages that no browser selector will ever be able to match.

but copying the URL is a pain. specially since i can click by accident while doing so. and then i have to wait for the unwanted browser to open. close it. go back to copying. or i just click by reflex when i see a url i want to read from email...

So, since the "default browser" action is just sending a url to an application, what is the simpler way to send it the clipboard? is there a simple script i can use on windows to do that? on linux i did that with a one liner... but i don't know how to script windows without going full blown and installing cygwin, and i don't want to do that now.

edit 1:

found clip.exe that ships on windows by default, but passing info to it is tricky.

C:\>echo http://asd@asdf.com/?x=1&y | clip
http://asd@asdf.com/?x=1
'y' is not recognized as an internal or external command,
operable program or batch file.

so i tried to add quotes... but now the url in the clipboard also has quotes...

edit 2:

how to use a custom default browser here:

How do I set the Windows default browser, for a custom application, like foobar.exe?

edit 3: This is becoming a big project... will keep adding updates here. The script was taken care of by heavyd answer, so adding to clipboard is solved. but that only takes care of 50% of the problem, making that script the default browser is proving to be a huge problem.

decent way to notify the user (me :) of what happened, and what was copied to the clipboard before i change focus and paste. http://www.paralint.com/projects/notifu/

1

I created a quick batch file that will handle the URL provided. It just escapes the & characters in the URL so that they won't be parsed on the command line.

@echo off
set str=%1
set str=%str:&=^^^&%
echo %str:"=% | clip

You would call the script like this:

to_clipboard.cmd "http://asd@asdf.com/?x=1&y"

If your URLs may contain other reserved characters (|, <, >) you would probably have to escape them separately.

1

Create the batch file provided by heavyd, name it browser.bat In:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\
UrlAssociations\http\UserChoice]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\
UrlAssociations\https\UserChoice]

Change the default key to your batch file e.g. c:\1progs\1scripts\browser.bat

Clear the ProgId key.

Now your links will just be copied to the clipboard so you can paste them to your browser of choice. Additionally you can associate htm, url and html files to your batch file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.