I'm working on a program that runs basic smoke tests and acceptance tests on Windows applications under development. Part of what it does is to snapshot the app's top-level window(s) when it(they) first appears. It does this by starting the process, waiting for input idle, enumerating top-level windows, and then getting the window DC and blitting from it.
It turns out that the first appearance of a top-level window is animated by default--it fades in and expands to its actual size--at least on Windows 7. Screenshots taking during the animation are either missing the window frame or the frame is scaled down and partially transparent.
I can avoid this problem by adding a delay (e.g., Sleep(250)
) before taking the screenshot, but I can't find any information on how long the animations may actually take. If the animation takes longer on a future version of Windows (or if it's user adjustable), this delay might not be long enough. If the animations are disabled, then I'm just wasting time. (The tool will be used to run many tests, so the quarter second delays could add up.)
I can avoid the problem by checking the "Turn off all unnecessary animations" checkbox in the Ease of Access Center control panel, which seems to disable this animation. I figured this might correspond to a setting (or settings) programmatically accessible via SystemParametersInfo. If I could check when the animation is enabled, I could add the delay only when needed. I could also consider disabling the animations for the duration of the tests and then restoring the user's choice afterwards.
But I can't seem to find the SPI setting that corresponds to this particular animation. There is SPI_GETANIMATION, which indicates whether minimize and restore animations are enabled. However, that setting is independent of setting for the top-level window appearance animation.
Is there an API to detect whether top-level window appearance animations are enabled? Is there a setting that controls the speed of them so my code knows how long to delay? Is there a signal my program can watch for to know when a window from a child process is fully painted and finished animating?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…