Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Win32::GuiTest control id

by abt (Novice)
on Jan 26, 2013 at 16:46 UTC ( #1015512=perlquestion: print w/replies, xml ) Need Help??
abt has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks and visitors of the monestry, I have a problem when clicking on buttons and mouseclick etc using contro id's. First I would like to know if ther is a methode somehow to find out all available Control id's on a window. Ad PushButton and MouseClick etc do not respond eventhough I provide it with the right id. Anyone ideas?

Replies are listed 'Best First'.
Re: Win32::GuiTest control id
by dasgar (Priest) on Jan 26, 2013 at 18:32 UTC

    You've got a few options to choose from. First, there's Spy++ utility from Microsoft that is part of their Visual Studio package. From some blog posts that I found, it looks like the Express versions of Visual Studio do not have the Spy++ utility.

    If you don't want to purchase Visual Studio, you've got a few free alternatives. In the examples from Win32::GuiTest, there are spy-- and spy. Since I personally haven't tried either, I can't tell you much about either example scripts.

    There's a freeware utility called WinSpy++ that is "based around the Spy++ utility that ships with Microsoft Visual Studio". Again, I haven't used it so I can't provide any more details on it. Recently, someone had posted a question here in the monastery looking for a newer version of WinSpy++ that would work with Windows 7.

    Another alternative is to check out AutoIt, which is a freeware tool set that can be used to automate GUI based applications like you can with Win32::GuiTest. One of the tools that they provide is the AutoIt Window Info tool, which can help provide information about the GUI application that you're wanting to automate. In fact, I used this same tool to help find window IDs to modify the example from Win32::GuiTest. You can look at my modified code at Re: Problems with WIN32::GUITEST.

      I am not supposed to use any of these Tools. But to make things better i have a list of Controlids. It's just the clicking and pushbutton that do not respond. Well some collegae told me that the list he gave me where the control id's. And if I have to use a tool to read the ID's, I am far from flexible. I coe across similar programs that can differ sligthly and new versions where the devolpers have the freedom to change the ID's That will make my task impossible for that means for every verion of every similar ( not exatly the same) program a offline check.

        It kind of sounds like you're trying to automate something for use at your work. If your employer has given you the task to do this automation work, then I personally believe that they need to provide you with what you need. In this case, that would be the use of a utility like the ones I suggested or you need access to key information from the source code. Of course, I've never been employed as a programmer before, so I guess there's a chance that I might be wrong about that.

        Given the restraints that you're claiming that you have to work within, here's my thoughts on what to try.

        First, you can check out the spy-- and spy examples from the Win32::GuiTest module. If you have Perl installed along with Win32::GuiTest, you already have those "installed". Just run them and see if those can help you out.

        Secondly, you can try to use Win32::GuiTest module to come up with some code of your own to explore the window GUI object of the application that you're trying to automate. To help you get started, you can start with something like the code below. Of course, you will need to make some modifications to use your desired program instead of calc.exe. Also, you may need to dig deeper into the windows structure, but this should help get you started.

        Out of curiosity, when you manually use the program that you're trying to automate, can you fully run that program using only the keyboard? If so, I would suggest punting on using PushButton and MouseClick functions. Instead, just go with the SendKeys function, which is providing "keyboard" input to the GUI based application.

        I am not supposed to use any of these Tools.

        Sure you are

        And if I have to use a tool to read the ID's, I am far from flexible.

        Funny -- because you know what the alternative is? Not doing the job at all

Re: Win32::GuiTest control id
by ww (Archbishop) on Jan 26, 2013 at 17:23 UTC
    And this is Perl-related HOW?

    Until/unless janitors UNconsider my ill-considered consideration, please vote KEEP on it: I failed to note that the Perl nexus is contained in the title.

    But, abt: Please include the full question in the body of your node. As my mis-step illustrates, relying on the title can be less than effective.

      The problem is that the Win::32 module methods liek PushButton and Mouseclick do not seem to accept the Control id's. Have no idea why. Managed to run the calculator etc. but the home made tool that does supposed to have buttons doesnt seem to respond on the clicking and pushing. Eventhough I do have the Control id's in a list accoring to a co-worker.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1015512]
Approved by ww
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2018-07-16 11:59 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (334 votes). Check out past polls.