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

Dear all!

Could you please advice how to send a message to perlTk program from Win32 application so that perl program will receive Tk event and process it?

My C program should use something like SendMessage, but which message and which parameters?

Thanks in advance,
Courage, the Cowardly Dog

  • Comment on How to send a message to perlTk program from Win32 application?

Replies are listed 'Best First'.
Re: How to send a message to perlTk program from Win32 application?
by PodMaster (Abbot) on Oct 10, 2002 at 11:00 UTC
    Don't know anything about C, and I don't know why you'd ask here, but the following can help (found thanks to how to rtfm):
    Win32::CtrlGUI
    Win32::GuiTest

    ____________________________________________________
    ** The Third rule of perl club is a statement of fact: pod is sexy.

      podmaster, it is not a problem to send a message using some Win32 stuff, the problem is to send such a message that Tk system will understand!

      I want to fire Tk event from outside and do not know how.

      Anyway, thanks for trying to help.

      Courage, the Cowardly Dog

        You're out of luck. That's the only way you can do it directly. Your other alternative is to set up a PIPE or something between the two programs, and communicate that way.

        Check out http://perltk.org/ and ask on the mailing list (maybe somebody there'll get it)

        ____________________________________________________
        ** The Third rule of perl club is a statement of fact: pod is sexy.

Re: How to send a message to perlTk program from Win32 application?
by Anonymous Monk on Oct 10, 2002 at 23:22 UTC
    You need to break this into two parts -
    1.the Win32 app sending an event to another app.
    2.the Perl::Tk app receiving the event.

    For part 2, you need to use

    Tk::Receive($widget, "command");

    That bit I got from O'Reilly Learning Perl/Tk, which recommend using -T to check for taints, in case the command is arbitrary code - that is, your tk app gets hacked by someone's Win32 or Tk app. It also recommends you do careful checking of command - e.g. don't just do eval("command") without checking for commands that contain things like

    system("rm -rf");

    For Perl::Tk talking to other (Tk?) apps use send

    $widget->send("application" => callback);

    Use -async to not wait for callback to execute.

    For part 1, I have no idea.
      Thank you a lot!

      You gave me really usefull idea!

      Courage, the Cowardly Dog