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

Cannot WMGetText where control id is 1

Expand Messages
  • shsk7203
    Hi folks, Please ignore my earlier two emails regarding getting text from particular text box and warning Text from a dialog box. I found the Control Id of my
    Message 1 of 3 , Jul 14, 2003
    View Source
    • 0 Attachment
      Hi folks,

      Please ignore my earlier two emails regarding getting text from
      particular text box and warning Text from a dialog box. I found the
      Control Id of my controls displayed in the WinSpy utility and was
      able to get the value from a particular input box as well as the
      warning message from a dialog box.

      The problem I realised was when the control id happens to be 1. I
      have two input text boxes in one of my windows. The control ids are 1
      and 2. The foll code returns the value :

      my ($dlg) = FindWindowLike(0, "Threshold");
      my ($label1) = WMGetText(FindWindowLike($dlg, "", "", 0x2));
      print $label;

      But when I replace 0x2 with 0x1, nothing gets printed. Any thoughts?

      Regards,
      -skanitkar
    • Dennis K. Paulsen
      If this is a copy and paste of your code, a couple of thoughts: * print $label should be print $label1 * There may be two controls on the form with the same
      Message 2 of 3 , Jul 14, 2003
      View Source
      • 0 Attachment
        If this is a copy and paste of your code, a couple of thoughts:

        * print $label should be print $label1

        * There may be two controls on the form with the same window id
        (0x1). If that is the case, you can specify the class name to
        FindWindowLike to constrain the search more..

        * Finally, FindWindowLike returns an array of window handles, not a
        single window handle, so specifying it as a parameter to WMGetText
        directly is not a good idea, even though it may seem to work..
        Better to use ($varname) = FindWindowLike(..) convention and use
        $varname in the WMGetText call.

        Regards,
        Dennis K. Paulsen


        > The problem I realised was when the control id happens to be 1. I
        > have two input text boxes in one of my windows. The control ids
        are 1
        > and 2. The foll code returns the value :
        >
        > my ($dlg) = FindWindowLike(0, "Threshold");
        > my ($label1) = WMGetText(FindWindowLike($dlg, "", "", 0x2));
        > print $label;
        >
        > But when I replace 0x2 with 0x1, nothing gets printed. Any
        thoughts?
        >
        > Regards,
        > -skanitkar
      • shsk7203
        Hi Dennis, Sorry, I didnt actually copy paste. Next time I ll make sure to do that. But putting in the classname worked! Though I still dont know why it
        Message 3 of 3 , Jul 14, 2003
        View Source
        • 0 Attachment
          Hi Dennis,


          Sorry, I didnt actually copy paste. Next time I'll make sure to do
          that.

          But putting in the classname worked!

          Though I still dont know why it wouldnt work without it. When I look
          at the windows open, there's just one by the Title "Threshold", and
          there's just one item under this with control id as 1.

          Thanks anyway,
          Regards,
          -skanitkar

          --- In perlguitest@yahoogroups.com, "Dennis K. Paulsen"
          <ctrondlpaulsden@y...> wrote:
          > If this is a copy and paste of your code, a couple of thoughts:
          >
          > * print $label should be print $label1
          >
          > * There may be two controls on the form with the same window id
          > (0x1). If that is the case, you can specify the class name to
          > FindWindowLike to constrain the search more..
          >
          > * Finally, FindWindowLike returns an array of window handles, not a
          > single window handle, so specifying it as a parameter to WMGetText
          > directly is not a good idea, even though it may seem to work..
          > Better to use ($varname) = FindWindowLike(..) convention and use
          > $varname in the WMGetText call.
          >
          > Regards,
          > Dennis K. Paulsen
          >
          >
          > > The problem I realised was when the control id happens to be 1. I
          > > have two input text boxes in one of my windows. The control ids
          > are 1
          > > and 2. The foll code returns the value :
          > >
          > > my ($dlg) = FindWindowLike(0, "Threshold");
          > > my ($label1) = WMGetText(FindWindowLike($dlg, "", "", 0x2));
          > > print $label;
          > >
          > > But when I replace 0x2 with 0x1, nothing gets printed. Any
          > thoughts?
          > >
          > > Regards,
          > > -skanitkar
        Your message has been successfully submitted and would be delivered to recipients shortly.