Sign in to follow this  
Followers 0
PcExpert

Detect if a PC is idle

6 posts in this topic

Hi all,

How to detect if PC is idle, so the user is away from the computer and then shut it down after 45 minutes?

Thanks!

Share this post


Link to post
Share on other sites



Hi,

how do you do it manually? What is your criteria?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You can check mouse move. If mouse not move 45 minute then close pc.

$Idle = 0
$Old = MouseGetPos()

While 1
    $Get = MouseGetPos()
    If $Get[0] = $Old[0] And $Get[1] = $Old[1] Then
        $Idle += 1
    Else
        $Idle = 0
    EndIf
    If $Idle <> 0 Then
        TrayTip("", "Idle time : " & $Idle & " second.", 1, 16)
    Else
        TrayTip("", "", 0)
    EndIf
    $Old = MouseGetPos()
    Sleep(1000)
WEndoÝ÷ Ù:ÚÉ8©~ì!£¬Âäx-«lr¸©µ.çi×eG­«m)àjëh×6$Minute = 45
If $Idle >= (60 * $Minute) Then Shutdown(1)
Edited by Jex

Share this post


Link to post
Share on other sites

@All

Maybe this can help

Func _CheckIdle(ByRef $last_active, $start = 0)
    $struct = DllStructCreate("uint;dword");
    DllStructSetData($struct, 1, DllStructGetSize($struct));
    If $start Then
        DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($struct))
        $last_active = DllStructGetData($struct, 2)
        Return $last_active
    Else
        DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($struct))
        If $last_active <> DllStructGetData($struct, 2) Then
            Local $save = $last_active
            $last_active = DllStructGetData($struct, 2)
            Return $last_active - $save
        EndIf
    EndIf
EndFunc   ;==>_CheckIdle

regards

ptrex

Share this post


Link to post
Share on other sites

Just as in this topic:

http://www.autoitscript.com/forum/index.ph...;hl=screensaver

I would create a screensaver in AutoIt that just had a command to shutdown.

http://www.autoitscript.com/forum/index.ph...;hl=screensaver

Actually I think if you rename your compiled script to *.scr it will run if you choose it in your screensaver list.

Share this post


Link to post
Share on other sites

Interesting. It would be fun to take my father's screensaver (Windows Logo that moves around) and after a while just make some crazy shit happen to it...

He'd probably not even notice, though.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0