Sign in to follow this  
Followers 0
Zamp

Is there a way for autoit to tell if you're on the computer?

6 posts in this topic

Tomorrow I'm going to be away from my computer for a while, so I want autoit to do some stuff for me in a browser game, but I don't remember things well, so I want it to do the stuff for me today also.

Basically, I want it to check if I'm on the computer somehow, if I am, have it ask me if I want it to do the stuff and wait until I click OK or something, then do it, and if I'm not on the computer, just have it do it right away.

So if someone could understand that, is it possible to tell if I'm using the computer or not?

Share this post


Link to post
Share on other sites



You could add a timout to a message box. Once the timmer rexpires it assumes your not there.

Share this post


Link to post
Share on other sites

That sounds like a good idea, but sometimes I will be doing other stuff on my computer which might last longer than the timeout. But if there is no other way, I guess I'll just do a timeout thing. How would you do that though? Have it pop up a message box, if you don't do anything to it within, lets say 10 seconds, it closes it and then does stuff, and if you click OK or something, it won't wait the 10 seconds and get started on it right away?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$a=MsgBox (0, "Are you there?", "Press OK in 10 seconds or I'll think you're not there",10)
if $a=1 then 
    MsgBox(0,"Ok","Just Making Sure")
    Exit
EndIf
if $a=-1 then
    MsgBox(0,"OK","You're not here! time do to things")
    ;do things
EndIf

Edited by evilertoaster

Share this post


Link to post
Share on other sites

Ah alright thanks!

Share this post


Link to post
Share on other sites

Here is function that checks if user is do somthing :) :

HotKeySet("{esc}", "Quit")

$NotifyTime = 5 ;5 seconds
$TimerInitStart = TimerInit()

While 1
    $Idle = _IdleWaitCommit(0, $NotifyTime)
    If $Idle = -1 Then
        Do_Stuff_Func()
    ElseIf TimerDiff($TimerInitStart) >= ($NotifyTime*1000) Then
        $Ask = MsgBox(36, "Question", "Would you like to do stuff?")
        If $Ask = 6 Then Do_Stuff_Func()
        $TimerInitStart = TimerInit()
    EndIf
WEnd

Func Do_Stuff_Func()
    ConsoleWrite("! i am doing stuff ;)" & @LF)
EndFunc

Func Quit()
    Exit
EndFunc

Func _IdleWaitCommit($idlesec, $TimerToDoStuff=60) ;$TimerToDoStuff=60 is 60 seconds to wait before notify
    Local $iSave, $LastInputInfo = DllStructCreate ("uint;dword")
    DllStructSetData ($LastInputInfo, 1, DllStructGetSize ($LastInputInfo))
    DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))
    Local $TimerInit = TimerInit()
    Do
        $iSave = DllStructGetData ($LastInputInfo, 2)
        Sleep(100)
        DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))
    Until (DllStructGetData ($LastInputInfo, 2)-$iSave) > $idlesec Or TimerDiff($TimerInit) >= ($TimerToDoStuff*1000)
    If TimerDiff($TimerInit) >= ($TimerToDoStuff*1000) Then Return -1
    Return DllStructGetData ($LastInputInfo, 2)-$iSave
EndFunc

You can set $NotifyTime, in that time will appear msgbox if you work with the computer, if you don't, then after this time will called function Do_Stuff_Func() :)


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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