Window Title Help - MBS Plugins

Ok, I am trying to monitor other windows and when a specific Outlook window closes (based on Window Title), I want the form I am in to close automatically as well.

The problem I am having it that for some reason the window stays in the list, even after the window is closed. My code is below, I have hard coded the “Test Window” into my code for example, but that is a variable, as is h. Anyone see what I might be doing wrong that would cause the window list to never be refreshed? Also, this code is in the Action event of a timer control that has period set to 100.

dim subj as text = "Test Window" dim h as integer = 100 if subj <> "" then if h > 0 then dim w as new WindowsListMBS dim i,c as integer dim s(-1) as string c=w.WindowCount-1 for i=0 to c if w.WindowText(i).Contains(subj) then exit sub end if next i PHWork.Close end if end if

The list is updated in constructor.
So make a new instance when needed.

[quote=316911:@Christian Schmitz]The list is updated in constructor.
So make a new instance when needed.[/quote]
Huh? Can you please explain a bit clearer? Doesn’t dim w as NEW WindowsListMBS create a new instance every time that this is run (in the case every 100 milliseconds)?

New calls the constructor which builds the list. That’s what it’s supposed to do.

That’s what I thought, yet for some reason it doesn’t.