本人想用VB控制IE垂直滚动条,我写的代码如下,但是不能滚动,求高手帮忙Private Sub Form_Load()
Label1.AutoSize = True
Timer1.Interval = 500
End SubPrivate Sub Timer1_Timer()
hWnd1 = GetForegroundWindow() '得到活动窗口的句柄
Label1.Caption = getCaption(hWnd1)
End Sub
'根据窗口句柄得到该窗口的标题
Function getCaption(hwnd As Long)
Dim nPos As Long
Dim hWndlength As Long, hWndTitle As String, A As Long
hWndlength = GetWindowTextLength(hwnd)
hWndTitle = String$(hWndlength, 0)
A = GetWindowText(hwnd, hWndTitle, (hWndlength + 1))
getCaption = hWndTitle
Debug.Print getCaption
If Right(getCaption, 8) = "Explorer" Then
nPos = GetScrollPos(hwnd, SB_HORZ)
SetScrollPos Me.hwnd, SB_HORZ, nPos + 100, True
End If
End Function
Label1.AutoSize = True
Timer1.Interval = 500
End SubPrivate Sub Timer1_Timer()
hWnd1 = GetForegroundWindow() '得到活动窗口的句柄
Label1.Caption = getCaption(hWnd1)
End Sub
'根据窗口句柄得到该窗口的标题
Function getCaption(hwnd As Long)
Dim nPos As Long
Dim hWndlength As Long, hWndTitle As String, A As Long
hWndlength = GetWindowTextLength(hwnd)
hWndTitle = String$(hWndlength, 0)
A = GetWindowText(hwnd, hWndTitle, (hWndlength + 1))
getCaption = hWndTitle
Debug.Print getCaption
If Right(getCaption, 8) = "Explorer" Then
nPos = GetScrollPos(hwnd, SB_HORZ)
SetScrollPos Me.hwnd, SB_HORZ, nPos + 100, True
End If
End Function
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货