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

I'm using WIN::GuiTest to interface with a GUI.... I would like to use SendKeys to enter some text. Will SendKeys work with variables. exampe: SendKeys($x); I can't get the variable to expand.

Replies are listed 'Best First'.
Re: Win32::GuiTest sendkeys
by blazar (Canon) on May 24, 2007 at 21:12 UTC
    I'm using WIN::GuiTest to interface with a GUI.... I would like to use SendKeys to enter some text. Will SendKeys work with variables. exampe: SendKeys($x); I can't get the variable to expand.

    Minimal example? I just installed the module, adapted the code in the synopsis to the following:

    #!/usr/bin/perl use strict; use warnings; use Win32::GuiTest qw/FindWindowLike SetForegroundWindow SendKeys/; my @windows = FindWindowLike(0, 'Senza nome - Blocco note'); for (@windows) { SetForegroundWindow($_); my $x="Foo Bar Baz%fv"; SendKeys($x); } __END__

    And it works as expected: I open notepad before launching it, and when I launch it, it writes there "Foo Bar Baz" and then opens the "save as" dialog box.