用VB做一个程序实现鼠标无操作一定时间内关机
因为有时候走开了,也没定时间回来,电脑整天开着浪费电,网上有此功能软件,但又夹着别的功能,我想自己用VB做单一功能的程序实现鼠标无操作一定时间内关机(或侍机),有谁会做吗...
因为有时候走开了,也没定时间回来,电脑整天开着浪费电,网上有此功能软件,但又夹着别的功能,我想自己用VB做单一功能的程序实现鼠标无操作一定时间内关机(或侍机),有谁会做吗??
把关机程序换成.scr格式然后右键安装
当屏保启动的时候就启动关机程序了,就自动关机了。呵呵 ...
只有想法,,做不好,,达达们帮我做一个好吗?? 发到邮箱: risky@tom.com
' 获得鼠标和键盘动作的Api
Private Declare Function GetLastInputInfo Lib "user32" (plii As LASTINPUTINFO) As Boolean
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
' 获得当前时间 单位为毫秒
Private Declare Function GetTickCount Lib "kernel32" () As Long
' 控制系统关机的Api
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Const EWX_SHUTDOWN = 1
Const EWX_LOGOFF = 0
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Dim mEvent As LASTINPUTINFO
Dim StopTime As Long ' 鼠标和键盘,开始无动作的时间
Dim PrvEvent As Long ' 上一次鼠标或者键盘的状态
Private Sub Timer1_Timer()
mEvent.cbSize = Len(mEvent)
GetLastInputInfo mEvent
Debug.Print mEvent.dwTime
' 判断鼠标和键盘的状态,如果状态改变,则重新设置监视时间,保存当前状态
If mEvent.dwTime <> PrvEvent Then
PrvEvent = mEvent.dwTime
StopTime = GetTickCount
Else
' 如果当前时间与开始监视时间超过3,600,000 Ms 则关机.
If (GetTickCount - StopTime) >= (60 * 60 * 1000) Then
Call ExitWindowsEx(EWX_LOGOFF Or EWX_FORCE Or EWX_SHUTDOWN, 0)
End If
End If
End Sub 展开
把关机程序换成.scr格式然后右键安装
当屏保启动的时候就启动关机程序了,就自动关机了。呵呵 ...
只有想法,,做不好,,达达们帮我做一个好吗?? 发到邮箱: risky@tom.com
' 获得鼠标和键盘动作的Api
Private Declare Function GetLastInputInfo Lib "user32" (plii As LASTINPUTINFO) As Boolean
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
' 获得当前时间 单位为毫秒
Private Declare Function GetTickCount Lib "kernel32" () As Long
' 控制系统关机的Api
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Const EWX_SHUTDOWN = 1
Const EWX_LOGOFF = 0
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Dim mEvent As LASTINPUTINFO
Dim StopTime As Long ' 鼠标和键盘,开始无动作的时间
Dim PrvEvent As Long ' 上一次鼠标或者键盘的状态
Private Sub Timer1_Timer()
mEvent.cbSize = Len(mEvent)
GetLastInputInfo mEvent
Debug.Print mEvent.dwTime
' 判断鼠标和键盘的状态,如果状态改变,则重新设置监视时间,保存当前状态
If mEvent.dwTime <> PrvEvent Then
PrvEvent = mEvent.dwTime
StopTime = GetTickCount
Else
' 如果当前时间与开始监视时间超过3,600,000 Ms 则关机.
If (GetTickCount - StopTime) >= (60 * 60 * 1000) Then
Call ExitWindowsEx(EWX_LOGOFF Or EWX_FORCE Or EWX_SHUTDOWN, 0)
End If
End If
End Sub 展开
展开全部
Private Declare Function GetLastInputInfo Lib "user32" (plii As LASTINPUTINFO) As Boolean
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
' 获得当前时间 单位为毫秒
Private Declare Function GetTickCount Lib "kernel32" () As Long
' 控制系统关机的Api
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Const EWX_SHUTDOWN = 1
Const EWX_LOGOFF = 0
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Dim mEvent As LASTINPUTINFO
Dim StopTime As Long ' 鼠标和键盘,开始无动作的时间
Dim PrvEvent As Long ' 上一次鼠标或者键盘的状态
Private Sub Timer1_Timer()
mEvent.cbSize = Len(mEvent)
GetLastInputInfo mEvent
Debug.Print mEvent.dwTime
' 判断鼠标和键盘的状态,如果状态改变,则重新设置监视时间,保存当前状态
If mEvent.dwTime <> PrvEvent Then
PrvEvent = mEvent.dwTime
StopTime = GetTickCount
Else
' 如果当前时间与开始监视时间超过3,600,000 Ms 则关机.
If (GetTickCount - StopTime) >= (10) Then '时间我改了
Shell "shutdown -s" '最简单的关机 有30 秒的时间 你可以在网上搜shutdown 可以用 shutdown -A 取消关机
End If
End If
End Sub
我只改了一下
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
' 获得当前时间 单位为毫秒
Private Declare Function GetTickCount Lib "kernel32" () As Long
' 控制系统关机的Api
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Const EWX_SHUTDOWN = 1
Const EWX_LOGOFF = 0
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Dim mEvent As LASTINPUTINFO
Dim StopTime As Long ' 鼠标和键盘,开始无动作的时间
Dim PrvEvent As Long ' 上一次鼠标或者键盘的状态
Private Sub Timer1_Timer()
mEvent.cbSize = Len(mEvent)
GetLastInputInfo mEvent
Debug.Print mEvent.dwTime
' 判断鼠标和键盘的状态,如果状态改变,则重新设置监视时间,保存当前状态
If mEvent.dwTime <> PrvEvent Then
PrvEvent = mEvent.dwTime
StopTime = GetTickCount
Else
' 如果当前时间与开始监视时间超过3,600,000 Ms 则关机.
If (GetTickCount - StopTime) >= (10) Then '时间我改了
Shell "shutdown -s" '最简单的关机 有30 秒的时间 你可以在网上搜shutdown 可以用 shutdown -A 取消关机
End If
End If
End Sub
我只改了一下
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询