Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Automating a Win10 GUI

by Marshall (Canon)
on Jan 23, 2020 at 07:05 UTC ( [id://11111741]=perlquestion: print w/replies, xml ) Need Help??

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

I want to automate some Windows GUI interactions.
There appear to be quite a number of tools that claim that they can "do this".
I suspect that the solution to my problem will be some existing tool that has the capability of accepting Perl code for decision making.

I currently only have a single monitor.
I launch a program, let's just call this program X. "X" is designed to stay in the background of the GUI.
Then I launch program "Y". "Y" has a many windows.
I move the individual windows of application "Y" around so that I see the most important parts of application "X".
Application X essentially functions as the "wallpaper".
Unfortunately, program "X" has a timeout "nag window" that I have to click on every 15-20 minutes or so.
That "nag window" will be displayed on top of the program X application, but below the windows for application Y which means that it might not even be possible to see on the monitor.

I have considered and I am implementing the most obvious solution:
Buy a second monitor and run "X" and 'Y" on 2 different monitors.
Unfortunately that will not solve my complete problem. Program "X" is a bit funky and actually I just want to keep it running, and not mess with it at all. The interactions can be more complex than I described above.

To further complicate matters, it is highly desirable to only use Perl libraries available on ActiveState's latest release.

Replies are listed 'Best First'.
Re: Automating a Win10 GUI
by marto (Cardinal) on Jan 23, 2020 at 07:42 UTC

    Have you considered Win32::GuiTest? I've used it in the past to automate funky, dare I say flaky old applications.

      I have heard about that module. When I run ActiveState ppm (Perl Package Manager), I don't see it as a package option for the latest AS version. There a lot of reasons why that could happen. I haven't investigated why that is yet.

      I am hoping to find a tool that does most of the work, with me just writing some small amount of extra code. I am hoping for an option better than Win32::GuiTest. If "GuiTest" winds up being "the answer", then likely follow-on questions will involve complicated build problems that Active State has not solved.

      Update: I installed the cpan module from Active State. And lo and behold, installation of Win32::GuiTest appeared to work. I will investigate this module further.

        Define better? The question you posted had a list of things you had to do in order to automate a couple of programs. The module I suggested provides convenient ways to achieve this. The module documentation is pretty clear on where to get a PPD file, how to build from source. I don't recall having issues with either method when using AS perl, or simply using cpan/cpanm. A quick search shows AS do offer a version, though perhaps not built for your version of AS perl. Make life easier in yourself, switch to Strawberry perl or just follow the documentation for building it yourself ;).

Re: Automating a Win10 GUI
by Anonymous Monk on Jan 23, 2020 at 08:39 UTC
Re: Automating a Win10 GUI
by harangzsolt33 (Chaplain) on Jan 23, 2020 at 14:58 UTC
    Have you heard of AutoIt3 ? It’s designed specifically for this purpose!
      There are a whole bunch of automation programs. One person suggested AutoHotKey. I am open to any solutions. My initial testing with Win32::GuiTest indicates that this can be a lot more complicated than it sounds.

        I had a positive experience with Win32::GuiTest. If you want to go this way start by getting a handle to the window you are interested in. The manual shows this: my @found = FindWindowLike(0,"title-regex");. And the t/01_basic.t test script does it this way:

        # Create a notepad window and check we can find it system("cmd /c start notepad.exe \"README\""); my @waitwin = WaitWindowLike(0, "readme|README", $class_re); is(@waitwin, 1, "There is one notepad open with README in it"); my @windows = FindWindowLike(0, "readme|README", $class_re); is(@windows, 1, "The same from FindWindowLike"); is($waitwin[0], $windows[0], "The two windows are the same"); # Find the edit window inside notepad my $notepad = $windows[0]; my @edits = FindWindowLike($notepad, "", "Edit"); is(@edits, 1, "Edit window found within notepad");

        I do not have any experience with the AutoIt3,that harangzsolt33 suggested, nor with AutoHotKey. I am sure they will do the job equally well. However, an all-Perl solution has benefits. The tricky part, recalling from my experience, is to wait for the windows to show and then make sure that the usual windows blabbering via popups will not get in the way of what window focus and arrangement you want.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11111741]
Approved by marto
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found