What is the best way (with a view to optimization and using system resources) to make waiting in my application when window of another app will be shown?
For example:
- My application starts.
- Waiting while, for example, Notepad will be started so i can get handle of its window.
- Using handle im doing something with it and then closing my app.
How to accomplish item 2? I know only one possible way: just check if handle exis开发者_StackOverflowts in loop using FindWindow
. But I hope there is a more smart solution exists.
If you launched the process (with CreateProcess
) use WaitForInputIdle
and then start the FindWindow
loop. Adding a Sleep(20)
or something to the loop will ensure your resource usage is minimal.
I dont think the same... I think the best way is windows hooking process... USING HOOKS
... Please see: WH_CBT and you have to be watching the event: HCBT_CREATEWND
精彩评论