找回密码
 加入
搜索
查看: 4425|回复: 1

[AU3基础] 那位前辈有简单的定时唤醒方法?

[复制链接]
发表于 2014-1-1 14:59:29 | 显示全部楼层 |阅读模式
代码来源  http://www.autoitx.com/forum.php ... hlight=%BB%BD%D0%D1

怎么每次唤醒都是用户选择,要输入密码才能进入桌面。怎么才能唤醒直接进入桌面呢?
  1. #include <date.au3>

  2. ;===============================================================================
  3. ;
  4. ; Description:      Sets a wakeup time to wake it up if the system / computer is hibernating or standby
  5. ; Parameter(s):     $Hour     - Hour Values    : 0-23
  6. ;                    $Minute - Minutes Values: 0-59
  7. ;                    $Day    - Days Values    : 1-31    (optional)
  8. ;                   $Month     - Month Values    : 1-12     (optional)
  9. ;                   $Year     - Year Values    : > 0     (optional)
  10. ;
  11. ; Requirement(s):   DllCall
  12. ; Return Value(s):  On Success - 1
  13. ;                   On Failure - 0 sets @ERROR = 1 and @EXTENDED (Windows API error code)
  14. ;
  15. ; Error code(s):     http://msdn.microsoft.com/library/default....error_codes.asp
  16. ;
  17. ; Author(s):        Bastel123 aka Sebastian
  18. ; Note(s):          -
  19. ;
  20. ;===============================================================================
  21. func SetWakeUpTime($Hour,$Minute,$Day=@mday,$Month=@mon,$Year=@YEAR)

  22. $SYSTEMTIME = DllStructCreate("ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort")
  23. $lpSYSTEMTIME = DllStructGetPtr($SYSTEMTIME)
  24. $LOCALFILETIME=DllStructCreate("dword;dword")
  25. $lpLOCALFILETIME = DllStructGetPtr($LOCALFILETIME)
  26. $DueTime=DllStructCreate("dword;dword")
  27. $lpDueTime=DllStructGetPtr($DueTime)

  28. DllStructSetData($SYSTEMTIME, 1, $Year)
  29. DllStructSetData($SYSTEMTIME, 2, $Month)
  30. DllStructSetData($SYSTEMTIME, 3, _DateToDayOfWeek($Year,$Month,$Day)-1)
  31. DllStructSetData($SYSTEMTIME, 4, $Day)
  32. DllStructSetData($SYSTEMTIME, 5, $Hour)
  33. DllStructSetData($SYSTEMTIME, 6, $Minute)
  34. DllStructSetData($SYSTEMTIME, 7, 0)
  35. DllStructSetData($SYSTEMTIME, 8, 0)

  36. $result = DllCall("kernel32.dll", "long", "SystemTimeToFileTime", "ptr", $lpSystemTime, "ptr", $lpLocalFileTime)
  37. If $result[0] = 0 Then
  38.     Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
  39.     SetExtended($lastError[0])
  40.     SetError(1)
  41.     Return 0
  42. EndIf
  43. $result = DllCall("kernel32.dll", "long", "LocalFileTimeToFileTime", "ptr", $lpLocalFileTime, "ptr", $lpLocalFileTime)
  44. If $result[0] = 0 Then
  45.     Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
  46.     SetExtended($lastError[0])
  47.     SetError(1)
  48.     Return 0
  49. EndIf
  50. $result = DllCall("kernel32.dll", "long", "CreateWaitableTimer", "long", 0, "long", True, "str", "")
  51. If $result[0] = 0 Then
  52.     Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
  53.     SetExtended($lastError[0])
  54.     SetError(1)
  55.     Return 0
  56. EndIf
  57. DllCall("kernel32.dll", "none", "CancelWaitableTimer", "long",$result[0])

  58. DllStructSetData($DueTime, 1, DllStructGetData($LocalFILETIME, 1))
  59. DllStructSetData($DueTime, 2, DllStructGetData($LocalFILETIME, 2))

  60. $result = DllCall("kernel32.dll", "long", "SetWaitableTimer", "long",$result[0], "ptr", $lpDueTime, "long", 1000, "long", 0, "long", 0, "long", true)
  61. If $result[0] = 0 Then
  62.     Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
  63.     SetExtended($lastError[0])
  64.     SetError(1)
  65.     Return 0
  66. EndIf
  67. return 1
  68. EndFunc



  69. ;===============================================================================
  70. ;
  71. ; Description:      Set the computer in Hibernate or Standby Status
  72. ; Parameter(s):     $Mode     - Suspend mode    : True=Hibernate, False=Suspend
  73. ;                    $Force  - Force-Mode    : True=the system suspends operation immediately
  74. ;                                              False=FALSE, the system broadcasts a PBT_APMQUERYSUSPEND event to each application to request permission to suspend operation
  75. ;
  76. ; Requirement(s):   DllCall
  77. ;
  78. ; Author(s):        Bastel123 aka Sebastian
  79. ; Note(s):          If the system does not support hibernate use the standby mode          -
  80. ;
  81. ;===============================================================================
  82. Func SetSuspend($mode=False,$force=true)
  83.     $result = DllCall("PowrProf.dll", "long", "SetSuspendState", "long",$mode, "long",$force, "long", false)
  84. EndFunc







  85. SetWakeUpTime(@HOUR,@min+1); wakeup the system in 1 minutes from now

  86. SetSuspend(); go to hibernate mode
复制代码
发表于 2014-1-1 19:07:47 | 显示全部楼层
直接进入桌面似乎是要设置自动登录吧?
还有在休眠唤醒的设置中去掉需要密码的选项。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2026-9-22 15:23 , Processed in 0.073112 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表