Hi all,

 

I’m attempting to close a window using the FindWindow() and SendMessage() functions as documented in MSDN. I can’t get it to work, so I was wondering if anyone might help me see what’s wrong with my code:

 

######################################################

 

use Win32::API;

 

my $findWindow = Win32::API->new( 'user32', 'FindWindow', 'PP', 'P' );

my $sendMessage = Win32::API->new( 'user32', 'SendMessage', 'PIIN', 'P' );

 

my $windowToClose = $findWindow->Call("PGPtray_Hidden_Window","PGPtray_Hidden_Window");

$sendMessage->Call($windowToClose,"WM_CLOSE",0,0);

 

######################################################

 

In particular, I’m not sure whether I’m specifying the correct parameters for each method. (Should the parameters for FindWindow() be ‘PP’, with a return value of ‘P’? And should the parameters for SendMessage() be ‘PIIN’, with a return value of ‘P’?)

 

Thanks in advance,

Rob