Nalina has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks
Please tell me how to find the windows handle of excel automated using OLE? For Excel 2002 & higher versions, the hWnd property is added to the Application object. So hwnd for Excel 2002 & higher versions can be found as follows.
use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Constant = Win32::OLE::Const->Load('Microsoft Excel'); $Excel = Win32::OLE->new('Excel.Application', 'Quit') || die "Error launching MS Excel ".Win32::OLE->LastError; $hwnd = $Excel->{"Hwnd"}; print "Excel Windows Handle: $hwnd\n";
How to find it for earlier versions of Excel. I read somewhere that it can be found using FindWindow API call. If so please tell me how to use this API call to find hwnd?

Replies are listed 'Best First'.
Re: How to get windows handle?
by Corion (Patriarch) on Nov 22, 2006 at 10:00 UTC

    I'd just use Win32::GUITest, which has the FindWindowLike function that is quite easy to use. Of course the FindWindow API is documented too. Maybe you can show us where you have problems with using that API? Also, what do you need the window handle for? Maybe there is a solution for your problem where you don't need the window handle ...