guinness Posted July 30, 2014 Posted July 30, 2014 (edited) This is a quick example I created in which it move the mouse after a certain period of time of being idle. I could have changed the system settings, but then this wasn't an option. expandcollapse popup#include <WinAPISys.au3> Global Const $IDLETIME_GUID = '5816AA22-EEB4-4C92-BB07-4A5E1DBA4A6A' Global Enum $IDLETIME_DELEGATE, $IDLETIME_ID, $IDLETIME_ISRUNNING, $IDLETIME_TIME, $IDLETIME_MAX Global $g_bIsRunning = True ; For the example only. This is set to false when ESC is pressed. HotKeySet('{ESC}', Close) Example() Func Example() Local $hIdle = _IdleTime(10000, WakeUp) ; Create an idle time object and set the time to move the mouse every 10 seconds and call the parameterless function WakeUp(). ConsoleWrite('IsRunning: ' & _IdleTime_IsRunning($hIdle) & @CRLF) ; Display running status. ConsoleWrite('Time: ' & _IdleTime_GetTime($hIdle) & @CRLF) _IdleTime_StopStartPause($hIdle) ; Start the idle time monitoring. ConsoleWrite('IsRunning: ' & _IdleTime_IsRunning($hIdle) & @CRLF) ; Display running status. While Sleep(250) And $g_bIsRunning WEnd If _IdleTime_IsRunning($hIdle) Then _IdleTime_StopStartPause($hIdle) ; Stop if the idle time is currently running. EndIf ConsoleWrite('IsRunning: ' & _IdleTime_IsRunning($hIdle) & @CRLF) Return True EndFunc ;==>Example Func Close() $g_bIsRunning = False EndFunc ;==>Close Func WakeUp() MsgBox($MB_SYSTEMMODAL, '', 'Please wake up!') EndFunc ;==>WakeUp #Region IdleTime UDF Func _IdleTime($iTime = Default, $hFunc = Default) Local $aIdleTime[$IDLETIME_MAX] $aIdleTime[$IDLETIME_ID] = $IDLETIME_GUID $aIdleTime[$IDLETIME_ISRUNNING] = False __IdleTime_Delegate($aIdleTime, $hFunc) ; Set the delegate function. This should have no parameters. __IdleTime_Time($aIdleTime, $iTime) ; Set the time. Return $aIdleTime EndFunc ;==>_IdleTime Func _IdleTime_GetDelegate(ByRef $aIdleTime) Return (__IdleTime_IsAPI($aIdleTime) ? $aIdleTime[$IDLETIME_DELEGATE] : Null) EndFunc ;==>_IdleTime_GetDelegate Func _IdleTime_GetTime(ByRef $aIdleTime) Return (__IdleTime_IsAPI($aIdleTime) ? $aIdleTime[$IDLETIME_TIME] : Null) EndFunc ;==>_IdleTime_GetTime Func _IdleTime_IsRunning(ByRef $aIdleTime) Return (__IdleTime_IsAPI($aIdleTime) ? $aIdleTime[$IDLETIME_ISRUNNING] : False) EndFunc ;==>_IdleTime_IsRunning Func _IdleTime_SetDelegate(ByRef $aIdleTime, $hFunc) Local $bReturn = False If __IdleTime_IsAPI($aIdleTime) And __IdleTime_Time($aIdleTime, $hFunc) Then ; Set the delegate. $bReturn = True If _IdleTime_IsRunning($aIdleTime) Then _IdleTime_StopStartPause($aIdleTime) ; Stop. _IdleTime_StopStartPause($aIdleTime) ; Start. EndIf EndIf Return $bReturn EndFunc ;==>_IdleTime_SetDelegate Func _IdleTime_SetTime(ByRef $aIdleTime, $iTime) Local $bReturn = False If __IdleTime_IsAPI($aIdleTime) And __IdleTime_Time($aIdleTime, $iTime) Then ; Set the time. $bReturn = True If _IdleTime_IsRunning($aIdleTime) Then _IdleTime_StopStartPause($aIdleTime) ; Stop. _IdleTime_StopStartPause($aIdleTime) ; Start. EndIf EndIf Return $bReturn EndFunc ;==>_IdleTime_SetTime Func _IdleTime_StopStartPause(ByRef $aIdleTime) Local $bReturn = False If __IdleTime_IsAPI($aIdleTime) Then $bReturn = True If $aIdleTime[$IDLETIME_ISRUNNING] Then __IdleTime_Proc(0, 0) ; Set the static variablse in the procedure to the default of zero, thus clearing the previous values. AdlibUnRegister(__IdleTime_AdLibRegister) Else __IdleTime_Proc($aIdleTime[$IDLETIME_DELEGATE], $aIdleTime[$IDLETIME_TIME]) ; Set the static variables in the procedure to the required time when to move the mouse and delegate to call. AdlibRegister(__IdleTime_AdLibRegister, Ceiling($aIdleTime[$IDLETIME_TIME] / 3)) ; Register the function to be called time / 3. EndIf $aIdleTime[$IDLETIME_ISRUNNING] = Not $aIdleTime[$IDLETIME_ISRUNNING] EndIf Return $bReturn EndFunc ;==>_IdleTime_StopStartPause Func __IdleTime_IsAPI(ByRef $aIdleTime) Return UBound($aIdleTime) = $IDLETIME_MAX And $aIdleTime[$IDLETIME_ID] = $IDLETIME_GUID EndFunc ;==>__IdleTime_IsAPI Func __IdleTime_AdLibRegister() ; Wrapper for __IdleTime_Proc(), since AdLibRegister() doesn't accept functions with parameters. Return __IdleTime_Proc() EndFunc ;==>__IdleTime_AdLibRegister Func __IdleTime_Delegate(ByRef $aIdleTime, $hFunc) If Not IsFunc($hFunc) Then $hFunc = 0 $aIdleTime[$IDLETIME_DELEGATE] = $hFunc Return True EndFunc ;==>__IdleTime_Delegate Func __IdleTime_Proc($hSetFunc = Default, $iSetTime = Default) Local Static $hFunc = 0, _ $iTime = 0 If $hSetFunc = Default And $iSetTime = Default And $iTime > 0 Then If _WinAPI_GetIdleTime() >= $iTime Then Local $aPos = MouseGetPos() If Not @error Then Local Enum $POS_X, $POS_Y MouseMove($aPos[$POS_X] + 1, $aPos[$POS_Y]) MouseMove($aPos[$POS_X], $aPos[$POS_Y]) If IsFunc($hFunc) Then ; Call a function if it's set. $hFunc() EndIf EndIf EndIf Else If Not ($hSetFunc = Default) Then $hFunc = $hSetFunc If Not ($iSetTime = Default) Then $iTime = $iSetTime EndIf Return True EndFunc ;==>__IdleTime_Proc Func __IdleTime_Time(ByRef $aIdleTime, $iTime) If $iTime = Default Or $iTime < 750 Then $iTime = 750 ; 750 ms by default, since the procedure is checked 750 / 3 = 250 (which is the minimum for AdLibRegister()). $aIdleTime[$IDLETIME_TIME] = $iTime Return True EndFunc ;==>__IdleTime_Time #EndRegion IdleTime UDF Edited July 30, 2014 by guinness IgImAx 1 UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
careca Posted July 30, 2014 Posted July 30, 2014 Seen once a script in vbs for the same purpose, but all it did was on/off scroll lock every minute, worked good to prevent automatic lock. Good job, i wonder if it could be a simpler thing, maybe like this: #include <Timers.au3> HotKeySet('{ESC}','Quit') While 1 Sleep(1000) $iIdleTime = _Timer_GetIdleTime() $iIdleTime = $iIdleTime / 1000 If $iIdleTime >= 60 Then ConsoleWrite('$iIdleTime >= 60 '& @SEC &@CRLF) Send('{SCROLLLOCK toggle}') Sleep(500) Send('{SCROLLLOCK toggle}') EndIf WEnd Func Quit() Exit EndFunc What do you think? Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
guinness Posted July 30, 2014 Author Posted July 30, 2014 (edited) Great, but the point was to demonstrate how to create a UDF which is easy to maintain and expand. I could write the same functionality in 3 lines if I wanted to. Plus Send() has its drawbacks.Edit: Also with your example it's only limited to your example and the user has to strip out the functionality, which as we know is not always easy for users who have a limited understanding (of AutoIt) to do. Edited July 30, 2014 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Gianni Posted July 30, 2014 Posted July 30, 2014 (edited) Seen once a script in vbs for the same purpose, but all it did was on/off scroll lock every minute, worked good to prevent automatic lock. ...... What do you think? another drawback on using "SCROLLLOCK" for example is that if you are using "Attachmate's Reflection for the web" 3270 emulator, the "SCROLLLOCK" key in that emulator is used to clear the entire screen...... so, hitting that key is not much polite , expecially if someone has just finished to fill all the fields on the emulator's screen..... Edited July 30, 2014 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
czardas Posted July 30, 2014 Posted July 30, 2014 You could make a lonely computer which gives you a nudge - c'mon hurry up and type something. Maybe you should add that to the UDF. Actually it's quite useful. operator64 ArrayWorkshop
guinness Posted July 30, 2014 Author Posted July 30, 2014 Maybe add some callback function. I will add this later on. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
careca Posted July 30, 2014 Posted July 30, 2014 another drawback on using "SCROLLLOCK" for example is that if you are using "Attachmate's Reflection for the web" 3270 emulator, the "SCROLLLOCK" key in that emulator is used to clear the entire screen...... so, hitting that key is not much polite , expecially if someone has just finished to fill all the fields on the emulator's screen..... Well, the key can be changed to whatever.. so i don't see any issue, i chose it because it seems to be the key, that interferes less with applications, tough luck you found one so fast. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
guinness Posted July 30, 2014 Author Posted July 30, 2014 (edited) You could make a lonely computer which gives you a nudge - c'mon hurry up and type something. Maybe you should add that to the UDF. Actually it's quite useful. Done. See first post for an update. Well, the key can be changed to whatever.. so i don't see any issue, i chose it because it seems to be the key, that interferes less with applications, tough luck you found one so fast. It wasn't so much about the key you chose, I just feel you misunderstood the purpose of the example. I have zero issue people making suggestions, so long as they adhere to the same concept as the original post. Edited July 30, 2014 by guinness czardas 1 UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Exit Posted July 30, 2014 Posted July 30, 2014 I use another approach to disable screensavers and power events, like hibernate and standby. expandcollapse popup;~ PowerKeepAlive() function. ;~ Script to prevent screensaver, sleepstate, hibernate and powersaving mode. ;~ The script is adapted from another who's origin I don't know. ;~ Modified by Exit #NoTrayIcon Exit _PowerKeepAlive() Func _PowerKeepAlive() If WinExists("SA_0bc53fe0-59c2-11e2-bcfd-0800200c9a66_SA") Then Exit MsgBox(64 + 262144, Default, @ScriptName & " already running.", 99) AutoItWinSetTitle("SA_0bc53fe0-59c2-11e2-bcfd-0800200c9a66_SA") Opt("TrayOnEventMode", 0) Opt("TrayMenuMode", 1 + 2) TraySetClick(8 + 1) Local $iTrayExit = TrayCreateItem("Exit and reset timers and power-savings mode") ; Disable screensaver, power-save, etc __PowerKeepAlive() OnAutoItExitRegister("_PowerResetState") TraySetState() While TrayGetMsg() <> $iTrayExit WEnd EndFunc ;==>_PowerKeepAlive Func __PowerKeepAlive() ;~ ES_SYSTEM_REQUIRED(0x01) - > Resets system Idle timer ;~ ES_DISPLAY_REQUIRED(0x02) - > Resets display Idle timer ;~ ES_CONTINUOUS(0x80000000) - > Forces 'continuous mode' - > the above 2 will Not need To continuously be reset Local $aRet = DllCall('kernel32.dll', 'long', 'SetThreadExecutionState', 'long', 0x80000003) If @error Then Return SetError(2, @error, 0x80000000) Return $aRet[0] ; Previous state (typically 0x80000000 [-2147483648]) EndFunc ;==>__PowerKeepAlive Func _PowerResetState() ;~ ES_CONTINUOUS(0x80000000) - > (Default) - > used alone, it resets timers & allows regular sleep / power - savings mode Local $aRet = DllCall('kernel32.dll', 'long', 'SetThreadExecutionState', 'long', 0x80000000) If @error Then Return SetError(2, @error, 0x80000000) Return $aRet[0] ; Previous state EndFunc ;==>_PowerResetState App: Au3toCmd UDF: _SingleScript()
guinness Posted July 30, 2014 Author Posted July 30, 2014 Thanks. Should have checked the help file. _WinAPI_SetThreadExecutionState() UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now