[Last Call] Learn how to a build a cloud-first strategyRegister Now


How to get a Window handle

Posted on 2006-04-13
Medium Priority
Last Modified: 2012-05-05
Hi Experts.
I have an application that is called from IE toolbar with a parameter. This parameter is the window handle (i.e. myApplication.EXE /235468) so myApplication.EXE can manipulate the content of the IE window that send the order. To Explain it more: suppose i open 10 IE windows, when i click a button on the first IE window, it will call my application.exe and send the handle of IE window No.1, if i click the same button but on the second IE window, it will call my application.exe and send the window handle for the second IE window, etc...
So how can i get the handle of the window (that send the order to myapplication) in JavaScript so i can add it to my web toolbar ??
Question by:BMaadarani
LVL 11

Expert Comment

ID: 16446595
Nothing documented.  ref: http://www.javascriptkit.com/jsref/window.shtml .

Closest thing would be window.name - which is optional.  Try this in your address or location box:

Mine came back blank.

This would be OS dependent??  An OS process handle?

Peace and joy.  mvan

Expert Comment

ID: 16446675
I think this would need ActiveX controls...
LVL 11

Expert Comment

ID: 16447551
Yep, ActiveX ...

'Example of how to get the handle of excel using VBA or VB referencing Excel type library
'This is VB / VBA Code!!
Sub TestVBA(handle As Long)
    'Make Excel's caption unique, use in VBA
    Application.Caption = "MY EXCEL"
    'Find Excel's window handle
    handle = FindWindow("XLMAIN", Application.Caption)
End Sub

Of course, needs the proper includes and rewrite for JavaScript.  And would be browser specific as the "XLMAIN" would be replaced by the browser process name.  Because ActiveX, possibly applicable to IE only.

Peace and joy.  mvan
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 11

Accepted Solution

mvan01 earned 250 total points
ID: 16447581
bbbbbb ... I guess you said "IE toolbar." ;)

Previous comment code was adapted from the 7th hit here:


Peace and joy.  mvan

Author Comment

ID: 16448377
I've had the VB code to get a process handle, unfortunately I am not familiar enough with Javascript to convert it.

Expert Comment

ID: 16448396
I do not think you can reach the window handle through any script in a pge.
By the way, as you seem to use a custom made ie toolbar, can't you do this inside this toolbar?

Author Comment

ID: 16448428
Good question, unfortunately I purchased bar control, and I do not have access to the bar source-code.

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question