|No such thing as a small change|
Re: Problems with WIN32::GUITESTby dasgar (Curate)
|on Jan 26, 2013 at 05:22 UTC||Need Help??|
Like you, I'm running dwimperl on Windows 7 Home Premium 64-bit. When I tried running the code, the printed result was blank and the calculator never did do anything.
To make a long story short, I ended up tweaking the code to get it to work. I believe that the calculator app in Windows 7 must be designed differently that the calculator app in previous Windows version.
For those that want to gory details and my tweaked version of the code, here's a summary my debug process. (Also, some of the info might be useful for others wanting to use Win32::GuiTest to automate applications.)
First, I decided to double-check the version of Win32::GuiTest that is in dwimperl. That version is 1.58. Since the example code was from version 1.60, I updated my Win32::GuiTest module to 1.60. Still no luck.
Then I took a look at the code for the 'keyboard' portion as well as the perldoc for Win32::GuiTest. Since I never saw any activity in the calculator app, I figured that the calls to simulate keyboard input was not working correctly. When I changed the calls to PushButton to SendKeys, then the script really did get the calculator app to behave correctly.
However, the printed result from the script was blank. After a bit of testing, I changed to the printf line to be in a loop looking for a window whose text contained only digits and printed that as the result. That fixed the 'keyboard' section of the code.
Onto debugging the 'mouse' section. At one point I thought that since I had my calculator app defaulting to the scientific mode instead of standard mode was the source of the problem. Tested both modes, but there was no difference.
I tried printing out the text from each child window object, but didn't see anything matched the calculator button labels. So I figured that I needed more information about the components of the calculator app. Some time ago I had looked into AutoIt Script and still had it installed. So I used their AutoIt Window Info Tool, which helped me get the window IDs of the needed buttons. So I tweaked the code to look for those IDs. Again, the printed result was blank. So I reused the same loop that I used from the 'keyboard' section.
Below is the final version of the code that worked on my system. Not sure if this will work on any other versions of Windows 7 or earlier versions of the Windows OS.