![]() |
#2
e3bnsd2012-12-13 22:05
|
只有本站会员才能查看附件,请 登录

Private Declare Function GetLastInputInfo Lib "user32" (plii As LASTINPUTINFO) As Boolean
Private Declare Function GetTickCount Lib "kernel32" () As Long
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 Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Dim hwnd1, hwnd2, hwnd3 As Long
Dim winHwnd As Long
Dim RetVal As Long
Private Const WM_CLOSE As Long = &H10
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Private Sub Command1_Click()
Dim lii As LASTINPUTINFO
lii.cbSize = Len(lii)
Do
If GetLastInputInfo(lii) Then Label1 = "系统空闲时间:" & (GetTickCount - lii.dwTime) / 60000 & "分"
DoEvents
Loop
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
hwnd1 = FindWindow("IEFrame", "VB6论坛-编程论坛 - Windows Internet Explorer")
winHwnd = FindWindow(vbNullString, "VB6论坛-编程论坛 - Windows Internet Explorer")
Debug.Print winHwnd
Label2.Caption = hwnd1
If hwnd1 <> 0 Then
Call a
End If
If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
End If
End Sub
Private Declare Function GetTickCount Lib "kernel32" () As Long
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 Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Dim hwnd1, hwnd2, hwnd3 As Long
Dim winHwnd As Long
Dim RetVal As Long
Private Const WM_CLOSE As Long = &H10
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Private Sub Command1_Click()
Dim lii As LASTINPUTINFO
lii.cbSize = Len(lii)
Do
If GetLastInputInfo(lii) Then Label1 = "系统空闲时间:" & (GetTickCount - lii.dwTime) / 60000 & "分"
DoEvents
Loop
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
hwnd1 = FindWindow("IEFrame", "VB6论坛-编程论坛 - Windows Internet Explorer")
winHwnd = FindWindow(vbNullString, "VB6论坛-编程论坛 - Windows Internet Explorer")
Debug.Print winHwnd
Label2.Caption = hwnd1
If hwnd1 <> 0 Then
Call a
End If
If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
End If
End Sub