'shortcut on desktop' in right-click menu?
Posted by: 666
Date: June 08, 2005 11:09PM

One of the very few good things about IE is the option to right-click on a page and send a shortcut to your desktop.

KM only has an option to send a link to an email client.

Is there a trick to add 'shortcut on desktop' to KMs right-click menu?

Re: 'shortcut on desktop' in right-click menu?
Posted by: Carson
Date: June 08, 2005 11:28PM
Re: 'shortcut on desktop' in right-click menu?
Posted by: Eyes-Only
Date: June 09, 2005 02:56AM

Hmm... correct me if I'm wrong Carson, but when I read that I get the idea that Drakhen is talking about a different kind of shortcut there. It's the kind of shortcut that some programmes install that by clicking upon it gets you to their webpage. Some will use the default browser, some internet shortcuts on the computer insist on using the IE engine. Apparently the new breakthrough is that the build with the 1.8b2 GRE will handle even those.

Of course, as I so frequently am, I could be all wet behind the ears...

Amicalement,

Eyes-Only
"L'Peau-Rouge d'Acadie"

Re: 'shortcut on desktop' in right-click menu?
Posted by: Carson
Date: June 09, 2005 03:22AM

Um . . you're probably right. Sorry, 666.

Re: 'shortcut on desktop' in right-click menu?
Posted by: 666
Date: June 09, 2005 09:41AM

Something like this:

[/url]

Re: 'shortcut on desktop' in right-click menu?
Posted by: 666
Date: June 09, 2005 09:44AM

Damn BBcode...



Re: 'shortcut on desktop' in right-click menu?
Posted by: guenter
Date: June 09, 2005 12:50PM

view image - copy image and then use e. g. irfan view which has that function.
(paste from clipboard & next set as background )

else make macro that calls application to do that can do that
else try to make macro that invokes that function from xul - because Gecko xul has that or calls that.

(but we are possibly hamperd again - by other download procedure of k-m)

Re: 'shortcut on desktop' in right-click menu?
Posted by: 666
Date: June 09, 2005 01:28PM

I think you're mixing up the 'set as background' and 'create shortcut' options.

To create a shortcut to the page this page, you need some code to:

1) make an empty text file

2) copy the location from the address bar into it as:

[InternetShortcut]
URL=http://kmeleon.sourceforge.net/forum/read.php?f=1&i=27152&t=27152

3) save it on the desktop as k-meleon.url .

K-Meleon can send a URL to internet explorer or to an email client. It must be possible to make K-Meleon send a URL to a textfile called (website).url . But how?

Re: 'shortcut on desktop' in right-click menu?
Posted by: sensai
Date: June 09, 2005 04:16PM

hi, I don't think km has the ability to do that at the moment (someone correct me if I'm wrong). As you noticed, it doesn't have a problem to paste a URL into the clipboard and use it from there, but to save this url as shortcut-file it would need an extra function which tolds him to do that. A dll-plugin could easily solve this I think.
I got a vague idea how to write it, wouldn't have a prob to write the function that saves the file, but since there are different windows-versions and also different folder names for specific languages (eg. xp: documents and settings/desktop, xp: Dokumente und Einstellungen/desktop (german vers.), w98: windows/desktop) and perhaps different user-accounts o_O, I'm not really sure how to solve this (without getting headaches ;O) ). Maybe the easiest solution (at least for me ;OÞ) would be to make it like its done with the Mailclient-inquiry(?) macro (e.g. let the user input the path where shortcuts should go himself a single time and store this value as a km-preference). The plugin-function could then use this config-setting for the save part every time. I'm going to play a bit with this in my spare time to see if it works.

cheers,

sensai

Re: 'shortcut on desktop' in right-click menu?
Posted by: guenter
Date: June 09, 2005 07:30PM

probably misssunderstood.


but for what do You need a shortcut to desktop?

You can make bookmark.
actually You could use detour via favourites plugin to create ...
(but that is not a single click thing ... but can be probably automated as macro)

Re: 'shortcut on desktop' in right-click menu?
Posted by: 666
Date: June 14, 2005 05:05PM

Bookmarks are good for sites that you visit often (especially when your bookmarks are stored as plain HTML and you set the bookmark file as your homepage).

But I often find myself at sites with interesting stuff that I want to read once, but later, not now. Having a shortcut on my desktop to remind me beats adding a bookmark to my overcrowded bookmark list.
After I've read the page, deleting a shortcut from my desktop is a lot faster than deleting a bookmark entry from within my browser.

Right now my options are:

1) copy URL from address bar, leave browser window and go to desktop, right-click to make new shortcut, paste in URL, enter a name, click OK.
If the location of the page differs from the URL in the address bar (frames, dynamic content, cloaked URLs, etc.) this trick doesn't work.
So therefore I usually resort to:

2) Right-click page, hit 'view page in IE,' right-click page in IE, click 'create shortcut.'

A method to avoid the detour through my desktop (or worse: IE) would make things a lot easier. Especially for sites that you don't trust enough to allow to load in IE.

Re: 'shortcut on desktop' in right-click menu?
Posted by: Fred
Date: June 14, 2005 06:01PM

If you don't use Favorites as bookmarks in K-Meleon, you can go to
Preferences-->Plugins-->IE Favorites Plugin -->configure and enter manually
your Desktop as location for Favorites, depending on your system
for example C:\Documents and Settings\All Users\Desktop\
(don't forget the last backslash), and save the URL as a favorite.
Then you can't use the other favorites as bookmarks obviously.
You can add K-Meleon to your "Send to"-menu to open the URL.
Hope that it works.
Fred

Re: 'shortcut on desktop' in right-click menu?
Posted by: Fred
Date: June 14, 2005 06:17PM

P.S.
If you want to use your existing Favorites, you can import them
into Netscape bookmarks before changing the location.
Go to Edit bookmarks and press the button "Import Favorites",
to integrate them into bookmarks.
Fred

Re: 'shortcut on desktop' in right-click menu?
Posted by: Carson
Date: June 14, 2005 09:43PM

Well, sure, that is an excellent way to do it. As 666 says, the re is a need to do it very fast (so not to interrupt a train of thought), plus a need to keep these "references in passing" separate from really important bookmarks.

I suppose you could use Opera's system too? Anything that is NOT Bookmarks. And, as long as the second system is handy, it no longer matters whether these things go to desktop or not. The file could point anywhere that's quick to access.

Re: 'shortcut on desktop' in right-click menu?
Posted by: 666
Date: June 16, 2005 11:35PM

Thanx for the suggestion. Didn't really work for me, though, because I use IE favorites for three reasons:

1. Some sites that I visit regularly (like my online banking account) only work in IE.
2. I share my IE favorites between IE and K-M. IE doesn't see Netscape bookmarks so I can't do it the other way around.
3. My favorites folder is a toolbar on my taskbar for easy 2-click access to my bookmarked sites (which open in K-M when I open them from my taskbar; editing 'folder options' took care of that).

Converting my favorites to bookmarks is not an option.

When I change the favorites location in the plugin config screen, K-Ms favorites menu mixes the contents from my favorites folder AND my desktop in one big menu. And not just the shortcuts: every file or folder on my desktop ends up in K-Ms favorites menu too.

Trying to send shortcuts to my desktop didn't work: K-M just ignored my "E:\desktop\" entry and sent them to the default IE favorites folder instead - the very place I tried to keep those links away from!


Any possibility of a script or batch file which converts a 'mailto' link to a desktop shortcut? If yeah, setting that script as K-Ms email protocol app would do the trick.

Re: 'shortcut on desktop' in right-click menu?
Posted by: jsnj
Date: June 17, 2005 03:23AM

Not exactly what you're looking for but KM does support dragging links to the desktop to make a shortcut, if that helps any.

Re: 'shortcut on desktop' in right-click menu?
Posted by: 666
Date: June 26, 2005 10:05AM

The link thing is a step in the right direction. Unfortunately it only works for text links.

Maybe the code responsible for the 'drag link to desktop' feature can be edited?

Re: 'shortcut on desktop' in right-click menu?
Posted by: kko
Date: June 27, 2005 03:15PM

I can offer a solution using Windows Script Host. All work described below takes place in your profile directory.

1) Creating the script

Create a new text file in your profile directory, paste the following lines and rename it to "Shortcut.js".

if (WScript.Arguments.length) {
var Arg = WScript.Arguments;
var WSS = new ActiveXObject("WScript.Shell");
var FSO = new ActiveXObject("Scripting.FileSystemObject");
var LnkName = (Arg.length > 1) ? Arg(1) : "New Internet Shortcut";
var LinkLoc = WSS.SpecialFolders("Desktop") + "\\";
var i=0; for (; FSO.FileExists(LinkLoc+LnkName+((i)?(" ("+i+").url"):".url")); i++);
LnkName += (i) ? (" ("+i+").url") : ".url";
var Lnk = WSS.CreateShortcut(LinkLoc+LnkName);
Lnk.TargetPath = Arg(0);
Lnk.Save();
}

Half of the script is to make sure, that we do not overwrite existing files. The script won't do anything, if no parameters are passed to it.

2) Defining macros

Open macros.cfg with a text editor and paste the following lines (wherever you want, I suggest at the end):

PageToDesktop{
exec("wscript.exe \"".$path."Shortcut.js\" \"".$URL."\" \"".$TITLE."\"");
}
LinkToDesktop{
exec("wscript.exe \"".$path."Shortcut.js\" \"".$LINKURL."\"");
}
FrameToDesktop{
exec("wscript.exe \"".$path."Shortcut.js\" \"".$FrameURL."\"");
}

These macros will execute the script "Shortcut.js" in your profile directory. First parameter is the URL (required). Second parameter is the file name (optional).

3) Defining menu entries

Open menus.cfg with a text editor. Search for "Save{". You should find the following lines (about line 700):

Save{
bookmarks(Add, Bookmark This Page)
favorites(Add, Add Page to Favorites)
hotlist(Add, Add Page to Hotlist)
%ifplugin macros
macros(SavePage, Save Page As...)
macros(EmailURL, Send Page As Link...)
%else
Save Page &As... = ID_FILE_SAVE_AS
%endif
-
}

Before the line "%else" add the line "macros(PageToDesktop, Send Page To Desktop)". This will give you a new entry "Send Page To Desktop" in the context menu of a page. When this entry is selected, the macro "PageToDesktop" is executed.

Search for "Link{". You should find the following lines (about line 775):

Link{
%ifplugin layers
layers(OpenLink, Open in New Layer)
layers(OpenLinkBg, Open in Background Layer)
-
%endif
Open in &New Window = ID_OPEN_LINK_IN_NEW_WINDOW
Open in Back&ground Window = ID_OPEN_LINK_IN_BACKGROUND
-
bookmarks(AddLink, Bookmark This Link)
favorites(AddLink, Add Link to Favorites)
hotlist(AddLink, Add Link to Hotlist)
&Copy Link URL = ID_COPY_LINK_LOCATION
%ifplugin macros
macros(SaveLink, Save Link As...)
macros(LinkInfo, View Link URL...)
macros(LinkInIE, View Link In IE)
%else
Save &Link As... = ID_SAVE_LINK_AS
%endif
}

Before the line "%else" add the line "macros(LinkToDesktop, Send Link To Desktop)".

Search for "Frame{". You should find the following lines (about line 840):

Frame{
Open Frame = ID_OPEN_FRAME
%ifplugin layers
macros(FrameInLayer, Open Frame in New Layer)
%endif
Open Frame in New Window = ID_OPEN_FRAME_IN_NEW_WINDOW
macros(FrameInBack, Open Frame in Background)
-
%ifplugin macros
macros(ReloadFrame, Reload Frame)
macros(SaveFrame, Save Frame As...)
macros(EmailFrameURL, Send Frame As Link...)
%else
Save Frame As... = ID_FILE_SAVE_FRAME_AS
%endif
-
View Frame Info = ID_VIEW_FRAME_INFO
V&iew Frame Source = ID_VIEW_FRAME_SOURCE
}

Before the line "%else" add the line "macros(FrameToDesktop, Send Frame To Desktop)".

4) Restart K-Meleon

Good luck!

Re: 'shortcut on desktop' in right-click menu?
Posted by: sensai
Date: June 27, 2005 09:57PM

good job kko!
It wouldn't work for me, cause I've disabled w-scripting host for security purposes, but I hope the OP will find it useful anyway.

Re: 'shortcut on desktop' in right-click menu?
Posted by: jsnj
Date: June 27, 2005 11:15PM

Nice! Works on all the pages I tested except for movies.yahoo.com. Strange that it works on that page if saved from a link. Might have something to do with the page title($TITLE) because when that was removed from the macro, it saved it but with no title whatsoever, not even 'New Shortcut'. But anyway, works well on all others I tested. :-)

Re: 'shortcut on desktop' in right-click menu?
Posted by: kko
Date: June 28, 2005 01:07AM

Yes, jsnj, setting the title of a page as filename is indeed a potential source of strangenesses. The reason is, that a page's title can contain characters, that are invalid for a filename (like colons). I forgot about that - nobody's perfect ;-)

Here is an updated version of "Shortcut.js":

if (WScript.Arguments.length) {
function Sanitize(string) {
// replace invalid characters by whitespaces
var invalid = new Array('*','"','<','>','|','\\','/',':','?');
for (var i in invalid) string = string.replace(invalid," ");
return string;
}
var Arg = WScript.Arguments;
var WSS = new ActiveXObject("WScript.Shell");
var FSO = new ActiveXObject("Scripting.FileSystemObject");
var LnkName = (Arg.length > 1) ? Sanitize(Arg(1)) : "New Internet Shortcut";
var LinkLoc = WSS.SpecialFolders("Desktop") + "\\";
var i=0; for (; FSO.FileExists(LinkLoc+LnkName+((i)?(" ("+i+").url"):".url")); i++);
LnkName += (i) ? (" ("+i+").url") : ".url";
var Lnk = WSS.CreateShortcut(LinkLoc+LnkName);
Lnk.TargetPath = Arg(0);
Lnk.Save();
}


Re: 'shortcut on desktop' in right-click menu?
Posted by: kko
Date: June 28, 2005 01:16AM

Sorry, something went wrong. I try again:

if (WScript.Arguments.length) {
function Sanitize(string) {
// replace invalid characters by whitespaces
var invalid = new Array('*','"','<','>','|','\\','/',':','?');
for (var t in invalid) string = string.replace(invalid[t]," ");
return string;
}
var Arg = WScript.Arguments;
var WSS = new ActiveXObject("WScript.Shell");
var FSO = new ActiveXObject("Scripting.FileSystemObject");
var LnkName = (Arg.length > 1) ? Sanitize(Arg(1)) : "New Internet Shortcut";
var LinkLoc = WSS.SpecialFolders("Desktop") + "\\";
var i=0; for (; FSO.FileExists(LinkLoc+LnkName+((i)?(" ("+i+").url"):".url")); i++);
LnkName += (i) ? (" ("+i+").url") : ".url";
var Lnk = WSS.CreateShortcut(LinkLoc+LnkName);
Lnk.TargetPath = Arg(0);
Lnk.Save();
}

Re: 'shortcut on desktop' in right-click menu?
Posted by: jsnj
Date: June 28, 2005 11:49AM

Works well now :-)

Re: 'shortcut on desktop' in right-click menu?
Posted by: 666
Date: July 04, 2005 08:08AM

Hi kko!!!

Error box popped up complaining about missing script engine, but after manually associating .js with wscript.exe it works great.

THANX!!!

Re: 'shortcut on desktop' in right-click menu?
Posted by: 666
Date: August 25, 2005 12:54AM

Bug:

When I tried to send http://vowe.net/archives/001639.html to my desktop, it created a dead shortcut with an invalid name that couldn't be changed or deleted.

The problem is with the page title: it contains '::' and the script only removed a single ':'.

Is there a way to fix this? Simply adding '::' to the list of invalid characters in the script didn't work.

Re: 'shortcut on desktop' in right-click menu?
Posted by: kko
Date: August 25, 2005 02:17AM

Fix:

The solution is, to use regular expressions instead of string representations in Sanitize().

function Sanitize(string) {
// replace invalid characters by whitespaces
var invalid = new Array(/\*/g,/"/g,/</g,/>/g,/\|/g,/\\/g,/\//g,/:/g,/\?/g);
for (var i in invalid) string = string.replace(invalid," ");
return string;
}

I hope, we have it now! Have you found a way to get rid of the corrupted file, yet?


Re: 'shortcut on desktop' in right-click menu?
Posted by: kko
Date: August 25, 2005 02:20AM

I should have known it better! Next try:

function Sanitize(string) {
// replace invalid characters by whitespaces
var invalid = new Array(/\*/g,/"/g,/</g,/>/g,/\|/g,/\\/g,/\//g,/:/g,/\?/g);
for (var j in invalid) string = string.replace(invalid[j]," ");
return string;
}

Re: 'shortcut on desktop' in right-click menu?
Posted by: 666
Date: August 26, 2005 11:11AM

Thanx kko!!!

So the full script is:


if (WScript.Arguments.length) {
function Sanitize(string) {
// replace invalid characters by whitespaces
var invalid = new Array(/\*/g,/"/g,/</g,/>/g,/\|/g,/\\/g,/\//g,/:/g,/\?/g);
for (var j in invalid) string = string.replace(invalid[j]," ");
return string;
}
var Arg = WScript.Arguments;
var WSS = new ActiveXObject("WScript.Shell");
var FSO = new ActiveXObject("Scripting.FileSystemObject");
var LnkName = (Arg.length > 1) ? Sanitize(Arg(1)) : "New Internet Shortcut";
var LinkLoc = WSS.SpecialFolders("Desktop") + "\\";
var i=0; for (; FSO.FileExists(LinkLoc+LnkName+((i)?(" ("+i+").url"):".url")); i++);
LnkName += (i) ? (" ("+i+").url") : ".url";
var Lnk = WSS.CreateShortcut(LinkLoc+LnkName);
Lnk.TargetPath = Arg(0);
Lnk.Save();
}


Works great!

Had to put all files from my desktop that I wanted to keep in a folder, close explorer, and purge my desktop with del *.* to get rid of the ghost shortcut, but it's gone now.

I guess the only way to improve the script now is to put it all in an installer that copies the .js to the right place and plugs the right bits into the .cfg files, then drop it on http://kmeleon.sourceforge.net/wiki/index.php?id=KPlugins : )

Re: 'shortcut on desktop' in right-click menu?
Posted by: kko
Date: August 26, 2005 12:43PM

Had to ... purge my desktop with del *.* to get rid of the ghost shortcut...
That's exactly what I did, too!

I guess the only way to improve the script now is to put it all in an installer...
Yes! Would be nice if somebody would do that smiling smiley

Thank you for 'beta testing', 666! Enjoy!

If all proofs stable the next weeks, I will post it to the official macro page...

PS: Somehow based on this one, I've experimented with another macro (script) recently. It would empower you to use Internet Explorer's own "Add to Favorites..." function instead of K-Meleon's i.e. you could select the folder where your bookmark is stored and so on. The only problem is: K-Meleon's favorites plugin does not synchronize the menu. What a pity! :´-(

Re: 'shortcut on desktop' in right-click menu?
Posted by: Arrow
Date: August 27, 2005 03:34AM

Superb kko and thankyou for bringing it up 666, It's a feature I will regularly be using - smiling smiley

K-Meleon forum is powered by Phorum.