Jump to content

Recommended Posts

Posted

No, I have read the helpfile, it returns a 1demension array, I thought maybe it would work if I just used $Pos, but maybe not, and its in a loop? read the posts above, you cant just come into a thread and post because of the last post.

I have read every post in this thread and I even got the cookie, while you posted bugged code and you are complaining??

Seriously man, you cant read a 1-dimensional array like a variable because they aren't the same thing and you would know that if you read the help-file or had some common sense. And the op wanted the script to WAIT UNTIL THE COMP IS IDLE!!! How can you do that if you only check one time?? A loop or adlib would work but your code wouldn't do a squat.

Posted (edited)

At least I tried, all ive seen you do here is cry, post, and critize. Do some work before you yell at others.

There is a plethora of things wrong in that sentence. Nobody cried, except you, a lot of people post here (Get used to it), and its not critisicism. He's not yelling, like you were.

So your backing out? :D:);)

Edited by JustinReno
Posted

At least I tried, all ive seen you do here is cry, post, and critize. Do some work before you yell at others.

I will only say this one more time

I got the cookie, while you posted bugged code and you are complaining??

Posted

There is a plethora of things wrong in that sentence. Nobody cried, except you, a lot of people post here (Get used to it), and its not critisicism. He's not yelling, like you were.

So your backing out? :D:);)

I don't want to make a fool of myself, like you already have.

Posted (edited)

All of you guys need to get over it.

As for the original poster, this should do what you want.

AdLibEnable("_UpdateTimer", 100)

Global $nTimer = 0
Global $OldMousePosition = MouseGetPos()
GLobal $NewMousePosition


While(1)
    sleep(10)
WEnd

Func _UpdateTimer()
    $nTimer += 100 ;100 ms
    
    $NewMousePosition = MouseGetPos()
    if (($NewMousePosition[0] == $OldMousePosition[0]) and ($NewMousePosition[1] == $OldMousePosition[1])) Then
        ; The user is still idle (you might also want to check for key presses
    Else
        ; The user moved, we should start the timer over.
        $OldMousePosition = $NewMousePosition
        $nTimer = 0
    EndIf
    
    if ($nTimer >= 5000) Then ;Change the '5000' to the number in milliseconds you want to wait, with your user being idle.
        _OnTimerFinish()
        $nTimer = 0
    EndIf
EndFunc

Func _OnTimerFinish()
    MsgBox(0, "", "[b]idle hands are the devil's tools[/b]")
    AdLibDisable()
    Exit
EndFunc
Edited by chris95219
Posted

FileCopy(@DesktopDir & "\AutoIt\VaultWait.exe", @StartUpDir & "\VaultWait.exe")

Here you go nathan, hope it helps :)

Posted

Hi Nblufire12,

I know you had a lot of answers but... You also can try to detect if your computer is locked or not ?

The following function can do that. Of course, if your settings do not include the parameter which locks the workstation after a given delay forget it...

Func _IsLocked()
    $hDesktop = DllCall("User32.dll", "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP)
    $ret = DllCall("User32.dll", "int", "SwitchDesktop", "int", $hDesktop[0])
    DllCall("User32.dll", "int", "CloseDesktop", "int", $ret[0])

    If $ret[0] Then
        Return SetError(0, 0, 0)
    Else
        Return SetError(0, 0, 1)
    EndIf
EndFunc  ;==>_IsLocked

Here is a sample code which can be used to detect if the computer is still locked 20 mins after the lock time and if yes performs the required operation :

#Include <Date.au3>
$Delay=20; This is the delay value after the lock time

Func _IsLocked()
    $hDesktop = DllCall("User32.dll", "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP)
    $ret = DllCall("User32.dll", "int", "SwitchDesktop", "int", $hDesktop[0])
    DllCall("User32.dll", "int", "CloseDesktop", "int", $ret[0])

    If $ret[0] Then
        Return SetError(0, 0, 0)
    Else
        Return SetError(0, 0, 1)
    EndIf
EndFunc  ;==>_IsLocked

While 1
    Sleep (250); If the computer is not powerful increase the sleep value (500, 1000)
    If _IsLocked() Then; The computer is locked
        $TimeBase=_NowCalc(); Set the reference base time
        Do; Will loop until the computer is unlocked
            $NewTime=_NowCalc(); Get the actual time
            $ElapsedTime= _DateDiff ( "n", $TimeBase,$NewTime); Calculates the difference between now and the initial Time in minutes
            If $ElapsedTime >= $Delay Then; Delay value has been achieved
            ; Put here the full path to the target program to run
                $TimeBase=""
                $NewTime=""
                $ElapsedTime=""
                ExitLoop; Exit and return to the main loop and wait another $delay value
            EndIf
        Until Not _IsLocked()
    Else 
        ContinueLoop; Computer is not locked so nothing to do except loop again
    EndIf
WEnd

Here you are now... I hope this will help you.

Enjoy,

FreeRider

FreeRiderHonour & Fidelity

Posted

$hDesktop = DllCall("User32.dll", "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP)
Hi Christophe,

what am I supposed to set as value to variable $DESKTOP_SWITCHDESKTOP while calling User32.dll in function _IsLocked()?

Posted (edited)

Hi Christophe,

what am I supposed to set as value to variable $DESKTOP_SWITCHDESKTOP while calling User32.dll in function _IsLocked()?

Global Const $DESKTOP_SWITCHDESKTOP = 0x100

This constant is not in the AutoIt includes

API's not in the Standard or UDF AutoIt code

may not have all constants they use declared.

free tools for constants

APIGuide http://allapi.mentalis.org

and

Gary Frost's APIConstants For AutoIt

http://www.autoitscript.com/forum/index.ph...amp;showfile=16

Edit: added url's

Edited by rover

I see fascists...

Posted

added url's

Hi Rover,

thanks a lot for those links and quick response - I found what I need and it works. :)

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
  • Recently Browsing   0 members

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