求一个VB检测鼠标键盘无操作自动关机脚本 50
首先谢谢您的帮助,想用VB脚本实现,再指定时间内检测到鼠标键盘无操作执行关机命令,并出现对话框提示10分钟后关机,在出现对话框期间检测到键盘鼠标有操作,结束关机命令并重新...
首先谢谢您的帮助,想用VB脚本实现,再指定时间内检测到鼠标键盘无操作执行关机命令,并出现对话框提示10分钟后关机,在出现对话框期间检测到键盘鼠标有操作,结束关机命令并重新检测,谢谢,谢谢,谢谢,真心不想用软件华而不实,邮箱也可以1451677288@qq.com
首先谢谢你,但是没成功,希望您详细点,我对这个一点都不懂 展开
首先谢谢你,但是没成功,希望您详细点,我对这个一点都不懂 展开
展开全部
楼上vb的可行,在vb.net中不行,vb.net格式如下
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Public Class Form2
'定义结构体
Private Structure LASTINPUTINFO
Public cbSize As Int32
Public dwTime As Int32
End Structure
'引入系统API
Private Declare Function GetLastInputInfo Lib "user32" (ByVal plii As IntPtr) As Long '重新定义为 IntPtr
'在计时器中,进行相应的计算
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'获取系统的运行时间
Dim systemUpTime As Integer = Environment.TickCount
Dim LastInputTicks As Integer = 0
Dim IdleTicks As Integer = 0
Dim LastInputInfo As New LASTINPUTINFO()
LastInputInfo.cbSize = Len(LastInputInfo)
Dim thObject2 As Runtime.InteropServices.GCHandle = Runtime.InteropServices.GCHandle.Alloc(LastInputInfo, Runtime.InteropServices.GCHandleType.Pinned)
Dim tpObject2 As IntPtr = thObject2.AddrOfPinnedObject() '取得指向结构的指针
'获取用户上次操作的时间
If GetLastInputInfo(tpObject2) Then
LastInputTicks = CInt(thObject2.Target.dwTime)
'LastInputTicks = CInt(LastInputInfo.dwTime)
'求差,就是系统空闲的时间
IdleTicks = systemUpTime - LastInputTicks
End If
lblSystemUpTime.Text = "系统运行时间:" + Convert.ToString(systemUpTime / 1000) + " 秒"
lblIdleTime.Text = "系统空闲时间:" + Convert.ToString(IdleTicks / 1000) + " 秒"
End Sub
End Class
展开全部
Option Explicit
Private Declare Function GetLastInputInfo Lib "user32" (plii As LASTINPUTINFO) As Boolean
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Dim lii As LASTINPUTINFO
Private Sub Form_Load()
Timer1.Interval = 1000
lii.cbSize = Len(lii)
End Sub
Private Sub Timer1_Timer()
If GetLastInputInfo(lii) Then
If (GetTickCount - lii.dwTime) / 60000 >= 15 Then
Shell "shutdown.exe -s -t 180"
Call MsgBox("由于本机15分钟没有操作,如果3分钟后没有反应,系统将强制关机", vbYesNo + vbExclamation + vbDefaultButton2, "提示")
End If
End If
End Sub
更多追问追答
追问
是直接复制文本吗?保存成什么格式?
追答
vb的格式.
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询