KurogamineNox Posted October 12, 2010 Share Posted October 12, 2010 Just like the title says(and I really have no clue if this can be done) Is there a way to activate certain functions when no input from mouse or keyboard is found after like say 5min. Like on instant messengers when no input has been detected it switches there status to afk(away from keyboard). Can AutoIt do something like this? If not then thanks for telling me. Link to comment Share on other sites More sharing options...
Affe Posted October 12, 2010 Share Posted October 12, 2010 (edited) You could use a timer and _IsPressed to find out when a user is not entering data and away from the computer. You'll need to check for every form of input, however. Here's something I threw together in 2 minutes: While 1 TimerFunction Sleep(100) WEnd Func TimerFunction() If IsPressedFunction() = False Then ;start timer $timer = TimerInit() Do ;check for user input, if so then return If IsPressedFunction() Then Return Sleep(100) Until TimerDiff($timer) > 300000 ;5 minutes time AFK_Function() EndIf EndFunc Func IsPressedFunction() ;I am not going to write this, it will require lots of if's, else's, switches, etc. ;Look up _IsPressed() in the help file ;return True if a button is pressed ;return False if no button is pressed EndFunc Func AFK_Function() ;what you want to do after 5 minutes here EndFunc Edited October 12, 2010 by Affe [center][/center] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 12, 2010 Moderators Share Posted October 12, 2010 KurogamineNox,Dog eaten the Help file? Try _Timer_GetIdleTime. M23 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 Link to comment Share on other sites More sharing options...
Affe Posted October 12, 2010 Share Posted October 12, 2010 _Timer_GetIdleTimeOoh, new trick, thanks Makes me wonder how many things I've created a workaround for that a simple command already exists oO.Thanks again Melba! [center][/center] Link to comment Share on other sites More sharing options...
KurogamineNox Posted October 12, 2010 Author Share Posted October 12, 2010 Ill check it out. Thanks. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 12, 2010 Moderators Share Posted October 12, 2010 Affe,My pleasure. That Help file is just too big sometimes - as GeoSoft proved to me only yesterday by pointing out something I had never noticed! M23 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 Link to comment Share on other sites More sharing options...
KurogamineNox Posted October 12, 2010 Author Share Posted October 12, 2010 Hey I was checking the help file, How could I edit it to have it work the same way but after 5 seconds(Without the sleep and with a while function) original #AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <Timers.au3> ; Mouse/Keyboard action during this 10 sec delay will change reported idle time Sleep(10 * 1000); 10sec Global $iIdleTime = _Timer_GetIdleTime() MsgBox(64, "_Timer_GetIdleTime", "Idle time = " & $iIdleTime & "ms") What I was thinking and need help on #AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <Timers.au3> ; Mouse/Keyboard action during this 10 sec delay will change reported idle time Global $iIdleTime = _Timer_GetIdleTime() While 1 If $iIdleTime = 5000 Then MsgBox(64, "_Timer_GetIdleTime", "Idle time = " & $iIdleTime & "ms") EndIf WEnd I clearly am doing something wrong. Any thoughts or at least a better understanding of it? Link to comment Share on other sites More sharing options...
Affe Posted October 12, 2010 Share Posted October 12, 2010 (edited) You need to set $iIdleTime to the current Idle Time each instance through the loop. So you can declare it, but you must still get a new value for the idle time. Global $iIdleTime While 1 Sleep(100) ;you really want some kind of sleep to prevent CPU overload $iIdleTime = _Timer_GetIdleTime() If $iIdleTime > 300000 Then ;you can either exit the loop, or call a function AFK_Function() EndIf Wend Also, time in AutoIt is in milliseconds. 1000 ms = 1 second 60 s = 1 minute 60 m = 1 hour So 5 minutes is: 1000 * 60 * 5 = 300000 milliseconds. Edited October 12, 2010 by Affe [center][/center] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 12, 2010 Moderators Share Posted October 12, 2010 KurogamineNox, Just keep testing like this: #include <Timers.au3> $iPermitted_IdleTime = 5000 ; 5 secs max While 1 If _Timer_GetIdleTime() > $iPermitted_IdleTime Then ExitLoop ; If you press a key or move the mouse BEFORE 5 secs elapse, the timer is automatically reset WEnd MsgBox(0, "Idle Too Long!", "Do Something Now!") M23 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 Link to comment Share on other sites More sharing options...
KurogamineNox Posted October 12, 2010 Author Share Posted October 12, 2010 Thank you for the feed back. This helps a lot. Thanks both of you. Link to comment Share on other sites More sharing options...
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