Groups | Blog | Home
all groups > dotnet scripting > october 2007 >

dotnet scripting : Adding to the RMB menu in IE



David Thielen
10/11/2007 3:33:00 PM
Hi;

This may be the wrong NG for this question. If so, please let me know what
NG to go to.

I need to create a script/program/??? that is added to IE (not to the web
page) that is a small program that has 2 items added to the RightMouseButton
menu. When those lines are clicked, I need to get all text from the webpage
that is selected, do some vary simple text operations on it, and then launch
another copy of IE to a url. The url includes some of the selected text.

How can I do this?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

v-wywang NO[at]SPAM online.microsoft.com
10/12/2007 12:00:00 AM
Hello Dave,

According to your description, what you need is to add a new entry into IE
context menu.When clicked on this new entry, it launches another copy of IE
to the url which we selected. If I misunderstood anything here, please feel
to correct me.

If this is the case, you may refer to the following article
http://msdn2.microsoft.com/en-us/library/aa753589.aspx
[Adding Entries to the Standard Context Menu]

At first, we should add a new entry into Windows Register.
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\New Test]
@="C:\\ mytest.html"

Then, copy the following code snippet as mytest.html on your disk.
<SCRIPT LANGUAGE="JavaScript" defer>
var parentwin = external.menuArguments;
var doc = parentwin.document;
var sel = doc.selection;
var rng = sel.createRange();
var str = new String(rng.text);
var regex = /^http:\/\//;

if(str.length==0) {
// if we didn't get a page assume the current one.
str = doc.URL;
}

if(! regex.test(str)) {
str = "http://" + str;
}

//open(external.menuArguments.location.href=str);
windows.open(window.location.href=str);
</SCRIPT>

Last, please restart your IE. You will notice there is a new entry "New
Test" on the context menu.

But, please note the entry we inserted into Context Menu is only on one
level. We cannot create them as Script/Program/???.

Hope this helps. Please feel free to let me know if there is anything
unclear or you face any further issue. We are glad to assist you.

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
David Thielen
10/12/2007 2:00:33 PM
I think this will work - thank you.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




[quoted text, click to view]
v-wywang NO[at]SPAM online.microsoft.com
10/15/2007 12:00:00 AM
You are welcome, Dave.

Have a great day.
Best regards,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
David Thielen
10/25/2007 3:31:01 PM
Hi;

It turns out we need to do some small processing on the text selected. Is
there a way to write an IE AddIn in C# or C++?

Again, we need to add 2 items to the RightMouse menu and when those are
clicked on, our code can get the text presently selected in IE, do some
manipulations on the text, then launch another browser (or tab) to a URL that
is based on the selected text.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




[quoted text, click to view]
v-wywang NO[at]SPAM online.microsoft.com
10/26/2007 12:00:00 AM
Hello Dave,

We need to perform more research on this issue . We will reply here as soon
as possible.
If you have any more concerns on it, please feel free to post here.

Thanks for your understanding!
Best regards,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
wawang NO[at]SPAM online.microsoft.com (
10/29/2007 12:00:00 AM
Hi Dave,

Note the javascript in the html file can use ActiveX components to do
various stuff. I don't think you have to create a full IE add-on (called
Browser Helper Object, BHO for short) to do this. Of course, this will
depend on your detailed requirement.

For example:

<SCRIPT>
var shell = new ActiveXObject("WScript.Shell");
shell.run("iexplore \"" + external.menuArguments.document.URL + "\"");
</SCRIPT>


Let me know which method do you want to use and we can discuss more about
that.


Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
David Thielen
10/29/2007 10:28:02 AM
BHO sounds like what we need - is there a url that shows how to create &
install one?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




[quoted text, click to view]
wawang NO[at]SPAM online.microsoft.com (
10/30/2007 12:00:00 AM
Hi Dave,

I think following blog could probably help:

#Nico's WebLog : Calling into your BHO from a client script
http://blogs.msdn.com/nicd/archive/2007/04/18/calling-into-your-bho-from-a-c
lient-script.aspx



Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
AddThis Social Bookmark Button