Показать полную графическую версию : Возможноли автоматическое включение ПК через скрипт?
Anarasius
02-11-2009, 00:27
Можно ли сделать так чтобы скрипт запрограммировал компьютер на включение, если нет, то я слышал что можно через скрипт вывести компьютер из спящего режима так как это можно сделать или
Можно ли сделать так чтобы скрипт запрограммировал компьютер на включение »
Интересно, а скрипт будет запущен виртуально? http://files.myopera.com/Creat0R/Opera_AC/Icons/Kolobki/crazy.gif
можно через скрипт вывести компьютер из спящего режима »
Вроде можно:
#include <Date.au3>
SetWakeUpTime(@HOUR (http://www.autoitscript.com/autoit3/docs/macros.htm#@HOUR), @MIN (http://www.autoitscript.com/autoit3/docs/macros.htm#@MIN) + 2) ;wakeup the system in 2 minutes from now
SetSuspend() ;go to hibernate mode
;===============================================================================
;
; 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 (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) SetSuspend($mode = True (http://www.autoitscript.com/autoit3/docs/keywords.htm#True), $force = True (http://www.autoitscript.com/autoit3/docs/keywords.htm#True))
$result = DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("PowrProf.dll", "long", "SetSuspendState", "long", $mode, "long", $force, "long", False (http://www.autoitscript.com/autoit3/docs/keywords.htm#False))
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>SetSuspend
;===============================================================================
;
; 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 (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes.asp)
;
; Author(s): Bastel123 aka Sebastian
; Note(s): -
;
;===============================================================================
Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) SetWakeUpTime($Hour, $Minute, $Day = @MDAY (http://www.autoitscript.com/autoit3/docs/macros.htm#@MDAY), $Month = @MON (http://www.autoitscript.com/autoit3/docs/macros.htm#@MON), $Year = @YEAR (http://www.autoitscript.com/autoit3/docs/macros.htm#@YEAR))
$SYSTEMTIME = DllStructCreate (http://www.autoitscript.com/autoit3/docs/functions/DllStructCreate.htm)("ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort")
$lpSYSTEMTIME = DllStructGetPtr (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetPtr.htm)($SYSTEMTIME)
$LOCALFILETIME = DllStructCreate (http://www.autoitscript.com/autoit3/docs/functions/DllStructCreate.htm)("dword;dword")
$lpLOCALFILETIME = DllStructGetPtr (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetPtr.htm)($LOCALFILETIME)
$DueTime = DllStructCreate (http://www.autoitscript.com/autoit3/docs/functions/DllStructCreate.htm)("dword;dword")
$lpDueTime = DllStructGetPtr (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetPtr.htm)($DueTime)
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($SYSTEMTIME, 1, $Year)
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($SYSTEMTIME, 2, $Month)
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($SYSTEMTIME, 3, _DateToDayOfWeek($Year, $Month, $Day) - 1)
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($SYSTEMTIME, 4, $Day)
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($SYSTEMTIME, 5, $Hour)
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($SYSTEMTIME, 6, $Minute)
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($SYSTEMTIME, 7, 0)
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($SYSTEMTIME, 8, 0)
$result = DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("kernel32.dll", "long", "SystemTimeToFileTime", "ptr", $lpSYSTEMTIME, "ptr", $lpLOCALFILETIME)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $result[0] = 0 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $lastError = DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("kernel32.dll", "int", "GetLastError")
Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) SetError (http://www.autoitscript.com/autoit3/docs/functions/SetError.htm)(1, $lastError[0], 0)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
$result = DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("kernel32.dll", "long", "LocalFileTimeToFileTime", "ptr", $lpLOCALFILETIME, "ptr", $lpLOCALFILETIME)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $result[0] = 0 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $lastError = DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("kernel32.dll", "int", "GetLastError")
Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) SetError (http://www.autoitscript.com/autoit3/docs/functions/SetError.htm)(1, $lastError[0], 0)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
$result = DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("kernel32.dll", "long", "CreateWaitableTimer", "long", 0, "long", True (http://www.autoitscript.com/autoit3/docs/keywords.htm#True), "str", "")
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $result[0] = 0 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $lastError = DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("kernel32.dll", "int", "GetLastError")
Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) SetError (http://www.autoitscript.com/autoit3/docs/functions/SetError.htm)(1, $lastError[0], 0)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("kernel32.dll", "none", "CancelWaitableTimer", "long", $result[0])
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($DueTime, 1, DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($LOCALFILETIME, 1))
DllStructSetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructSetData.htm)($DueTime, 2, DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($LOCALFILETIME, 2))
$result = DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("kernel32.dll", "long", "SetWaitableTimer", "long", $result[0], "ptr", $lpDueTime, _
"long", 1000, "long", 0, "long", 0, "long", True (http://www.autoitscript.com/autoit3/docs/keywords.htm#True))
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $result[0] = 0 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $lastError = DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("kernel32.dll", "int", "GetLastError")
Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) SetError (http://www.autoitscript.com/autoit3/docs/functions/SetError.htm)(1, $lastError[0], 0)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) 1
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>SetWakeUpTime
Источник (http://www.autoitscript.com/forum/index.php?showtopic=21575)
Anarasius
02-11-2009, 12:13
Не совсем я там разобрался мне надо что бы ПК каждый день уходил в спящий режим в 22.55 а включался в 9.55
Примерно так. Но Creat0R если что поправит
#include <Date.au3>
While 1; цикл для проверки времени
If @HOUR = 22 AND @MIN = 55 Then; если время нужное, то...
$sFuture = _DateAdd('D', 1, _NowCalcDate()); вычислить завтрашнюю дату
$aFuture = StringSplit($sFuture, '/'); найти день/меся/год
SetWakeUpTime(9, 55, $aFuture[3], $aFuture[2], $aFuture[1]); задать время для выхода из спящего режима
SetSuspend() ;уйти в спящий режим
Else
Sleep(100)
EndIf
WEnd
;===============================================================================
;
; 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 = True, $force = True)
$result = DllCall("PowrProf.dll", "long", "SetSuspendState", "long", $mode, "long", $force, "long", False)
EndFunc ;==>SetSuspend
;===============================================================================
;
; 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")
Return SetError(1, $lastError[0], 0)
EndIf
$result = DllCall("kernel32.dll", "long", "LocalFileTimeToFileTime", "ptr", $lpLOCALFILETIME, "ptr", $lpLOCALFILETIME)
If $result[0] = 0 Then
Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")
Return SetError(1, $lastError[0], 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")
Return SetError(1, $lastError[0], 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")
Return SetError(1, $lastError[0], 0)
EndIf
Return 1
EndFunc ;==>SetWakeUpTime
Creat0R, kaster, можете сделать похожий скрипт, чтобы комп уходил в ждущий режим а не в спящий?
Спасибо.
Могу только предположить, что надо вызвать функцию SetSuspend с первым параметром False. Попробуй
SetSuspend(False)
Попробовал, уходит действительно в ждущий режим. Но не выходит из него сам, включал комп вручную.
Пробовал потом менять оба параметра, т.е. так Func SetSuspend($mode = False, $force = False)
Тоже уходит в ждущий и не выходит из него. Второй параметр поменял наугад, думал что это поможет :)
После вывода из ждущего режима у меня почемуто глючит интернет. Модем не устанавливает соединение :dont-know
Если у кого-то будет тоже повторятся глюк, то нужно просто перезагрузить комп.
Где-то писали, что для корректного ухода в ждущий режим, необходимо чтобы Hibernate был отключен в опциях электропитания. Может поможет
А как "по-правильному запустить некий файл, обычный или музыкальный при описанном в этой теме выходе из спящего режима? Имеется ввиду не функция типа:SoundPlay(), а место в скрипте, где эту функцию притулить? Ибо мне приходит на ум, только сделать проверку в цикле на сравнение, если счас на 1 минуту больше чем время выхода из спящего режима, которое задано было в функции SetWakeUpTime(), то SoundPlay()?
Запустил скрипт, только время поставил свое. Решил попробовать спящий режим потому что из ждущего он не выходит сам.
Комп ушел в спящий режим и в назначенное время запустился, но вместо загрузки он выдал BSOD.
О чем говорилось на экране я непонял, все на англ конечно. Сделал скрины мобилкой, и для удобочитаемости сделал скрины черно-белыми.
Это у меня с ноутом ерунда какая-то, или у вас тоже так?
Ниже сами скрины и код скрипта который пробовал.
http://i080.radikal.ru/0911/84/837d47053729t.jpg (http://i080.radikal.ru/0911/84/837d47053729.jpg)
http://i032.radikal.ru/0911/3b/defbbcb0568ct.jpg (http://i032.radikal.ru/0911/3b/defbbcb0568c.jpg)
потом еще
http://i055.radikal.ru/0911/f0/0d60facbe1b9t.jpg (http://i055.radikal.ru/0911/f0/0d60facbe1b9.jpg)
скрипт Sleep.au3
Вроде все нормально, или время ноль часов нужно с двумя нолями указывать? Я поставил один ноль...
#include <Date.au3>
While 1; цикл для проверки времени
If @HOUR = 23 AND @MIN = 55 Then; если время нужное, то...
$sFuture = _DateAdd('D', 1, _NowCalcDate()); вычислить завтрашнюю дату
$aFuture = StringSplit($sFuture, '/'); найти день/меся/год
SetWakeUpTime(0, 05, $aFuture[3], $aFuture[2], $aFuture[1]); задать время для выхода из спящего режима
SetSuspend() ;уйти в спящий режим
Else
Sleep(100)
EndIf
WEnd
;
kaster, спасибо. В управлении у меня отключены спящий и ждущий режимы. На вкладке спящего режима галка есть, разрешить использование спящего режима.
Lirriella
06-07-2011, 14:58
Во, как раз то, что я искала!
Может кому пригодится: использовала код по ссылке источник (http://www.autoitscript.com/forum/index.php?showtopic=21575) на семерке. "Просыпается" только после того, как в настройках электропитания (настройка перехода в спящий режим - изменить дополнительные параметры питания - сон) разрешила таймеры пробуждения.
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.
Available in ZeroNet 1osznRoVratMCN3bFoFpR2pSV5c9z6sTC