(已解决)狂棘手问题 : 用shutdown(32)待机后 ,如何唤醒机器?
本帖最后由 yarsye 于 2010-6-3 13:42 编辑用shutdown(32)shutdown(64)可以正常待机/休眠 , 可是待机后 , 后面的语言都执行不了,压根就不能唤醒 ,必须得手动唤醒吗? 废话,待机就是硬盘磁针归位,哪还能继续执行,比如说你挂个Q吧,待机唤醒后,QQ会自动重新登录,说明QQ在待机的时候离线饿了。。。 待机一般必须手动唤醒,因为一切程序进入停止状态,休眠更不用说,相当于关机,这时除非用bios自带的唤醒功能 XD学习语言是好事,但也要明白一些基本的MS系统知识吧 本帖最后由 Joo 于 2010-6-3 10:35 编辑
学习:face (4):。。。 但是我看到很多压力测试工具可以 进入系统休眠 然后自动唤醒 唤醒之后还能接着休眠 然后再自动唤醒
AutoIT就不能实现这个功能吗? 但是我看到很多压力测试工具可以 进入系统休眠 然后自动唤醒 唤醒之后还能接着休眠 然后再自动唤醒
AutoI ...
yarsye 发表于 2010-6-3 09:42 http://www.autoitx.com/images/common/back.gif
发来看看 gang刚才试了下,要实现你所说的,必须使shutdown函数能及时返回 我没法上传 但是确实很多工具都可以 我这就有2个 只不过那些程序都不是用AutoIT写的 已经解决了这个问题#include <date.au3>
;===============================================================================
;
; Description: Sets a wakeup time to wake it up if the system / computer is hibernating or standby
; Parameter(s): $Hour - Hour Values : 0-23
; $Minute - Minutes Values: 0-59
; $Day - Days Values : 1-31 (optional)
; $Month - Month Values : 1-12 (optional)
; $Year - Year Values : > 0 (optional)
;
; Requirement(s): DllCall
; Return Value(s):On Success - 1
; On Failure - 0 sets @ERROR = 1 and @EXTENDED (Windows API error code)
;
; Error code(s): http://msdn.microsoft.com/library/default....error_codes.asp
;
; Author(s): Bastel123 aka Sebastian
; Note(s): -
;
;===============================================================================
func SetWakeUpTime($Hour,$Minute,$Day=@mday,$Month=@mon,$Year=@YEAR)
$SYSTEMTIME = DllStructCreate("ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort")
$lpSYSTEMTIME = DllStructGetPtr($SYSTEMTIME)
$LOCALFILETIME=DllStructCreate("dword;dword")
$lpLOCALFILETIME = DllStructGetPtr($LOCALFILETIME)
$DueTime=DllStructCreate("dword;dword")
$lpDueTime=DllStructGetPtr($DueTime)
DllStructSetData($SYSTEMTIME, 1, $Year)
DllStructSetData($SYSTEMTIME, 2, $Month)
DllStructSetData($SYSTEMTIME, 3, _DateToDayOfWeek($Year,$Month,$Day)-1)
DllStructSetData($SYSTEMTIME, 4, $Day)
DllStructSetData($SYSTEMTIME, 5, $Hour)
DllStructSetData($SYSTEMTIME, 6, $Minute)
DllStructSetData($SYSTEMTIME, 7, 0)
DllStructSetData($SYSTEMTIME, 8, 0)
$result = DllCall("kernel32.dll", "long", "SystemTimeToFileTime", "ptr", $lpSystemTime, "ptr", $lpLocalFileTime)
If $result = 0 Then
Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
SetExtended($lastError)
SetError(1)
Return 0
EndIf
$result = DllCall("kernel32.dll", "long", "LocalFileTimeToFileTime", "ptr", $lpLocalFileTime, "ptr", $lpLocalFileTime)
If $result = 0 Then
Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
SetExtended($lastError)
SetError(1)
Return 0
EndIf
$result = DllCall("kernel32.dll", "long", "CreateWaitableTimer", "long", 0, "long", True, "str", "")
If $result = 0 Then
Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
SetExtended($lastError)
SetError(1)
Return 0
EndIf
DllCall("kernel32.dll", "none", "CancelWaitableTimer", "long",$result)
DllStructSetData($DueTime, 1, DllStructGetData($LocalFILETIME, 1))
DllStructSetData($DueTime, 2, DllStructGetData($LocalFILETIME, 2))
$result = DllCall("kernel32.dll", "long", "SetWaitableTimer", "long",$result, "ptr", $lpDueTime, "long", 1000, "long", 0, "long", 0, "long", true)
If $result = 0 Then
Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
SetExtended($lastError)
SetError(1)
Return 0
EndIf
return 1
EndFunc
;===============================================================================
;
; Description: Set the computer in Hibernate or Standby Status
; Parameter(s): $Mode - Suspend mode : True=Hibernate, False=Suspend
; $Force- Force-Mode : True=the system suspends operation immediately
; False=FALSE, the system broadcasts a PBT_APMQUERYSUSPEND event to each application to request permission to suspend operation
;
; Requirement(s): DllCall
;
; Author(s): Bastel123 aka Sebastian
; Note(s): If the system does not support hibernate use the standby mode -
;
;===============================================================================
Func SetSuspend($mode=False,$force=true)
$result = DllCall("PowrProf.dll", "long", "SetSuspendState", "long",$mode, "long",$force, "long", false)
EndFunc
SetWakeUpTime(@HOUR,@min+1); wakeup the system in 1 minutes from now
SetSuspend(); go to hibernate mode
从aronglai 牛人那转过来的 我试过了 可以实现我要的功能 不仅可以进入待机 而且可以唤醒
但是 我看不懂 先拿来用了再说 哇 楼上这段代码好厉害... 支持LZ- -:face (25): 先设置唤醒(SetWakeUpTime)后进入待机SetSuspend();
如果两行颠倒就不行了 是的 颠倒就不行 呵呵学习一下。。