Ninijaludek Posted April 9, 2022 Posted April 9, 2022 (edited) expandcollapse popup#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): [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes.asp]http://msdn.microsoft.com/library/default....error_codes.asp[/url] ; ; 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=true,$force=true) $result = DllCall("PowrProf.dll", "long", "SetSuspendState", "long",$mode, "long",$force, "long", false) EndFunc SetWakeUpTime(@HOUR,@min+2); wakeup the system in 2 minutes from now SetSuspend(); go to hibernate mode The problem is that if you set it for 2 minutes, it's all kk, and if you set it as below, it goes to sleep, but I don't want to wake up, what am I doing wrong? SetWakeUpTime(@HOUR +3,@min+59); wakeup the system in 2 minutes from now My code SetWakeUpTime(@HOUR ,@min+20); wakeup the system in 2 minutes from now SetSuspend(); go to hibernate mode Edited April 9, 2022 by Melba23 Added explanative title and Code tags
Ninijaludek Posted April 9, 2022 Author Posted April 9, 2022 It started to work sorry With the problem after 20 minutes it started and at 3 hours 59 I have it right?
Moderators Melba23 Posted April 9, 2022 Moderators Posted April 9, 2022 (edited) Ninijaludek, Please use explanatory titles for your threads. And when you post code in future please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. Thanks in advance for your cooperation. And now I see that this is the same you code you posted in your previously locked thread. Best NOT post it a third time. M23 Edited April 9, 2022 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts