You need to be logged in to post in the forums. If you do not have an account, please sign up first.
Saving a website shortcut to the desktop
I am not sure why something as trivial as this has not been implemented in O before?..When I browse (and I do a lot) I do come across websites that I want to review right afterwards, or anyway soon. For that I do save to the webstite URL shortcuts to the desktop. Saving shortcuts to the desktop is trivial in IE, while in O you have to un-maximize O in order to be able to drag the link to the desktop.
Can you implement the IE functionality - Save Shortcut to Desktop?
Thanks.
18. June 2007, 21:34:38 (edited)
The button doesn't work for some websites (e.g. if there is an & in URL ) 
If you want a working button then Save a VBS file with following code in C:\Windows\ folder and name it create_shortcut.vbs :
Then use this button to create a shortcut on desktop:
button

If you want a working button then Save a VBS file with following code in C:\Windows\ folder and name it create_shortcut.vbs :
Set wsArgs=WScript.Arguments
if wsArgs.length=0 Then WScript.Echo "Error":WScript.Quit
Set ws=CreateObject("WScript.Shell")
pos=Instr(wsArgs(0),"//")+2
name=Mid(wsArgs(0),pos,InStr(pos,wsargs(0),"/")-pos)
name=InputBox("Enter name of shortcut :","Name of new shortcut",name)
If Not Len(name) Then WScript.Quit
set sc=ws.CreateShortcut(ws.SpecialFolders("Desktop")+"\\"+name+".url")
sc.targetpath=wsArgs(0)
sc.save()
Then use this button to create a shortcut on desktop:
button
Use this button :
button
button
Bingo!
I must say that now you are getting the geek in me interested in some coding...
I guess I will join the club soon. I learn a couple of things here.
Now if only:
- The whole code was contained in an easy to install solution - a simple drag and drop - without the need to use the VBS code... This way everyone could use the button.
- Don't you think that such option would be useful to users, if implemented in O? I suggest that this functionality is built into 9.5, if possible.
- Would you mind get the Save As prepopulated with teh Page Title entry? That would be great.
Great job and thanks.
I must say that now you are getting the geek in me interested in some coding...
I guess I will join the club soon. I learn a couple of things here.
Now if only:
- The whole code was contained in an easy to install solution - a simple drag and drop - without the need to use the VBS code... This way everyone could use the button.
- Don't you think that such option would be useful to users, if implemented in O? I suggest that this functionality is built into 9.5, if possible.
- Would you mind get the Save As prepopulated with teh Page Title entry? That would be great.
Great job and thanks.
AyushJ,
Any ideas? I went through the WScript and the O ini options.
I see no possibility to pass on or to capture the page's title?
Also, when pressing the Cancel button a shortcut is still created to the desktop, albeit one without a title.
I am starting to believe that the title piece cannot be achieved without JS, but then I am not an expert coder so I may be missing some option to adjust your code and still achieve the desired result.
Thanks. This is cool..
Any ideas? I went through the WScript and the O ini options.
I see no possibility to pass on or to capture the page's title?
Also, when pressing the Cancel button a shortcut is still created to the desktop, albeit one without a title.
I am starting to believe that the title piece cannot be achieved without JS, but then I am not an expert coder so I may be missing some option to adjust your code and still achieve the desired result.
Thanks. This is cool..
Originally posted by eugenm:
Also, when pressing the Cancel button a shortcut is still created to the desktop, albeit one without a title.
I fixed the VBS code in the post above. copy/paste again

I dont think that the title part is possible
Thanks AyushJ
The change works just fine, thanks.
But the absence of the title prepopulation makes the button inconvenient.
It's actually faster to adjust the browser window size, drag and drop the link, and remaximize...
Sigh...
Good try. I learned a thing or 2 about the buttons and the WScript.
One thing that I learned about the O9 buttons is that it should have a capability to pass the page title to the vbs code. If it can pass on the URL it should certainly be able to capture and pass title as well.
What's the deal? Thanks.
The change works just fine, thanks.
But the absence of the title prepopulation makes the button inconvenient.
It's actually faster to adjust the browser window size, drag and drop the link, and remaximize...
Sigh...
Good try. I learned a thing or 2 about the buttons and the WScript.
One thing that I learned about the O9 buttons is that it should have a capability to pass the page title to the vbs code. If it can pass on the URL it should certainly be able to capture and pass title as well.
What's the deal? Thanks.
Save the following code as a VBScript file (or overwrite the create_shortcut.vbs):
Set WSArgs=WScript.Arguments:Dim Name
if WSArgs.length<>1 Then WScript.Echo "Arguments Error!":WScript.Quit
Set fs=CreateObject("Scripting.FileSystemObject")
Set ws=CreateObject("WScript.Shell")
Set Rxp=New RegExp:Rxp.Global=1:Rxp.Pattern="[\\/:\*\?""<>\|]"
Set file=fs.OpenTextFile(WSArgs(0),1,vbFalse)
Name= file.ReadLine
URL=file.ReadLine
file.Close
Desktop=ws.SpecialFolders("Desktop")
Do Until Check(Rxp.Replace(Name,"-"))
Name=InputBox("A file with this name already exists, please type a different name:","Enter name:",Name)
If len(name)=0 then wscript.quit
Loop
Function Check(lName)
If fs.FileExists(Desktop & "\" & Name & ".url") Then Check=False Else Check=True
Name=lName
End Function
Set SC=ws.CreateShortcut(Desktop & "\" & Name & ".url")
SC.TargetPath=URL
SC.Save
In Opera, click Tools - Preferences - Advanced- Downloads - Click ADD
Type create/shortcut in MIME Type field and select Open with other application and select the VBS script as the application
Click OK > OK
Now use this button :
button
Now the script will automatically create the shortcut (without asking you the name) if there is no shortcut on desktop with same name
Tools - Preferences - Advanced - Downloads
Double click create/shortcut in list and change the Open with other application line to:
Double click create/shortcut in list and change the Open with other application line to:
wscript.exe "C:\Windows\create_shortcut.vbs"
What happens when you click the button ??
Try these and try:
1. Remove the vbs from the File extension field in the dialog box.
2. Run these commands from Command Prompt (note that this will change the default action of VBS files):
Try these and try:
1. Remove the vbs from the File extension field in the dialog box.
2. Run these commands from Command Prompt (note that this will change the default action of VBS files):
- assoc .vbs=VBSFile
- ftype VBSFile=%SystemRoot%\System32\WScript.exe "%1" %*
#2.1 worked. Thanks a lot.
Now I do have an option that is sufficient for my normal use.
I hope that the Opera team can add some solution within the browser code..
This should not be so complicated.
Thanks again. Case closed and over to the Dev team...
And if the Opera dev team reads this thread - please have a look at the Save page with annotations idea and see if that could be implemented. Thanks Opera!
Now I do have an option that is sufficient for my normal use.
I hope that the Opera team can add some solution within the browser code..
This should not be so complicated.
Thanks again. Case closed and over to the Dev team...
And if the Opera dev team reads this thread - please have a look at the Save page with annotations idea and see if that could be implemented. Thanks Opera!
UPDATED for 9.50
Ayush's trick has been working well for many months, but changes in Opera version 9.50 seem to have broken it. I offer here a revised edition that should work both with 9.50 and previous versions, along with a couple of enhancements:
Save the following code as a VBScript file, or overwrite your existing create_shortcut.vbs:
For first-time readers, bind this script to Opera as per Ayush's original instructions:
Now use this UPDATED button, slightly different from the original:
button
Technical explanation:
The previous script used a line break between "title" and "URL", but line break characters now appear to be stripped before the MIME handler receives them. I don't think I've ever seen a space character in a URL, so I use that as the separator, and swapped the order in which they're passed to the script (now "URL" space "title"). I experimented with characters that are actually illegal in the formal spec for URLs, but all these seem to get stripped.
KNOWN BUGS
UTF-8 characters in a page's title seem to get mangled into pseudo-ASCII when turned into a filename. I'd welcome any VBS gurus who might know how to improve this.
HUGE THANKS to Ayush for the original implementation, saving me countless hours of research and frustration.
Ayush's trick has been working well for many months, but changes in Opera version 9.50 seem to have broken it. I offer here a revised edition that should work both with 9.50 and previous versions, along with a couple of enhancements:
- Bugfix to the "Check if already exists" logic, checking after replacing invalid characters.
- Easier to customize; for example, I like using these instead:
ReplacementChar="_" Folder=ws.SpecialFolders("MyDocuments") & "\My Downloaded Files"
Save the following code as a VBScript file, or overwrite your existing create_shortcut.vbs:
Set WSArgs=WScript.Arguments:Dim Name
if WSArgs.length<>1 Then WScript.Echo "Arguments Error!":WScript.Quit
Set fs=CreateObject("Scripting.FileSystemObject")
Set ws=CreateObject("WScript.Shell")
Set Rxp=New RegExp:Rxp.Global=1:Rxp.Pattern="[\\/:\*\?""<>\|]"
Set file=fs.OpenTextFile(WSArgs(0),1,vbFalse)
NameURL=file.ReadLine
file.Close
line=Split(NameURL, " ", 2)
URL=line(0)
Name=line(1)
ReplacementChar="-"
Folder=ws.SpecialFolders("Desktop")
Do
Name = Rxp.Replace(Name,ReplacementChar)
filename = Folder & "\" & Name & ".url"
If Not fs.FileExists(filename) Then Exit Do
Name=InputBox("A file with this name already exists, please type a different name:","Enter name:",Name)
If len(Name)=0 Then wscript.quit
Loop
Set SC=ws.CreateShortcut(filename)
SC.TargetPath=URL
SC.Save
For first-time readers, bind this script to Opera as per Ayush's original instructions:
In Opera, click Tools - Preferences - Advanced- Downloads - Click ADD
Type create/shortcut in MIME Type field and select Open with other application and select the VBS script as the application
Click OK > OK
Now use this UPDATED button, slightly different from the original:
button
Technical explanation:
The previous script used a line break between "title" and "URL", but line break characters now appear to be stripped before the MIME handler receives them. I don't think I've ever seen a space character in a URL, so I use that as the separator, and swapped the order in which they're passed to the script (now "URL" space "title"). I experimented with characters that are actually illegal in the formal spec for URLs, but all these seem to get stripped.
KNOWN BUGS
UTF-8 characters in a page's title seem to get mangled into pseudo-ASCII when turned into a filename. I'd welcome any VBS gurus who might know how to improve this.
HUGE THANKS to Ayush for the original implementation, saving me countless hours of research and frustration.
I followed the latest instructions, but I can't get this to work in Opera 10.10.
Whenever I click the button I placed on my address bar, I get the following:
Error!
Invalid URL
The URL http://document.location=%27data:create/shortcut,%27+document.URL+' '+document.title; contains characters that are not valid in the location they are found.
The reason for their presence may be a mistyped URL, but the URL may also be an attempt to trick you into visiting a Web site which you might mistake for a site you trust.
thanks
Whenever I click the button I placed on my address bar, I get the following:
Error!
Invalid URL
The URL http://document.location=%27data:create/shortcut,%27+document.URL+' '+document.title; contains characters that are not valid in the location they are found.
The reason for their presence may be a mistyped URL, but the URL may also be an attempt to trick you into visiting a Web site which you might mistake for a site you trust.
thanks
nynahs04, it works fine for me in Opera 10.10. Perhaps you are missing the "javascript:" portion of the URL.
The following line, or one like it, should be found in your standard toolbar (1).ini file, which under Windows XP is located in C:\Documents and Settings\(YOUR USERNAME)\Application Data\Opera\Opera\toolbar\
Not your fault for missing that. Looks like the forum software here is safety-zealous, and strips off the "javascript:" prefix when generating a clickable link from the following forum code:
button
[ URL=opera:/button/Go%20to%20page,%20%22javascript:document.location='data:create/shortcut,'+document.URL+'%20'+document.title;%22,1,,%22Bookmark%20Unvisited%22 ]button[ /URL ]
UPDATED for UTF-8
Good news! By replacing FileSystemObject.OpenTextFile with ADODB.Stream.LoadFromFile, web page titles with non-ASCII characters are now correctly stored in the shortcut's file name.
Here is the revised create_shortcut.vbs in its entirety. With a couple more bonus tweaks since I last posted:
The following line, or one like it, should be found in your standard toolbar (1).ini file, which under Windows XP is located in C:\Documents and Settings\(YOUR USERNAME)\Application Data\Opera\Opera\toolbar\
[Customize Toolbar Custom.content] Button0, "Send to Desktop"="Go to page, "javascript:document.location='data:create/shortcut,'+document.URL+' '+document.title;", 1, "Send to Desktop", "Bookmark Unvisited""
Not your fault for missing that. Looks like the forum software here is safety-zealous, and strips off the "javascript:" prefix when generating a clickable link from the following forum code:
button
[ URL=opera:/button/Go%20to%20page,%20%22javascript:document.location='data:create/shortcut,'+document.URL+'%20'+document.title;%22,1,,%22Bookmark%20Unvisited%22 ]button[ /URL ]
UPDATED for UTF-8
Good news! By replacing FileSystemObject.OpenTextFile with ADODB.Stream.LoadFromFile, web page titles with non-ASCII characters are now correctly stored in the shortcut's file name.
Here is the revised create_shortcut.vbs in its entirety. With a couple more bonus tweaks since I last posted:
- URL is used as title for pages with no title of their own
- If file name is too long, or shortcut fails to create for some other reason, prompt is shown to edit the name.
Set WSArgs=WScript.Arguments:Dim Name
if WSArgs.length<>1 Then WScript.Echo "Arguments Error!":WScript.Quit
Set fs=CreateObject("Scripting.FileSystemObject")
Set ws=CreateObject("WScript.Shell")
Set Rxp=New RegExp:Rxp.Global=1:Rxp.Pattern="[\\/:\*\?""<>\|]"
Set objStream = CreateObject( "ADODB.Stream" )
objStream.Open
objStream.Type = 2 'adTypeText
objStream.Charset = "utf-8"
objStream.LoadFromFile WSArgs(0)
NameURL = objStream.ReadText
objStream.Close
line=Split(NameURL, " ", 2)
URL=line(0)
if UBound(line)<1 then
Name=line(0)
else
Name=line(1)
end if
ReplacementChar="_"
Folder=ws.SpecialFolders("Desktop")
Do
Name = Rxp.Replace(Name,ReplacementChar)
filename = Folder & "\" & Name & ".url"
If fs.FileExists(filename) Then
Name=InputBox("A file with this name already exists, please type a different name:","Enter name:",Name)
else
On Error Resume Next
MakeShortcut
If err.Number=0 Then Exit Do
Name=InputBox("Could not create shortcut file, please type a different name:","Enter name:",Name)
end if
If len(Name)=0 Then Exit Do
Loop
Sub MakeShortcut
Set SC=ws.CreateShortcut(filename)
SC.TargetPath=URL
SC.Save
End Sub
I rewrote the script. I think that mine is the best one, but I would like other people to test it.
Create shortcut:
https://gist.github.com/2967901/
Create shortcut:
https://gist.github.com/2967901/
- Create a folder for storing the script.
- Go to the script on GitHub > Right click on "raw" > Save Linked Content As... > Save the WSF file to your folder.
- Opera > Settings > Preferences... > Advanced > Downloads > Add... > Under "MIME type", type "create/shortcut" > Select "Open with other application:" > Under "Open with other application:", select "Choose..." > Select the WSF file > OK > OK.
- Add this button.
- Drag the button to the toolbar.
encodeURI('
opera:/button/Go to page, "javascript:(function () { \'use strict\'; var document = window.document; var location = window.location; var newline = \'%250D%250A\'; var title = document.title; var uri = location.href; location.assign(\'data:create/shortcut;charset=utf-8,\' + encodeURIComponent(encodeURIComponent((title.length > 0 ? title : uri)) + newline + encodeURIComponent(uri))); }());", 1, "Create shortcut", "External Hyperlink"
')
I have also proposed a feature that allows you to save a shortcut file from the Save As dialog. See here if you are interested:
Save as shortcut (URL) file:
http://my.opera.com/community/forums/topic.dml?id=1443892
Save as shortcut (URL) file:
http://my.opera.com/community/forums/topic.dml?id=1443892
Hello there, I am coming back to Opera after leaving for years to Firefox!
I do miss a few addons and this function is one of them.
XP1, I just tested your script and I get a dialogue popup with the following:
Is it something I am doing wrong?
I followed the steps and that is what happens when I click the button...
Thanks.
I do miss a few addons and this function is one of them.
XP1, I just tested your script and I get a dialogue popup with the following:
--------------------------- Windows Script Host --------------------------- Script: C:\Program Files\Opera\scriptss\Create shortcut 1.00.wsf Line: 1 Char: 3 Error: Unexpected tag - expecting the tag 'job' or 'package' : html Code: 800400C1 Source: Windows Script Host --------------------------- OK ---------------------------
Is it something I am doing wrong?
I followed the steps and that is what happens when I click the button...
Thanks.
24. June 2012, 22:15:04 (edited)
Originally posted by FaeGiN:
What Windows are you using? Try editing the WSF file by removing "<?xml version="1.0" encoding="utf-8"?>" at the top.XP1, I just tested your script and I get a dialogue popup with the following:
I'm guessing that you didn't save the actual file because you had automatic redirection turned off. Try re-saving the WSF file from GitHub. Instead of Saved Linked Content As..., click on the "raw" link. You should see the file. The first line should be "<?xml version="1.0" encoding="utf-8"?>". Ctrl + S to save.
Works great for me. Thanks for the update, XP1!
TIP for novices: to store the shortcuts somewhere besides the desktop, find the following line near the bottom of the .WSF file,
and edit it as you see fit. Examples:
TIP for novices: to store the shortcuts somewhere besides the desktop, find the following line near the bottom of the .WSF file,
var desktopPath = shell.specialFolders("Desktop");
and edit it as you see fit. Examples:
var desktopPath = shell.specialFolders("MyDocuments") + "/" + "My Downloaded Files";
var desktopPath = "E:/My Web Files/Shortcuts";