hi there. I've been trying to work this out for a few days now. Im trying to script an ftp client to backup files from a server. using a program called ftprush. this allows the user to script commands via the windows api sendmessage. I want to be able to call this via perl and send some files as a backup server. the website provides a dll and a .exe file for doing this. but reading though the file I'm sure it can be intergrated. here is the code I've attempted.
use Win32::GUI; use Win32::API; my $rushhandle = Win32::GUI::FindWindow("tfmrush", ""); $command="RushApp.Util.Standalone.Login('backup','','')"; my $copy_data_struct = pack( 'L2P', 2, length( $command ), $command ); #Win32::GUI::PostMessage($rushhandle,WM_COPYDATA,$wparm,$lpCopydatastr +uct); #my $SendMessage=new Win32::API("User32","SendMessage",[qw(N N N N)],' +N'); #my $lresult=$SendMessage->Call($rushhandle,WM_COPYDATA,$wparm,$lpCopy +datastruct); Win32::GUI::SendMessage($rushhandle, WM_COPYDATA, 0, $copy_data_struct +);
here is the C code from the dll.
TargetWindow := FindWindow('TfmRush', nil); CopyDataStruct.dwData := 1000; CopyDataStruct.cbData := strlen(Data) + 1; CopyDataStruct.lpData := Data; wCallbackWindow.fIrcHandle := mWnd; SendMessage(TargetWindow, WM_COPYDATA, 0, LParam(@CopyDataStruct));
I've left the # from my code so you can see what I've tried. I've got a feeling the error is in the pack command. but reading thou the perldoc to be honest it all goes over my head. thanks for takeing the time to read and for any help offered. Ken. **UPDATE** Thank you igelkott for all the help. I got it working :) thanks for a friend on mirc for helping too :) ykwya.
use Win32::GUI; use Win32::API; use constant WM_COPYDATA => 74; my $rushhandle = Win32::GUI::FindWindow("tfmrush", ""); my $command = "RushApp.FTP.Login('backup','',0);"; my $copy_data_struct = pack('L2P', 1000, length( $command ), $command) +; print Win32::GUI::SendMessage($rushhandle, WM_COPYDATA, 0, $copy_data_ +struct);

In reply to win32::sendmessage and pack help. by Fuas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.