Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27212

VS 2010 getWindowList only seems to work with 'unused' arraylist

$
0
0
Hi,

I'm controlling a 3rd party app by watching for dialog boxes it brings up and then closing them.

Code:

        Dim arraylistWindows2 As New ArrayList
        Dim boolDialog_Closed As Boolean
        Dim strError As String

      boolDialog_Closed = False
        Do While boolDialog_Closed = False
            getWindowList(arraylistWindows2, strError)

            For Each strList_Item In arraylistWindows2
                If InStr(strList_Item, "Processing Experiment Script") Then
                    intHandle = Val(strList_Item)
                    PostMessage(intHandle, WM_CLOSE, 0, 0)
                    boolDialog_Closed = True
                    Exit For
                End If
            Next
            arraylistWindows2.Clear()
            Threading.Thread.Sleep(1000)
        Loop

The code gets the list of windows, looks for a specific 1 and if it finds it, then closes it.
If it doesn't find the window, it waits a second, grabs a list of windows again and loops through them all again.
The problem is that the 2nd time I call getWindowList, it always returns no windows, unless I pass it a new 'unused' arraylist.


Any ideas?

Thanks

Kristian

Viewing all articles
Browse latest Browse all 27212

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>