Utilizing IE

  • Thread starter Thread starter Nak
  • Start date Start date
N

Nak

Hi there,

I know this isn't 100% relevant in this newsgroup, but maybe someone
knows the answer or knows where to point me in the right direction.

I am making my appliction add an item to the toolbar and to the menu in
Internet Explorer. What I want to happen is when you press the item or
button for my application to launch and to be passed the current URL in the
browser via the command line. I have the application launching perfectly,
but am unsure how to get and pass the current URL.

There were 2 possible ways that I can think of,

1. There may be a variable that IE uses to pass to the application.
So the registry key "Exec" that specifies the location of the executable to
launch when the item is processed could contain the URL variable, i.e.

c:\myapplication.exe %currenturl

2. Launch a script instead of an executable and have the script
obtain the current url and launch the application from there. But I have no
experience of Java script to do this, Just from looking at other scripts
that work very similarly I presume I would be possible to do. Does anyone
know if this is possible?

Basically I'm sure that it must be possible to do this simple task, but
have yet to find a working example anywhere. If anyone has any pointers I
would be most appreciative. Thanks again.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Nick.
The Url is in java Script "document.url"
Some tips that maybe can help you:

I am never sure from this but try it, so dont blame me if some little things
are wrong.

There is mshtml.htmldocument with which you can use the html documentmodel.
There for you have to make a reference to Microsoft.mshtml
D'nt import that, because your code from the file where it is on will become
terrible slow because of the objects that are in it and freezes your IDE at
every declaration.
Just use it as .... as mshtml.htmldocument
If you didn't had this information till now, I think that you can go a lot
further
Cor
 
I think I would use JavaScript. The location object is what you need

in this example you can launch in a new window, but u can mod it

s= new String( state.value )
var loc = location.protocol + "//" + location.hostname +
"/gensurv.nsf/HINT_SURVEY_HEADER_" + s + "?openPage";

var ops =
"height=300,width=400,screenX=100,screenY=500,toolbar=no,scrollbars=yes
,alwaysRaised=yes,locationbar=no";


window.open( loc ,"Survey_Header_Help", ops);


Cheers

--
Regards - One Handed Man

Author : Fish .NET & Keep .NET
=========================================
This posting is provided "AS IS" with no warranties,
and confers no rights.
 
Nick,
Now I see the mail from OHM what I did mail, is about the Url that is in the
document currently in the top page from the browser
To open a document is the normal window.open(Url) like OHM provided
(He added something more, but I did not real look at that)
Maybe I did understand it wrong than sorry for that.
Cor
 
Nick,
Now I see the mail from OHM what I did mail, is about the Url that is in the
document currently in the top page from the browser
To open a document is the normal window.open(Url) like OHM provided
(He added something more, but I did not real look at that)
Maybe I did understand it wrong than sorry for that.
Cor

Thanks for the help Cor, it seems I may may have "upset" Herfried by asking
an OT question. Woops. Thanks loads for your help though ;-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Thanks very much OHM, I shall take a shifty and try to get this sorted.
Thanks for pointing me in the right direction.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Nick,
Can not be, the nicest Javascript I ever got was from Herfried in this
newsgroup when I started here, so I had to contribute something back.
(Mostly I don't get them, but make them myself, I even don't copy them
except the one time fun ones)

The JavaScript is to open the "add favorite window" from out a window form
application.
If you need it, I provide it you.
(The original has a link to Herfrieds site)
So don't take it serious
Cor
 
Hi Nick,

I've only just come on this 'morning' and yours is the first post that
I've seen.

LOL at your new footer. :-D. I'm flattered. I'll have to go along and see
what's in that thread.

====================
On your IE app launching I've got loads of questions and maybe some
answers.

How far have you got? You say you've got onto the toolbar and menu. How
did you do it and how does it launch your proggie? And which toolbar?

Do you want the actual text from the address bar or the location of the
current window?

My understanding is that JavaScript doesn't allow you to execute external
apps from the browser. There's no Exec call that I know. However it's possible
to instantiate the Shell and use that. But that might give you security popups
which ask permission. There's ways round it all.

Do you remember my post about URL protocols? This is a situation where you
can get your app launched via a URL - which JavaScript is quite happy to do
for you.


The following in the URL of a Favourite or Toolbar Link item should do the
trick.

javascript:location.href='nicks-app:' + location.href

once the nicks-app URL protocol has been set up.

Regards,
Fergus
 
Hi Fergus,
How far have you got? You say you've got onto the toolbar and menu. How
did you do it and how does it launch your proggie? And which toolbar?

It was done simply by adding the necessary registry entries, one of
which was a GUID (Hence me asking how to get the GUID out of the assembly
info file). The menu item is in the tools menu of IE and the toolbar item
simply goes into the main toolbar of IE with the "Back", "Home" buttons etc.


http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/ext/tutorials/menu.asp
Do you want the actual text from the address bar or the location of the
current window?

I was hoping to be able to pass the URL that is in the address bar to
the application when it is launched via the command line. If you look at
the above Microsoft URL you will see at the bottom it shows how to configure
a menu item to launch an executable file, I would have loved to have been
able to set the "Exec" to something like..

c:\myprogram.exe %currenturl

So that when it launches my application I can handle the url. But from
what I have seen, this is not possible as IE does not recognize any
variables, bugger :-( So the other way was running a script...
My understanding is that JavaScript doesn't allow you to execute external
apps from the browser. There's no Exec call that I know. However it's possible
to instantiate the Shell and use that. But that might give you security popups
which ask permission. There's ways round it all.

Hmm, that's a little frustrating, the Google toolbar works in a very
similar way to what I want to achieve. You can translate the current page
for example, this runs a script which passes the current url to Google and
processes it in the current window. The shell idea sounds good, I don't
want my application to seem like spyware though, it is simply to run
processes on the page that is being displayed.
The following in the URL of a Favourite or Toolbar Link item should do the
trick.

javascript:location.href='nicks-app:' + location.href

once the nicks-app URL protocol has been set up.

Hmmm, I have no idea about Javascript unfortunately so I have no idea
where the above would be placed and in what context it is being used
(forgive my ignorance). The protocol idea does sound like fun though, maybe
a simple method of passing an URL to an application, hmmm, I'm certainly all
ears, maybe I'm going about the whole thing the wrong way, I'm not sure :-(

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Nick,
As far as I know, is that always been one of the first Security Items: not
to be able to execute a program from the webpage.
In this news group Patrick has given yesterday an example how it is
possible, but only after that the user gives acknowledge.
Formerly VBS script has been downsized to not allow direct access to the
client computer.
And then it had no advantages anymore above JavaScript, I think no serious
developer uses VBScript anymore on the client side.
This non access is one of the most important aspects of from the Browsers
that all software builders have to follow.

An other thing is, there is let say Netscape JavaScript (I do not know if
they where the inventor but they started to make it big) and IE JavaScript,
I thought the method of opening an IE page Fergus did supply you is
Netscape. (IE will mostly eat everything so that is I think no problem).
There is a standard Mozilla, but that is again become a dialect apart.

For that I am happy that Microsoft controls VB.net. When you make a Webpage
you have to use sometimes 4 conditions only for the dialects.

That is stopping. In my opinion only Microsoft has good XML support, so when
you use XML, there is no need anymore to do all those rubbish compatible
things.

So with creating a start from IE to an exe I can not help you. The rest ask
and I think we together can solve it.

Cor
 
Howdy Nick,

Just a quick progress report.

I've installed a new IE menu item and am firing it off via Exec. This works even though it's a VBScript file. Unfortunately, I
can't get it to fire off via Script!!?

Exec won't let me put in parameters (the *&%$) which is pretty poor. Even if it did, though, I can't see how to specify the
current address.

Script may allow parameters but I can't get it working yet. I'll fiddle about a bit more then give up on that. That's just
curiousity as the same 'how to specify' issue arise there too.

The next thing to do is implement the URL protocol method. I'm certain that this can be made to work. The downside is that you
can only use it where IE lets you put URLs - ie. the Favourites menu and the Links toolbar. Can you live with this ?

Catch you later,
Fergus
 
Hit Fergus,

Wow, I really appreciate your help, you seem to be going through allot
of effort, I hope that it's not causing you any stress. It's very much
appreciated though, I still haven't got one reply in the IE newsgroup.
The next thing to do is implement the URL protocol method. I'm certain
that this can be made to work. The downside is that you
can only use it where IE lets you put URLs - ie. the Favourites menu and
the Links toolbar. Can you live with this ?

I would be very interested in seeing how this is implemented either way,
I'm sure I could add another "feature" to my aplette that would utilize
protocols, in fact it would be an idea way to advertise the application on
my site, by having siteshow files etc downloaded right into the application
from 1 click, sounds amazing to me!!

Thanks again Fergus, your a great help :-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Hi Nick,

'Tis all done. Success on a plate.

The solution comprises:

1. Creating your program. [I've supplied a VBScript example]
2. Entering your URL protocol into the registry. [Reg file]
3. Creating a Links in IE on the Links ToolBar.

There's the hard approach given in detail below. [Jump to the end for the easy way]

=================================
Let's start with 2:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\nicks-app]
@="URL: Nicks-App URL protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\nicks-app\DefaultIcon]
@="C:\\Program Files\\.Nick\\WonderApp.exe,3"

[HKEY_CLASSES_ROOT\nicks-app\shell]

[HKEY_CLASSES_ROOT\nicks-app\shell\open]

[HKEY_CLASSES_ROOT\nicks-app\shell\open\command]
@="WScript \"C:\\Tmp\\Nick's App.vbs\" \"%1\""


I've named the URL Protocol "nicks-app". This goes in the Classes list and everything it needs goes under it.

The URL: Blah is simply a descriptive name and can be anything, I believe.

The "URL Protocol=" says that this <is> a URL Protocol.

The DefaultIcon can come from any source.

The important part is what program the Protocol calls. This is under the (perhaps familiar) shell\open\command key and gives the
exe path and %1 for the argument. [There will be only one in this case but %2, etc is ok]

I've used a VBScript for testing which requires WScript. For your app it will be something like:
@=""C:\\Program Files\\.Nick\\WonderApp.exe" %1""

=================================
Step 3.

In IE, make sure that your Links ToolBar is showing. Open any page that has a link on it and drag the link to the Links ToolBar.
This will be the starting point. Now right-click on it and rename it, eg "Nick's App".

Right-click again and select Properties. You'll get the URL Shortcut Properties dialogue, for that is what these ToolBar items
are.

In the URL box, copy the following:
JavaScript: location.href = 'nicks-app:' + document.location

This says use the JavaScript URL Protocol to create a URL using the NicksApp URL Protocol with the current page's address and
make <that> the new address. Just a little hint of recursion there :-)

So if the current page (document.location) is http://www.google.com, it will set the browser's address (location.href) to
"nicks-app:http://www.google.com". This will then cause a lookup in the registry for the "nicks-app" URL Protocol handler which will
redirect the enquiry to "Nicks App.exe". Voila.

"Nicks App.exe" will receive the whole address, ie, "nicks-app:http://www.google.com" and will have to remove the Protocol part.
No worries.

=================================
Step 1.

You already have your own program but here is a VBScript which will show how it all works. As you can see above, the Protocol
expects to find this in "C:\Tmp\Nick's App.vbs".

'Get the command-line arguments from
'WScript (which is running this script)
Set objArgs = WScript.Arguments

'Get the URL Protocol with web page address.
sWebAddr = objArgs(0)

'Remove the Protocol part.
sWebAddr = Mid (sWebAddr, Instr (sWebAddr, ":") + 1)

CrLf = Chr(10) & Chr(13)
MsgBox ("Hi, this is Nick's App" & CrLf & CrLf & sWebAddr)

=================================
And there's the easy way.

All source for the above is in the attached zip (for those with a friendly newsreader).

Extract it to C:\Tmp.
Move "Nick's App.url" to Favorites/Links
Run "Nick's App.reg"
Go into IE and make the Links ToolBar visible.
Click on [Nick's App]
"Hey presto!"

=================================

That's it. Easy once you know how. :-)

Have fun, :-)
Fergus
 
Hi All,

I forgot to add:

If you have read the previous post and would like to know more about URL Protocols, there's an explanation under the topic
"VB.NET Help", dated 30th August 2003.

Regards,
Fergus
 
Howdy Nick,

|| Wow, I really appreciate your help.

Everyone that I help is most welcome. Nick, you are <most> welcome. ;-)

|| I hope that it's not causing you any stress

Thanks for reminding me - I <must> go and empty the ol' bladder - I've left it far to long again. Lol.

|| I still haven't got one reply in the IE newsgroup

Charity begins at home, so they say. Languages.vb is home. We look after our own here. :-D*

|| by having siteshow files etc downloaded right into
|| the application from 1 click, sounds amazing to me!!

I learnt about this a few weeks ago when I started using KazaaPlusPlus (the ad-free file-sharing client). Some of the utilities
set up URL Protocols so that you can go to a web site where there is a list of validated files, click on the link, and it launches a
Kazaa++ utility which adds the URL to the download list. From a web site!! It was amazing to me too. Get your protocol
surreptitiously added to someone's machine and you can create a very useful web site - or a very dangerous one. [Evil grin]

All the best,
Fergus

* For as long as I'm here, anyway. I do keep saying that this is temporary. [He says trying to convince himself]
 
Hi Fergus,

You're a genius. From using your protocol method I have managed to make
a manu item that ultimately launches an application with the current page
url as an argument. Basically what happens is when you click the menu item
it calls a java script that is actually inside of a HTML document, like
so...

<html>
<script language="JavaScript" type="text/JavaScript">
var parentwin = external.menuArguments;
var doc = parentwin.document;
parentwin.location.href = "nicks-app:" +
window.external.menuArguments.location;
</script>
</html>

This naviagtes the current page to the same location but with the
protocol that you made prefixed to the front. This of course then runs an
executable instead of VBScript and voila, the application launches with the
URL passed to it.

And must I say what a complete fanny on, if it wasn't for you delving
into the protocol implementation I don't think I would have ever got this
one, and more to the point, I wonder why they made it this hard to
implement. It basically goes backwards and forwards, but never mind all is
sorted!!! Now my application will be able to process web pages directly
from browser clicks, what could be more convenient?

Thanks again Fergus you have been a life saver :-) Soon new protocols
will be popping up all over the place "willy nilly"!! ;-)

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Fergus,
Nice I did it too in my map, when I need it I use it.
Now I remember that it is possible, it's probably the same as all those
callers do (line changers).
I nock to my head now.
Did you get it from such a page?
;-)))
Cor
 
Hi Nick,

And there's you saying you don't know JavaScript!!

I'm puzzled as to why you've got the script in a web page, though - it does the same as the one-liner. What do you have in the
menu item?

No, I've got it. You mean the <original> menu item - under Tools - and you're not using the Links ToolBar at all. That's
excellent!

Which means you've taught me something back. An equitable exchange, my friend. :-)

|| a complete fanny on

I think I missed something in my education. I know about "hard-ons" (<all> about <them>) - is this the ladies' version? And
while we're on the subject, you be careful with them popping up willies. There can be all sorts of trouble with unfettered willies.

|| It basically goes backwards and forwards

All together now: And the menu bone's connected to the html bone, and the html bone's connected to the browser bone, and the
browser bone's connected to the registry bone, and the registry bone's connected to the protocol bone, and the protocol bone's
connected to the nick's app bone. Oh, hear the word of Microsoft!

No wot ya mean, mate, iss all rahnd the ahziz, innit.

|| Now my application will be able to process web pages
|| directly from browser clicks

Haven't asked yet. What does your app do? Any use to Joe Public (me) or is it specialised stuff?

Regards,
Fergus

============================
Just a touch neater, if that's of any use.

<html>
<script language="JavaScript" type="text/JavaScript">
var parentwin = external.menuArguments;
parentwin.location.href = "nicks-app:" + parentwin.location;
</script>
</html>
 
Hi Cor,

|| it's probably the same as all those callers do (line changers).

'Callers', 'line changers' ??

I'm not sure what a 'line changer' is, so I guess I didn't get it from them. I noticed URL Protocols when I was using Kazaa++,
then I noticed them again when I was exploring the registry one day. This sparked the old curiousity and I dicovered a couple of
articles on the web which "taught me all I know".

Regards,
Fergus
 
All together now: And the menu bone's connected to the html bone, and
the html bone's connected to the browser bone, and the
browser bone's connected to the registry bone, and the registry bone's
connected to the protocol bone, and the protocol bone's
connected to the nick's app bone. Oh, hear the word of Microsoft!
At least now I now what binding is.
 
Back
Top