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

Hi I want to find a window by its title and send a message to it using the win32::api module The windows title is an explorer window viewing the directory "C:\" so i guess the title is C:\ I want to send a WM_PASTE message to the window.

Replies are listed 'Best First'.
Re: Win32 api sendmessage
by GrandFather (Saint) on Aug 19, 2008 at 00:04 UTC

    Depending on what you are actually trying to achieve, you may find Win32::GuiTest does the trick for you. It's not driving stuff through the windows messaging system, but may get you where you are going more directly.


    Perl reduces RSI - it saves typing
Re: Win32 api sendmessage
by juster (Friar) on Aug 19, 2008 at 06:01 UTC

    my win32 is very rusty but from what i remember you can't send certain messages willy nilly to windows not created by your application (instance). its somewhat of a security risk if your windows start duking it out.

    to get a list of top-level windows you can use the enumwindows function.

    that very cool module mentioned earlier looks like your best bet... but you might have trouble on vista. i dont really like the idea of programs messing with explorer myself.