主题:【求助】VB如何获得 同花顺2008 软件的句柄
同花顺2008 是经过处理的软件,求助高手们帮忙
下面的代码失败
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const BM_CLICK = &HF5
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Sub command1_click()
Dim Handle As Long
Dim s As String
Dim ParentHandle As Long
ParentHandle = FindWindow("#32770", "登录到中国电信行情主站")
Text1.Text = ParentHandle
While True
On Error Resume Next
Handle = FindWindowEx(Text1.Text, 0&, "Button", "登录")
Text2.Text = Handle
SendMessage Handle, WM_KEYDOWN, 32, &H11C0001
SendMessage Handle, WM_KEYUP, 32, &H11C0001
SendMessage Handle, WM_KEYDOWN, 32, &H11C0001
SendMessage Handle, WM_KEYUP, 32, &H11C0001
DoEvents
Wend
End Sub
下面的代码失败
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const BM_CLICK = &HF5
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Sub command1_click()
Dim Handle As Long
Dim s As String
Dim ParentHandle As Long
ParentHandle = FindWindow("#32770", "登录到中国电信行情主站")
Text1.Text = ParentHandle
While True
On Error Resume Next
Handle = FindWindowEx(Text1.Text, 0&, "Button", "登录")
Text2.Text = Handle
SendMessage Handle, WM_KEYDOWN, 32, &H11C0001
SendMessage Handle, WM_KEYUP, 32, &H11C0001
SendMessage Handle, WM_KEYDOWN, 32, &H11C0001
SendMessage Handle, WM_KEYUP, 32, &H11C0001
DoEvents
Wend
End Sub