2013-11-01 51 views
0

我在VB中工作與Visual Studio 2010需要幫忙的子窗口

的應用AnyOrder不再支持,我試圖做一個應用,在那裏我們的用戶可以輸入信息,然後讓信息填入到AnyOrder(以及其他網站 - 他們必須填充大量的冗餘信息),但我沒有任何運氣,一旦數據在VB窗口應用程序中獲得任何訂單的子窗口填充。

我可以得到父窗口句柄就好,但似乎無法得到一個子窗口句柄來挽救我的生命。我甚至無法得到第一層,我需要填充的空白是父窗口的偉大的大孩子。

它不會讓我發佈間諜++的screencap,因爲我剛剛註冊並沒有10代表,但這裏是一個鏈接到捕獲。

enter image description here

預先感謝您爲您提供的任何援助。

+0

請出示您使用,讓您的窗口中的代碼處理 –

+0

我不知道我做了什麼,以解決它,但我得到了它的工作,並想我會放在我這裏拼湊在一起,以防有人代碼其他人需要它。也許有更好的方法來做到這一點,但這至少將把手列表放入數組中。 – Rodger

回答

1

以某種方式找出答案。

#Region "functions" 
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32 
Public Delegate Function EnumWindowProcess(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean 
<DllImport("User32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> 
Private Shared Function EnumChildWindows(ByVal WindowHandle As IntPtr, ByVal Callback As EnumWindowProcess, ByVal lParam As IntPtr) As Boolean 
End Function 
Private Shared Function EnumWindow(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean 
Dim ChildrenList As List(Of IntPtr) = CType(GCHandle.FromIntPtr(Parameter).Target, Global.System.Collections.Generic.List(Of Global.System.IntPtr)) 
ChildrenList = CType(GCHandle.FromIntPtr(Parameter).Target, Global.System.Collections.Generic.List(Of Global.System.IntPtr)) 
If ChildrenList Is Nothing Then Throw New Exception("GCHandle Target could not be cast as List(Of IntPtr)") 
ChildrenList.Add(Handle) 
Return True 
End Function 
Private Shared Function GetChildWindows(ByVal ParentHandle As IntPtr) As IntPtr() 
Dim ListHandle As GCHandle = GCHandle.Alloc(ChildrenList) 
Try 
    EnumChildWindows(ParentHandle, AddressOf EnumWindow, GCHandle.ToIntPtr(ListHandle)) 
Finally 
    If ListHandle.IsAllocated Then ListHandle.Free() 
End Try 
Return ChildrenList.ToArray 
End Function 
#End Region 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
iParentHandle = FindWindow(vbNullString, AOParentName) 
GetChildWindows(FindWindow(vbNullString, AOParentName)) 
Dim Childlist As String = String.Join(". ", ChildrenList) 
MsgBox("list of child windows: " & Childlist) 
End Sub