3
我使用下面的代碼點擊一個按鈕,用於顯示另一種形式點擊:VB.net SendMessage函數等問題
Dim hwnd As Integer = FindWindow(vbNullString, "Virtual CDRom Control Panel")
Dim x As Integer = FindWindowEx(hwnd, 0, vbNullString, "Driver Control ...")
SendMessage(x, BM_CLICK, 0&, 0&)
Thread.Sleep(200)
hwnd = FindWindow(vbNullString, "Virtual CD-ROM Driver Control")
Debug.Print(hwnd)
的問題是,當它到達
的SendMessage(X, BM_CLICK,0 &,0 &)
點擊按鈕,它停止代碼,直到我退出彈出框。我希望能夠繼續,而無需退出方框,因爲下一行
HWND = FindWindow函數(vbNullString,「虛擬CD-ROM驅動器控制」)
發現彈出窗口,點擊則在該框內的按鈕上。
任何幫助將是偉大的! :O)
大衛
解決
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWndParent As IntPtr, ByVal hWndChildAfter As Integer, ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr
Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr
Dim hwnd As IntPtr = FindWindow(vbNullString, "Virtual CDRom Control Panel")
Dim x As IntPtr = FindWindowEx(hwnd, 0, vbNullString, "Driver Control ...")
PostMessage(x, BM_CLICK, 0&, 0&)
Thread.Sleep(200)
hwnd = FindWindow(vbNullString, "Virtual CD-ROM Driver Control")
Debug.Print(hwnd)
這工作GSerg。謝謝! :O) – StealthRT 2011-03-02 14:52:23