Loading ...
Sorry, an error occurred while loading the content.

Problem with SendMessage()

Expand Messages
  • s03nk3
    Hi, recently I discovered Win32::Guitest - thx for wríting this module! ... #!perl #use strict; use Win32::GuiTest qw(FindWindowLike SendMessage
    Message 1 of 2 , Jan 26, 2004
    • 0 Attachment
      Hi,

      recently I discovered Win32::Guitest - thx for wríting this module!

      But currently, I'm stuck with sending a simple Buttonclick:

      --------- 8< --------

      #!perl

      #use strict;
      use Win32::GuiTest qw(FindWindowLike SendMessage SetActiveWindow);
      use Win32::API;

      my $WM_USER = 0x0400;
      my $BM_SETSTATE = 0x00F3;
      my $BM_CLICK = 0x00F5;
      my $WM_LBUTTONDOWN = 0x0201;
      my $WM_LBUTTONUP = 0x0202;
      my $MK_LBUTTON = 0x0001;

      $Win32::GuiTest::debug = 1; # Set to "1" to enable verbose mode

      my @windows = '';
      my $status = '';

      @_ = FindWindowLike(0, "^eMule");
      for (@_) {
      @windows = FindWindowLike($_, "^Reload");
      for (@windows) {
      my $hwnd = $_;
      $status = SendMessage($hwnd, $BM_Click, 0, 0);
      print "\n $status "; # Debug
      $status = SendMessage($hwnd, $BM_SETSTATE, 1, 0);
      print "$status "; # Debug
      $status = SendMessage($hwnd, $WM_LBUTTONDOWN, $MK_LBUTTON, 0);
      print "$status "; # Debug
      $status = SendMessage($hwnd, $WM_LBUTTONDUP, $MK_LBUTTON, 0);
      print "$status :: $hwnd found\n"; # Debug
      }
      }

      --------- >8 --------

      The window handle returned by FindWindowLike() is correct (verified
      with Spy&Capture (http://kobik.videodot.net/spy_capture.asp)), but my
      W32 application doesn't receive the message with this "fake" click.

      Please be so kind as to tell me where I'm wrong, as I'm not familiar
      with Windows programming.

      Bye,
      Soenke J. Peters
    • s03nk3
      I finally found the problem *g* BM_Click should read BM_CLICK... Now, everything works fine and my eMule can be told to rehash its files from the command line
      Message 2 of 2 , Jan 27, 2004
      • 0 Attachment
        I finally found the problem *g*
        BM_Click should read BM_CLICK...

        Now, everything works fine and my eMule can be told to rehash its files from the command line :-D

        Bye,
        Soenke
      Your message has been successfully submitted and would be delivered to recipients shortly.