It is possible to emulate keyboard strokes with perl? Specifically, I want to select an open window and send a series of keystrokes to it. It this possible and if so how? TIA.
This may sound a little obtuse, but you could use office to do it.
You can use Perl to open an office document, and within the document have an autload function which would use
Application.SendKeys
Or you could use an app like Macro Express though here you would most likely need to know that state of the machine in terms of relevant window positions, and would be a right pain in the *******.
Another place to look would be CPAN for some of the testing modules
I'm assuming you're on a M$ platform - apologies if I'm wrong
Any decent test suite should have the ability you're after, which you could shell - none too elegant
Sorry If I haven't been too much help here, but it might put you on the right track
Ectually search.cpan.org, look for keystrokes, Win32::GuiTest (ernesto Guisado) could be the biscuit you quest or GUITest.xs ( a Pure Perl implementation, brilliant, but I've only ever got one to work ;(
HTH
Paul
It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
Thanks for the reply and apologies for the bad form, bumping.
I'll look into your suggestions which I presume imply the answer to my subject question is, "no."
I have Personal Rexx somewhere which does have that capability but I was hoping not to have to use so many different products for a seemingly simple task.
I downloaded GuiTest-1.3 (is that the same thing?) from CPAN. Unfortunaetly the install documentation makes too many assumptions. Can anyone tell me how to install it on Windows without installing a mass of additional software? TIA.
Theres a Win32::GUITest which should be more what you're after. The XS implementations are allegedly brilliant (because they're Pure Perl), and for that reason I can only assume the documentation doesn't have to be up to much. I had a brief glance at the dox you're talking about, and they looked sparse, wheras the Win32 one looks more like a traditional doc set.
HTH
Paul
PS Not trying to P*ss off the PP developers, but ...
It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
What did I download? The documentation provides two ways to install. The first fails because I don't have 'nmake.' It seems this version is for Unix. The second requires installing more software which I prefer to avoid.
I guess I am just totally confused. I looked for win32::guitest and got the same thing I just downloaded. Perhaps you would be kind enough to post the URL you are talking about.
try typing 'IPM help' at a command prompt. (Indigo Package Manager)
I installed Activestate Python at one point, and it associated my ppd files with an installer program.. now I can just double-click on them, and it installs them in my perl path - might work for Indigo perl too. It just makes things a little easier. (at work I can't download modules with ppm because of the firewall)
I seem to remember coming across some perl code a while back that opened notepad.exe then typed out "Welcome to perl" or something like that... Is that the kind of thing you're looking for, or am I not getting it? If so, I'll poke around to see if I can find it again. I'm actually in need of something like that too for a project I'm working on.
I've used Win32::GuiTest extensively at work for an after-hours process automation. The hard part is selecting which window you want. Straight from ASPN module documentation:
use Win32::GuiTest qw(FindWindowLike GetWindowText
SetForegroundWindow SendKeys);
$Win32::GuiTest::debug = 0; # Set to "1" to enable verbose mode
my @windows = FindWindowLike(0, "^Microsoft Excel", "^XLMAIN\$"
for (@windows) {
print "$_>\t'", GetWindowText($_), "'\n";
SetForegroundWindow($_);
SendKeys("%fn~a{TAB}b{TAB}{BS}{DOWN}"
}
A change in plans, I was able to try it. This is a good news/bad news scenario. The good news is Indigo perl does indeed have an IPM command and I was apparently able to successfully install the package. The bad news is why I used the word 'apparently'. When I try to use FindWindowLike, I get the following error:
Can't load 'C:/OpenSA/perl/site/lib/auto/Win32/GuiTest/GuiTest.dll' for module Win32::GuiTest: load_file:One of the library files needed to run this application
cannot be found at C:/OpenSA/perl/lib/DynaLoader.pm line 229.
That path and file does exist so I have no clue why it cannot find it. Suggestions?
I'm really not sure what the problem is... Is the OpenSA dir the default installation path for IndigoPerl? Maybe it's not liking that even though it seems to be looking in the right place.. It's a long shot, but I guess it could have something to do with it.
Yes, that is the install path and the directory in the %path% variable.
I posted this as a new question since it is no longer appropriate for this thread. I'm hoping someone with expereince with Indigo perl will see it. I also wrote to the author but so far no response.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.