if any key is not pressed or mouse not moved

Get help with using AutoHotkey and its commands and hotkeys
genaro
Posts: 20
Joined: 09 Feb 2016, 20:07

if any key is not pressed or mouse not moved

14 Jan 2020, 23:46

Help me please. I want if any key is not pressed or mouse not moved for 5 seconds then script to save and close Notepad.
User avatar
telanx
Posts: 67
Joined: 10 Jan 2020, 14:31

Re: if any key is not pressed or mouse not moved

15 Jan 2020, 08:03

this, Title and time are a custom variable. :roll:

Code: Select all

SetTitleMatchMode 2

winTitle := "Notepad"
runTime := 5   ;mins
idleTime := 1   ;mins
startTime := A_TickCount

while A_TickCount-startTime < runTime*60*1000 {
    sleep 10000
    while WinExist(WinTitle) {
        if (A_TimeIdle > idleTime*60*1000) {
            ControlSend, , ^s, %WinTitle%
            sleep 2000
            WinClose %WinTitle%
            return
        }
    }
}

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], daywalker, Pepineros, swagfag, TAC109, Xeo786 and 183 guests