Jump to content

Detect if a PC is idle


PcExpert
 Share

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
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

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...