Peter,

Win32::Pipe allows you to use named pipes for interprocess communication.
One process has to act as a server, any others as clients.  You might want
to have a look at the PerlIPC doc as well.

Here's a very simple Win32::Pipe server:

      use Win32::Pipe;

      $p = new Win32::Pipe("MyPipe"); # create pipe
      $res = $p->Connect();   # wait for a process to connect

      while ($data = $p->Read() ) {
            print "RECEIVED: $data\n";
      }

      $p->Disconnect();  # disconnect
      $p->Close();            # close pipe

and a client

      use Win32::Pipe;

      my $p = new Win32::Pipe("\\\\.\\pipe\\MyPipe"); # client must yous
\\server\pipe\pipename syntax

      for ( my $i = 0; $i <=10 ; $i++) {
            $p->Write("\$i = $i\n");  # could read from the pipe as well
            sleep 1;                          # without a delay all the
writes go across at once
      }

      $p->Close();

The problem with this is that while waiting for a connection your server
script won't be able to
respond to user input.  This is going to be a problem you hit with most IPC
methods.

Win32::GUI does give you access to SendMessage in the Win32 api so it may
be possible
to use that.  I have a vague recollection that some of the messages were
user definable but
wouldn't swear to this.  You could look on MSDN to find out.

SendMessage details are at

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/messagesandmessagequeues/messagesandmessagequeuesreference/messagesandmessagequeuesfunctions/sendmessage.asp

Good luck.

Kev.



|---------+------------------------------------------------>
|         |           "Straub, Peter (Peter)"              |
|         |           <[EMAIL PROTECTED]>                |
|         |           Sent by:                             |
|         |           [EMAIL PROTECTED]|
|         |           ceforge.net                          |
|         |                                                |
|         |                                                |
|         |           08/07/2002 17:08                     |
|         |                                                |
|---------+------------------------------------------------>
  
>----------------------------------------------------------------------------------------------|
  |                                                                             
                 |
  |       To:       perl-win32-gui-users@lists.sourceforge.net                  
                 |
  |       cc:                                                                   
                 |
  |       Subject:  [perl-win32-gui-users] communication between GUI scripts    
                 |
  
>----------------------------------------------------------------------------------------------|




Hi all,

does anyone know of a reliable way for two Win32::GUI
scripts to communicate with each other? They run as
separated processes.

My idea was to simply write data to a file and send a
notification of some kind to the other process
(concurrent accesses not being an issue here).

What came to my mind in the first place was to use
'PostMessage'. Using Win32::GuiTest I am able to retrieve
the adressee's window handle, but what message should
I post?
As far as I know there is no support for user defined
messages (at least I have no idea how to retrieve one).

I also tried Win32::GuiTest's SendKeys function to notify
a dummy window in the other application by simulating
keystrokes. This gradually turned out to be a real horror
because the receiving control must be the foreground
window in order for SendKeys to succeed and every box
popping up at the wrong time spoils the whole thing...

Could you please help with better ideas how to
accomplish this?

TIA and Cheers,
  Peter


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Oh, it's good to be a geek.
http://thinkgeek.com/sf
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users




Reply via email to