找回密码
 加入
搜索
查看: 30162|回复: 62

[AU3基础] (已解决)狂棘手问题 : 用shutdown(32)待机后 ,如何唤醒机器?

 火... [复制链接]
发表于 2010-6-3 08:53:57 | 显示全部楼层 |阅读模式
本帖最后由 yarsye 于 2010-6-3 13:42 编辑

用shutdown(32)  shutdown(64)可以正常待机/休眠 , 可是待机后 , 后面的语言都执行不了,压根就不能唤醒 ,必须得手动唤醒吗?

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-6-3 09:15:43 | 显示全部楼层
废话,待机就是硬盘磁针归位,哪还能继续执行,比如说你挂个Q吧,待机唤醒后,QQ会自动重新登录,说明QQ在待机的时候离线饿了。。。
发表于 2010-6-3 09:18:21 | 显示全部楼层
待机一般必须手动唤醒,因为一切程序进入停止状态,休眠更不用说,相当于关机,这时除非用bios自带的唤醒功能
发表于 2010-6-3 09:18:50 | 显示全部楼层
XD学习语言是好事,但也要明白一些基本的MS系统知识吧
发表于 2010-6-3 09:40:26 | 显示全部楼层
本帖最后由 Joo 于 2010-6-3 10:35 编辑

学习。。。
 楼主| 发表于 2010-6-3 09:42:20 | 显示全部楼层
但是我看到很多压力测试工具可以 进入系统休眠 然后自动唤醒 唤醒之后还能接着休眠 然后再自动唤醒
AutoIT就不能实现这个功能吗?
发表于 2010-6-3 10:00:14 | 显示全部楼层
但是我看到很多压力测试工具可以 进入系统休眠 然后自动唤醒 唤醒之后还能接着休眠 然后再自动唤醒
AutoI ...
yarsye 发表于 2010-6-3 09:42



    发来看看
发表于 2010-6-3 10:30:10 | 显示全部楼层
gang刚才试了下,要实现你所说的,必须使shutdown函数能及时返回
 楼主| 发表于 2010-6-3 13:30:33 | 显示全部楼层
我没法上传 但是确实很多工具都可以 我这就有2个 只不过那些程序都不是用AutoIT写的
 楼主| 发表于 2010-6-3 13:41:28 | 显示全部楼层
已经解决了这个问题
#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] = 0 Then
    Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
    SetExtended($lastError[0])
    SetError(1)
    Return 0
EndIf
$result = DllCall("kernel32.dll", "long", "LocalFileTimeToFileTime", "ptr", $lpLocalFileTime, "ptr", $lpLocalFileTime)
If $result[0] = 0 Then
    Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
    SetExtended($lastError[0])
    SetError(1)
    Return 0
EndIf
$result = DllCall("kernel32.dll", "long", "CreateWaitableTimer", "long", 0, "long", True, "str", "")
If $result[0] = 0 Then
    Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
    SetExtended($lastError[0])
    SetError(1)
    Return 0
EndIf
DllCall("kernel32.dll", "none", "CancelWaitableTimer", "long",$result[0])

DllStructSetData($DueTime, 1, DllStructGetData($LocalFILETIME, 1))
DllStructSetData($DueTime, 2, DllStructGetData($LocalFILETIME, 2))

$result = DllCall("kernel32.dll", "long", "SetWaitableTimer", "long",$result[0], "ptr", $lpDueTime, "long", 1000, "long", 0, "long", 0, "long", true)
If $result[0] = 0 Then
    Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
    SetExtended($lastError[0])
    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 牛人那转过来的 我试过了 可以实现我要的功能 不仅可以进入待机 而且可以唤醒
但是 我看不懂 先拿来用了再说
发表于 2010-6-3 13:52:55 | 显示全部楼层
哇 楼上这段代码好厉害...
发表于 2010-6-3 15:17:15 | 显示全部楼层
支持LZ- -
发表于 2010-6-3 18:31:22 | 显示全部楼层
先设置唤醒(SetWakeUpTime)后进入待机SetSuspend();
如果两行颠倒就不行了
 楼主| 发表于 2010-6-4 09:04:25 | 显示全部楼层
是的 颠倒就不行
发表于 2010-6-4 12:00:48 | 显示全部楼层
呵呵学习一下。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-17 07:23 , Processed in 0.086083 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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