求助,求一个检测鼠标键盘无操作自动关机的脚本

昵称全被占用了 2014-03-15 06:33:45
首先谢谢您的帮助,想用VB脚本实现,再指定时间内检测到鼠标键盘无操作执行关机命令,并出现对话框提示10分钟后关机,在出现对话框期间检测到键盘鼠标有操作,结束关机命令并重新检测,谢谢,谢谢,谢谢,真心不想用软件华而不实
...全文
472 2 打赏 收藏 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2014-03-17
  • 打赏
  • 举报
回复
How To Create a Screen Saver in Visual Basic Last reviewed: September 13, 1996 Article ID: Q146907 The information in this article applies to: - Standard, Professional, and Enterprise Editions of Microsoft Visual Basic, 16-bit, for Windows, version 4.0 SUMMARY You can create a Windows screen saver with Visual Basic by following the guidelines listed below. However, please note that this article gives only a very rough outline of what you should do for a robust screen saver. These are general guidelines only. MORE INFORMATION Follow these guidelines when creating a Windows screen saver with Visual Basic: In the File Make EXE File dialog, insert the string SCRNSAVE: (in upper case) at the beginning of the Application Title. For example: SCRNSAVE:Flying Fish. In the File Make EXE File dialog, specify the program file name extension as .SCR instead of .EXE. Locate the .SCR program file in the \WINDOWS directory. Give your form the following property settings so that it occupies the entire screen and does not have a title bar: Caption = "" (no caption) ControlBox = False MaxButton = False MinButton = False WindowState = 2 (maximized) Add code to all MouseMove, MouseDown, and KeyDown event handlers that exit the program. Because Visual Basic may invoke the MouseMove event when the form is first loaded, you must write code to ignore the first MouseMove event. The following MouseMove code avoids an artifact event that occurs when the application is first activated or when the application is running and another instance starts (causing loss of focus) and then quits (restoring focus): Private Sub Form_MouseMove (Button As Integer, Shift As Integer, _ X As Single, Y As Single) Static count As Integer If count > 2 Then End Else count = count + 1 End If End Sub This gives you a bit of slack when it comes to artifact MouseMove events. You will want to do something similar with the MouseDown and KeyDown events. Preventing Multiple Launches Windows usually launches the screen saver program multiple times. To prevent more than one copy of your screen saver from running, add the following statements to the Form_Load event handler, or Sub Main if used: Private Sub Form_Load () If App.PrevInstance Then End End If End Sub There is no reason to attempt to restore the previous instance of the screen saver as the active window because it will become the active window when the new instance ends. All you have to do is terminate when you see another instance running. To prevent multiple instances of the application from running as well as to keep the application running, you should move the code from the Form_Load() to a Sub Main(). Then set the project's Startup Form Option to Sub Main(). Setting the project to begin processing at Sub Main is done on the Project tab which is part of Options... under Tools menu. For example: Public Sub Main () If App.PrevInstance Then ' If already running, end the application. End Else Form1.Show 1 ' Show the screen saver form. End If End Sub Launching the Screen Saver Windows takes care of launching the Screen Saver. It keeps track of system idle time and launches the screen saver program. You can use a timer control to periodically draw graphics on the form. Screen savers are selected and configured from Windows Control Panel in the Desktop dialog. The screen saver section of this dialog has a button labeled Setup that invokes the screen saver program with the command line option /c. When your program is invoked with this option, you can display a configuration form to allow the user to select settings such as speed, number of objects, colors, and so on. Detect the /c command line parameter by checking the Command$ function. For example: Private Sub Form_Load () If Command$ = "/c" Then frmConfig.Show ' Display configuration form. Unload Me ' Bypass regular form. End If End Sub When Windows launches the screen saver, it usually specifies the command line option /s. Possible Improvements You may also want your program to appear on top of all other windows by making it a TOPMOST window. For additional information, please see the following article(s) in the Microsoft Knowledge Base: ARTICLE-ID: Q84251 TITLE : How to Create a Topmost or Floating Window in Visual Basic Also, you can find two example programs and a complete explanation showing how to write your own screen savers in Visual Basic in the following book: "Visual Basic Workshop 3.0" by John C. Craig, published by Microsoft Press. This article is a rough outline of what you should do for a robust screen saver. For example, you might want to have the startup be a Sub Main() in which you check for a previous instance and End if there is one. This would avoid the form load totally if there were already an instance running. It might also avoid the artifact MouseMove problem. -------------------------------------------------------------------------------- Additional reference words: 4.00 vb4win vb416 KBCategory: kbprg kbcode KBSubcategory: APrgOther THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Last reviewed: September 13, 1996 © 1998 Microsoft Corporation. All rights reserved. Terms of Use.
嗷嗷叫的老马 2014-03-17
  • 打赏
  • 举报
回复
VBA脚本不太清楚,不过在VB6中可以使用键盘鼠标HOOK,外加调用关机函数. 键盘鼠标HOOK代码封装: http://www.m5home.com/bak_blog/article/245.html 关机函数封装: http://www.m5home.com/bbs/thread-391-1-1.html 思路为: 窗体加一个定时器,周期设置为1秒,然后定时器事件里将一个全局变量A加1,这个A就是空闲时间了. 当这个时间大于某个设定的值,就可以调用关机了. 键盘鼠标HOOK中每产生键盘或鼠标事件,则就将A置0. 定时器内代码类似这样:
dim TimeLeft as long

private sub timer1_timer()
    timeleft=timeleft+1
    if timeleft>600 then     '600秒就是10分钟
        timer1.enabled=false:doevents
        call ShutDownPC(1)       '调用关机
    end if
end sub
然后鼠标键盘事件中只需要timeleft=0就行了.
源码直接下载地址: https://pan.quark.cn/s/387d7c8f6289 在使用IE浏览器的过程中,偶尔会出现重置为默认配置操作未能顺利完成的现象。这种情况的发生可能源于多种因素,包括注册表项出现偏差、浏览器附加组件之间存在不兼容、操作系统授权设置不当或受到恶意程序影响等。针对这一挑战,我们可以通过一系列系统性的方法来逐一诊断和纠正。首先需要验证当前用户是否具备管理员级别的操作权限。在执行重置配置的操作时,必须确保IE浏览器是以管理员身份启动的。具体操作方式为,使用鼠标右键单击IE程序图标,并从弹出的菜单中选择“以管理员身份运行”这一选项。其次,应当检查是否存在恶意软件。恶意程序有时会非法修改浏览器的配置信息,从而阻碍重置过程的正常进行。用户可以借助Windows系统自带的Microsoft Safety Scanner进行检测,或者选择安装并使用第三方安全防护软件执行全面的系统扫描。紧接着,需要对浏览器的缓存数据以及Cookies文件进行清理。在IE浏览器界面中,通过访问“工具”菜单并选择“Internet选项”,然后在弹出的设置界面中,切换至“常规”标签页,并执行清除浏览历史记录的操作,此过程应包含Cookies和临时互联网文件。倘若上述步骤均未能解决问题,那么可以考虑禁用或移除那些可能引发冲突的浏览器附加组件。相关操作需要在“工具”菜单下找到并打开“管理加载项”,对可疑的插件进行禁用处理,并在浏览器重新启动后再次尝试执行重置操作。再者,修复IE浏览器相关的注册表配置也是至关重要的环节。注册表编辑器是一个功能强大的系统工具,任何不当的操作都可能导致严重的系统问题,因此在进行修改前必须创建系统还原点作为安全备份。用户可以通过按下“Win+R”组合...
内容概要:本文详细介绍了光伏储能虚拟同步发电机(VSG)并网仿真模型的Simulink实现方法,系统研究了光伏发电与储能系统融合VSG技术并入电网的动态特性与控制策略。通过构建完整的VSG控制模块,模拟其在并网过程中的虚拟惯性响应、频率调节能力和有功无功功率支撑特性,验证了该系统在增强电网稳定性、提升新能源并网适应性方面的有效性。模型全面涵盖光伏出力特性、储能系统充放电管理、VSG有功-无功解耦控制、下垂控制机制以及并网点动态响应等关键环节,并通过多种工况下的仿真分析,评估系统在不同运行条件下的动态性能与鲁棒性。; 适合人群:具备电力系统、新能源发电、自动控制等相关专业背景,熟悉Matlab/Simulink仿真环境,从事新能源并网、微电网控制或电力电子系统研究的科研人员、工程技术人员及研究生。; 使用场景及目标:①深入理解光伏储能系统如何通过VSG技术模拟同步发电机的惯性和阻尼特性以支持电网稳定;②掌握虚拟惯量控制、下垂控制等VSG核心控制策略在Simulink中的建模、参数设计与实现方法;③为新型电力系统中新能源并网的动态仿真、稳定性分析及控制策略优化提供可靠的模型基础和技术参考。; 阅读建议:建议结合所提供的仿真模型进行逐步操作与参数调试,重点关注VSG控制环路的结构设计、控制器参数整定及其对系统动态性能的影响,同时可将该模型拓展应用于多机并联、微电网孤岛/并网切换、多能源协同控制等更复杂的系统场景中进行进阶研究。

2,506

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧