Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) 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 SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function RedrawWindow Lib "user32" (ByVal hwnd As Long, lprcUpdate As Any, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Private Const WM_SETTEXT = &HC
Private Const NULLAPI = 0&
Private Const RDW_INVALIDATE = &H1
Private Const RDW_ERASE = &H4
'改变窗体的标题
Private Sub ChangeForm()
Dim sClassName As String
Dim mString As String
Dim buffer As String
Dim WindowHandle As Long
Dim TextLength As Long
WindowHandle = 0
sClassName = ("IEFrame")
mString = " "
'查找Windows
WindowHandle = FindWindowEx(WindowHandle, 0, sClassName, vbNullString)
If WindowHandle <> 0 Then
TextLength = SendMessage(WindowHandle, WM_GETTEXTLENGTH, 0, 0)
buffer = String(TextLength, 0)
Call SendMessageByString(WindowHandle, WM_GETTEXT, TextLength + 1, buffer)
If InStr(buffer, "优快云") > 0 Then
Call SendMessageByString(WindowHandle, WM_SETTEXT, 0, ByVal mString)
' Call RedrawWindow(WindowHandle, ByVal NULLAPI, NULLAPI, RDW_INVALIDATE Or RDW_ERASE)
WindowHandle = 0
End If
End If
End Sub
'窗体加载
Private Sub Form_Load()
ShowIe
' Unload Me
Me.Timer1.Enabled = True
End Sub
'Timer事件
Private Sub Timer1_Timer()
Call ChangeForm
End Sub
'打开IE
Private Sub ShowIe()
On Error GoTo Err
Dim objExplorer As Object
Err:
Set objExplorer = CreateObject("InternetExplorer.Application")
' objExplorer.Navigate "https://www.worldtendency.com:8443/EntryExit/"
objExplorer.Navigate "www.youkuaiyun.com"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 1000
objExplorer.Height = 800
objExplorer.Visible = 1
End Sub