Private Declare Function WinExec Lib "kernel32" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long
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)
Private Declare Function PostMessage& Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Private Sub Command1_Click()
Dim aa As Long
Dim ParentHandle As Long
Dim bottonHandle As Long
Dim usernanmeHandle As Long
Dim passwordHandle As Long
Dim serverpathHandle As Long
Dim p As Long
Dim u As Long
Dim s As Long
Dim ss As Integer
Dim aabb As String
aa = WinExec("D:\OLE-TECH\SmarGroup4.5\Bin\StartUp.exe", 0)
Sleep (1000)
ParentHandle = FindWindow("ThunderRT6FormDC", "登录")
'Call SendMessage(parenhandle, WM_CLOSE, 0, 0)If ParentHandle <> 0 Then
'MsgBox (ParentHandle)
bottonHandle = FindWindowEx(ParentHandle, 0, "ThunderRT6CommandButton", "确定")
'MsgBox (bottonHandle)
If bottonHandle <> 0 Then
'MsgBox (bottonHandle)
serverpathHandle = FindWindowEx(ParentHandle, bottonHandle, "ThunderRT6TextBox", Nil)
'MsgBox (serverpathHandle)
If serverpathHandle <> 0 Then
passwordHandle = FindWindowEx(ParentHandle, serverpathHandle, "ThunderRT6TextBox", Nil)
If passwordHandle <> 0 Then
Call SendMessage(passwordHandle, WM_SETTEXT, 0, ByVal CStr("aaa"))
usernamehandle = FindWindowEx(ParentHandle, passwordHandle, "ThunderRT6TextBox", Nil)
'MsgBox (usernamehandle)
If usernamehandle <> 0 Then
Call SendMessage(usernamehandle, WM_SETTEXT, 0, "bbb")
MsgBox (u)
s = SendMessage(bottonHandle, BM_CLICK, 0, 0)
End If
End If
End If
End If
End If
End Sub
代码中好像sendmessage函数不执行呀,大大帮我看看吧
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)
Private Declare Function PostMessage& Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Private Sub Command1_Click()
Dim aa As Long
Dim ParentHandle As Long
Dim bottonHandle As Long
Dim usernanmeHandle As Long
Dim passwordHandle As Long
Dim serverpathHandle As Long
Dim p As Long
Dim u As Long
Dim s As Long
Dim ss As Integer
Dim aabb As String
aa = WinExec("D:\OLE-TECH\SmarGroup4.5\Bin\StartUp.exe", 0)
Sleep (1000)
ParentHandle = FindWindow("ThunderRT6FormDC", "登录")
'Call SendMessage(parenhandle, WM_CLOSE, 0, 0)If ParentHandle <> 0 Then
'MsgBox (ParentHandle)
bottonHandle = FindWindowEx(ParentHandle, 0, "ThunderRT6CommandButton", "确定")
'MsgBox (bottonHandle)
If bottonHandle <> 0 Then
'MsgBox (bottonHandle)
serverpathHandle = FindWindowEx(ParentHandle, bottonHandle, "ThunderRT6TextBox", Nil)
'MsgBox (serverpathHandle)
If serverpathHandle <> 0 Then
passwordHandle = FindWindowEx(ParentHandle, serverpathHandle, "ThunderRT6TextBox", Nil)
If passwordHandle <> 0 Then
Call SendMessage(passwordHandle, WM_SETTEXT, 0, ByVal CStr("aaa"))
usernamehandle = FindWindowEx(ParentHandle, passwordHandle, "ThunderRT6TextBox", Nil)
'MsgBox (usernamehandle)
If usernamehandle <> 0 Then
Call SendMessage(usernamehandle, WM_SETTEXT, 0, "bbb")
MsgBox (u)
s = SendMessage(bottonHandle, BM_CLICK, 0, 0)
End If
End If
End If
End If
End If
End Sub
代码中好像sendmessage函数不执行呀,大大帮我看看吧
sleep 50
postmessage hwnd,wm_lbuttonup,0,0
Const WM_CLOSE = &H10
Const BM_CLICK = &HF5
Const WM_SETTEXT = &HC
这样就可以了,谢谢大家了,大家以后注意这样的问题呀,给大家加分