向窗体的TEXT控件写,执行command按钮等操作。
gbCancel = True
Dim nCHILD As Long
Dim lParent As Long
Dim tTempStr As String * 256
Dim nA00 As Long
Dim nA01 As Long
Dim nA02 As Long
Dim nA03 As Long
Dim nA04 As Long
Dim nA05 As Long
Dim lHwnd As Long
Dim lResult As Long
Dim cCaption As String
Dim tTempStr0 As String * 256
Dim tTempStr1 As String * 256
Dim tTempStr2 As String * 256
Dim cOkTest As String
cCaption = Space(120)
nA00 = Val(Me.Text1(0).Text) '窗体
nA01 = Val(Me.Text1(1).Text) '
nA02 = Val(Me.Text1(2).Text)
nA03 = Val(Me.Text1(3).Text)
'---------------------------------------------------------
lHwnd = nA00
lResult = SendMessage(lHwnd, WM_GETTEXT, Len(cCaption), ByVal cCaption)
cCaption = StripTerminator(cCaption)
If cCaption = "短信息发送" Then
If nA00 = 0 Or nA01 = 0 Or nA02 = 0 Or nA03 = 0 Then
Call Msg_Stop("参数设置不完整!!!")
Else
'---------------------------------------
lHwnd = nA01
cCaption = Me.Text2.Text
lResult = SendMessage(lHwnd, WM_SETTEXT, 0, ByVal cCaption) '手机号码
lHwnd = nA02
cCaption = Me.Text3.Text
lResult = SendMessage(lHwnd, WM_SETTEXT, 0, ByVal cCaption) '短信内容
lHwnd = nA03
lResult = PostMessage(lHwnd, WM_LBUTTONDOWN, 0, 0) '发送
lResult = PostMessage(lHwnd, WM_LBUTTONUP, 0, 0) '发送
'---------------------------------------
DoEvents
lstWindows.Clear
nCHILD = FindWindow(vbNullString, "发 送")
Do While nCHILD = 0
nCHILD = FindWindow(vbNullString, "发 送")
'---------------------------------------------------有Information表示异常
If FindWindow(vbNullString, "Information") > 0 Then
Exit Sub
End If
'---------------------------------------------------有Information表示异常
Loop
nCHILD = GetWindow(nCHILD, GW_CHILD)
Do While nCHILD <> 0 '如果有子窗口
lHwnd = nCHILD
If List1.List(0) <> Capt(0) & Hex(lHwnd) Then
lResult = GetClassName(lHwnd, tTempStr0, 255)
lResult = GetWindowText(lHwnd, tTempStr1, 255)
If Me.Option1.Value Then
cOkTest = "否(&N)"
Else
cOkTest = "是(&Y)"
End If
If Left(tTempStr1, InStr(tTempStr1, vbNullChar) - 1) = cOkTest Then
lstWindows.AddItem Capt(0) & Hex(lHwnd)
lstWindows.AddItem Capt(1) & Left(tTempStr0, InStr(tTempStr0, vbNullChar) - 1)
lstWindows.AddItem Capt(2) & Left(tTempStr1, InStr(tTempStr1, vbNullChar) - 1)
End If
End If
nCHILD = GetWindow(nCHILD, GW_HWNDNEXT) '取得下一个兄弟窗口的句柄
Loop
DoEvents
lHwnd = Val("&H" & Mid(lstWindows.List(0), 11))
lResult = PostMessage(lHwnd, WM_LBUTTONDOWN, 0, 0) '确认
lResult = PostMessage(lHwnd, WM_LBUTTONUP, 0, 0) '确认
DoEvents
If Me.Option2.Value Then '发送
lstWindows.Clear
nCHILD = FindWindow(vbNullString, "Information") '查找发送成功
Do While nCHILD = 0
nCHILD = FindWindow(vbNullString, "Information")
Loop
nCHILD = GetWindow(nCHILD, GW_CHILD)
Do While nCHILD <> 0 '如果有子窗口
lHwnd = nCHILD
If List1.List(0) <> Capt(0) & Hex(lHwnd) Then
lResult = GetClassName(lHwnd, tTempStr0, 255)
lResult = GetWindowText(lHwnd, tTempStr1, 255)
cOkTest = "OK"
If Left(tTempStr1, InStr(tTempStr1, vbNullChar) - 1) = cOkTest Then
lstWindows.AddItem Capt(0) & Hex(lHwnd)
lstWindows.AddItem Capt(1) & Left(tTempStr0, InStr(tTempStr0, vbNullChar) - 1)
lstWindows.AddItem Capt(2) & Left(tTempStr1, InStr(tTempStr1, vbNullChar) - 1)
End If
End If
nCHILD = GetWindow(nCHILD, GW_HWNDNEXT) '取得下一个兄弟窗口的句柄
Loop
DoEvents
lHwnd = Val("&H" & Mid(lstWindows.List(0), 11))
lResult = PostMessage(lHwnd, WM_LBUTTONDOWN, 0, 0) 'OK
lResult = PostMessage(lHwnd, WM_LBUTTONUP, 0, 0) 'OK
End If
DoEvents
'---------------------------------------
lHwnd = nA01
lResult = SendMessage(lHwnd, WM_SETTEXT, 0, ByVal "") '手机号码
lHwnd = nA02
lResult = SendMessage(lHwnd, WM_SETTEXT, 0, ByVal "") '短信内容
'---------------------------------------
End If
Else
Call Msg_Stop("短信发送主窗体没有打开!!!")
End If