Jump to content

Need a simple script


loopylow
 Share

Recommended Posts

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode 
$i = 1
$m = 0
$mainwindow = GUICreate("Mouse Jiggler 1.0", 250, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel ("Jiggle every", 10, 10, 80, 20)
$input = GUICtrlCreateInput("1", 70, 10, 50, 20, $ES_READONLY)
$updown = GUICtrlCreateUpdown($input)
GUICtrlSetLimit(-1, 15, 1)
GUICtrlCreateLabel ("minutes", 130, 10, 50, 20)
$jiggle =   GUICtrlCreateButton ( "jiggle it!", 10, 40 , 150 , 30) 
GUICtrlSetOnEvent($jiggle, "OKButton")
GUISetState(@SW_SHOW)

While 1
    if GUICtrlRead ($jiggle) = "cancel or wait" Then
        MouseMove ( $m[0]+50, $m[1]+50 , 50 )
        MouseMove ( $m[0], $m[1] , 50 )
        For $i = $i to 1 Step -1
            GUICtrlSetData ($jiggle, "cancel or wait " & $i & " seconds")
            sleep(900)
        next
        if $i >= 0 then GUICtrlSetData ($jiggle, "cancel or wait")
        $m = MouseGetPos ( )
        $i = GUICtrlRead ($input) * 60
    endif
    Sleep(100)  ; Idle around
WEnd

Func OKButton()
    if GUICtrlRead ($jiggle) = "jiggle it!" Then
        $m = MouseGetPos ( )
        $i = GUICtrlRead ($input) * 60
        GUICtrlSetData ($jiggle, "cancel or wait")
    Else
        $i = -1
        GUICtrlSetData ($jiggle, "jiggle it!")
    endif
EndFunc

Func CLOSEClicked()
    Exit
EndFunc

Link to comment
Share on other sites

The _Timer_GetIdleTime() function will return how long the computer has been idle. We can wait until it exceeds a certain point and then get it to do something that will reset the timer (in this case I send a simple shift key press, harmless enough)

Here's a version that will check every 2 seconds, and print the current idle time in the output pane. After 30 seconds it will send Shift:

#Include <Timers.au3>

While 1

If _Timer_GetIdleTime() > 30000 Then
;   Mousemove(300,300,5)
;   Mousemove(500,500,5)
Send("{lshift}")
EndIf
ConsoleWrite(_Timer_GetIdleTime()&@CR)
sleep(2000)
WEnd

This will do it after 5 minutes, checking every minute, with no output:

#Include <Timers.au3>

While 1
    If _Timer_GetIdleTime() > 300000 Then
        Send("{lshift}")
    EndIf
    sleep(60000)
WEnd
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...