← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #497368]: Conditional no-user-activity trigger

 

Question #497368 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/497368

    Status: Open => Answered

RaiMan proposed the following answer:
Since everything with SikuliX is visual, it depends, how you are able to
visually track activity/inactivity.

Another option might be, to continually track the mouse position and do
your job, if the mouse is no longer moved for some time.

lastPos = Mouse.at()
lastMove = time.time()
maxWait = 15 #seconds
saved = False
while True:
    wait(1)
    currentPos = Mouse.at()
    if lastPos.x == currentPos.x and  lastPos.y == currentPos.y:
        if lastMove + maxWait < time.time and not saved:
            #here you should do your actions
            saved = True
    else:
        lastMove = time.time()
        lastPos = currentPos

... you might add something, to make this endless loop interruptible -
otherwise you have to kill it.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.