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.

Recognizing when a Window's Close Box has Ungrayed

Keywords:   ungrayed ungreyed

Question:

Can Winbatch recognize when a window has completely loaded?

e.g., When I execute a menu option that loads a report in a document window, as long as that data is loading, the close button, "X", in the upper right corner remains greyed out. When the load has finished, the button is painted black.

How can I set Winbatch up to wait for the close button to change from grey, (waiting), to black, (ready).

Answer:

Watching the "close" menu item on the system menu. No easy way to do that. If you have access to the Windows SDK documentation and some windows programming experience, then you could possibly do it with a few DLLCalls.

To wait for the application close box to ungray...

while 1
    SCCLOSE=61536
    MFBYCOMMAND=0
    hwnd=DllHwnd("WinBatch Studio")  ;Window Title of desired window goes here
    sysmenu=DllCall(strcat(DirWindows(1),"USER32.DLL"),long:"GetSystemMenu",long:hwnd,long:0)
    rslt=DllCall(strcat(DirWindows(1),"USER32.DLL"),long:"GetMenuState",long:sysmenu,long:SCCLOSE,long:MFBYCOMMAND)
           
    if (rslt & 1) == 0 then break  ; item no longer grayed
    TimeDelay(2)   ; wait somemore
endwhile
Message("Close box","no longer grayed")

Article ID:   W13375
Filename:   Recognize when a Windows Close Box has Ungrayed.txt
File Created: 2001:01:08:12:19:02
Last Updated: 2001:01:08:12:19:02