c# - Is there any event triggered when a new window is added to the desktop -


i want know whether there event triggered when new window appears/comes on desktop. open using com,wmi,winapis, uiautomation or other method language of choice c#.

the actual requirement: process has 1 main window , many other windows. class name of 1 of windows is, say, x, (i got info using pinvoke). window pops times whenever there notification in process. not want show window. not have code access process can disable window. there way can event or other mechanism keeps track of desktop , anytime window classname x comes/about come hides it.

do tell if not clear question.

edit : simon's answer good. tried , able notification windows except notifications/toast windows such of lync's im toast notification or outlook new mail notification. tried different elements of automation element , windows pattern still not those...any ideas how can those...you may read comments in simon's answer more context/detail. once again simon introducing great power of uiautomation...loving it!

as damien said in comment, can use ui automation, in c# sample console app:

class program {     static void main(string[] args)     {         automation.addautomationeventhandler(windowpattern.windowopenedevent, automationelement.rootelement, treescope.subtree, (sender, e) =>             {                 automationelement src = sender automationelement;                 if (src != null)                 {                     console.writeline("class : " + src.current.classname);                     console.writeline("title : " + src.current.name);                     console.writeline("handle: " + src.current.nativewindowhandle);                 }             });          console.writeline("press key quit...");         console.readkey(true);     } } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -