Link to home
Start Free TrialLog in
Avatar of BMaadarani
BMaadarani

asked on

How to get a Window handle

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 ??
Thanx
Avatar of mvan01
mvan01
Flag of United States of America image

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:
javascript:alert(window.name);

Mine came back blank.

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

Peace and joy.  mvan
Avatar of KennyTM
KennyTM

I think this would need ActiveX controls...
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
ASKER CERTIFIED SOLUTION
Avatar of mvan01
mvan01
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BMaadarani

ASKER

I've had the VB code to get a process handle, unfortunately I am not familiar enough with Javascript to convert it.
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?
Good question, unfortunately I purchased bar control, and I do not have access to the bar source-code.