WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Window Manipulation

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WinIDGet to get return value of a Window name

Keywords:  WinIDGet window name

Question:

I have a Windows application that, when minimized, the Windows name changes. What I would like to do is to launch the EXE in minimized mode, and get the Windows name. I do not have any partial information on what the iconized name will be, but I do know exactly what the maximized name is.

Answer:

Hmmm. There is no way to guess that the maximized name will be from the minimized name. But do you really need that, or do you just need to refer to the maximized windows unambiguously when it gets maximized.

You can do a WinIdGet(xxx) on a window, and use the return value of WinIDGet instead of the window name everyplace. So now the problem is figuring out what the name of the new minimized window is.

To get the title of an unknown window... Do a WinItemize before and after launching the window(For does windows add a small timedelay so it can get its title established). Then toss out the ones that match. What's left over - almost always the first one - is the window you just launched.

If you know what the maximized name is, do the following:

        oldlist=WinItemize()
        Runicon("daprogram.exe","")
        TimeDelay(4)
        newlist=WinItemize()

        oldcount=ItemCount(oldlist,@tab)
        for xx=1 to oldcount
           oldwin=ItemExtract(xx,oldlist,@tab)
           yy=ItemLocate(oldwin,newlist,@tab)
           if yy!=0 then newlist=ItemRemove(yy,newlist,@tab)
        next
        mywin=ItemExtract(1,newlist,@tab)
        mywinid=WinIdGet(mywin)

This (make sure it gets debugged!!!) code gets the lists of windows before and after a run statement, and tries to find the name of the new window that appeared, and then does a WInIdGet on it. After the code is over the "mywinid" variable should refer to the new window that appeared.

  1. WinIDGet will get a window handle and it will remain the same even if the window title changes.

  2. The ID's are assigned pretty much at random, so they'll have different IDs on different machines. Even different sessions will have different ID's.

Article ID:   W13377
Filename:   WinIDGet to Handle Changing Window Name.txt
File Created: 1999:04:15:16:53:36
Last Updated: 1999:04:15:16:53:36