ankit.tayal560 has asked for the wisdom of the Perl Monks concerning the following question:

use strict; use Win32::GuiTest qw(:ALL); my @window2=FindWindowLike(undef,m"^\s*(SURFer)\s*(\W+)\s+(note)\s*$") +; if(!@window2) { die("cannot find window with title/caption SURFer++ note\n"); } else { print("the matched strings are :\n <$1>\t<$2>\t<$3>"); printf("window handle of SURFer++ note is %x \n",$window2[0]); }

I wrote this code but it is not working .can you suggest me a suitable solution for the above case?

  • Comment on How to use FindWIndowLike to find a window like "SURFer++ note" under Win32::GuiTest module
  • Download Code

Replies are listed 'Best First'.
Re: How to use FindWIndowLike to find a window like "SURFer++ note" under Win32::GuiTest module
by Corion (Patriarch) on Sep 08, 2016 at 08:33 UTC

    How is it "not working"? Is there any error message? Does the program crash? Does your house burn down?

    Note that you seem to pass a weird string to FindWindowLike(...) - it takes a regular expression in a string, not the result of a matching m// expression. Maybe you want to pass a simple string to it?

    FindWindowLike(undef,qr/^\s*(SURFer)\s*(\W+)\s+(note)\s*$/)

      okay it works thanks ! but can you please elaborate why you used qr/../ in FIndWindowLike(...) what is the significiance of qr? I am pretty new to perl scripting!

Re: How to use FindWIndowLike to find a window like "SURFer++ note" under Win32::GuiTest module
by marto (Cardinal) on Sep 08, 2016 at 08:49 UTC

    Please mark updates to your post, and tell us what happens, be more descriptive in your posts please (previously linked to How do I post a question effectively?). Try using the spy.pl to get the window class, e.g.

    #!/usr/bin/perl use strict; use warnings; use Win32::GuiTest qw(FindWindowLike GetWindowText); my @windows = FindWindowLike(undef, "", "Notepad++"); for (@windows) { print "$_>\t'", GetWindowText($_), "'\n"; }

    output:

    1442758> 'D:\junk\gui.pl - Notepad++ [Administrator]'