Sign in to follow this  
Followers 0
batfastad

hidden application timer - feasible with autoit?

13 posts in this topic

Hi

I need to create a program that times how long applications are in focus for over the course of a working day.

Just to see what apps people are using on their computers at work.

I'd need to poll the current window every couple of seconds.

Basically I'd like to try and build up statistics on how various windows are active/focussed over the course of a day.

I'd then append the data to a text file every 30 mins or so.

Would having an autoit script running all day, constantly polling window titles, create any noticeable delays?

$t = 0

While $t = 0

$currentwindow = WinGetTitle("")
Sleep (2000)

WEnd

A basic loop above seems to work ok with no noticeable delays or overhead on other applications.

In the loop I'd have to be comparing the current window title to an array of previous window titles or something, and gradually incrementing the counter.

I just wondered if anyone could think of any reasons why autoit shouldn't be used for this?

Would it work effectively?

I've only every used AutoIt scripts in the past to perform batch operations and scripts. Not to perform a task all day, whilst a computer is being used for other tasks.

Are there any factors that could interrupt the operation of this script?

Thanks

Ben

Share this post


Link to post
Share on other sites



I've had a look around on the net for a week or so now to try and find something that can do this.

I found a program that times how long each application is open, but I want to find out how long each window is active/in focus.

Any ideas on whether this is a good idea in AutoIt?

Share this post


Link to post
Share on other sites

If you do that please share sounds like a great idea. Good for watching employees that are playing games too.

Share this post


Link to post
Share on other sites

look into the timer functions


[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Some some ideas to help get you started...

You might want to look at the functions WinGetProcess and ProcessList to help with time tracking since window titles can vary so much (especially with web browsers). You might store an array of Process NAMES and how many seconds each one has accumulated.....

FileWriteLine("TimeLog.txt", "<<<< Log STARTED " & @Hour & ":" & @Min & ":" & @Sec & " >>>>")
While 1
    $lastActiveWindow = WinGetTitle("")
    $init = TimerInit()
    WinWaitNotActive($lastActiveWindow)
    FileWriteLine("TimeLog.txt", Int(TimerDiff($init)/1000) & " seconds showing " & $lastActiveWindow)
WEnd

Func OnAutoItExit()
    FileWriteLine("TimeLog.txt", ">>>> Log stopped " & @Hour & ":" & @Min & ":" & @Sec & " <<<<")
EndFunc
Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Yeah that's a good idea.

Window titles can vary - web broswers and office documents.

But I could also check how long their spending in specific documents and whether it is work-related.

Then if I need stats about specific processes then I can just do a search for all 'microsoft word'

(Although what would happen if someone brings a Save As or Open box up in that document - according to the window spy it will just be Save As)

So what I'll do for each item in the array is store the process name, window title, and time.

I'll seriously think about doing this and I'll share any code I come up with.

I'll have an autoit script on the server gather all the files off admin shares (c$) into a folder, then I'll make some filemaker database routines to parse it in to a usable format.

I'll use filemaker as that's what I know :-)

Another thought...

Rather than polling every 2 seconds, is it possible to trigger it when the window changes?

Well it seems from the feedback so far that this should be fine to do in Autoit.

I will give it a good shot and if I get into any probs I'll come back to this thread.

And I'm on an old v3 of autoit so I better upgrade to get some of the newer functions.

AutoIt does rock!!!!

Thanks guys

Share this post


Link to post
Share on other sites

Yeah that's a good idea.

Window titles can vary - web broswers and office documents.

But I could also check how long their spending in specific documents and whether it is work-related.

and your employees are ok with this? are you telling them that you're spying on their activities? is it even legal?

i know it's a bit offtopic but i hope you've thought it through..

Share this post


Link to post
Share on other sites

Nope, not gonna tell them yet.

Want to try it for a couple of months, then tell them about the monitoring and try and see the difference.

How can monitoring the usage of our computer equipment and our internet connection be illegal?

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

How can monitoring the usage of our computer equipment and our internet connection be illegal?

<{POST_SNAPBACK}>

i don't think it's much different than listening to their phone calls.

install a keylogger while at it. and vnc in case you want to watch their screens when you see something interesting in your spy app.

did you forbid web surfing or playing games? if you did, why do they have the option to do so at the first place? why not disable web surfing and running games?

ps. they're also using your toilet equipment.

Edited by torsti

Share this post


Link to post
Share on other sites

Ok I've got something working thanks to CyberSlug :) !!

The only problem with the example above OnAutoItExit() doesn't work if you shut the machine down, without exiting the script.

This is a shame because the OnAutoItExit function could be really useful as I could copy the file to a central network share.

Is there any way around this?

In fact the only way I've found to get the OnAutoItExit() to trigger is if you have the trayicon displayed, and you right click and go to exit. And having the tray icon showing kinda defeats the point of this being a stealthy monitoring app.

That function doesn't get executed if you terminate the autoit process through taskman either.

Any ideas on this first one?

Secondly, in order for it to start when the machine logs in it needs to be in the start menu startup group.

Also having it in the startup group means it can just be deleted from there to stop it from starting in the future.

The only other way I can think of to have it running on startup is to register the script as a system service somehow. I'm not sure if this is even possible.

Any ideas guys?

If I can get that to work then I'll try running it all day on my machine next week.

Thanks

Ben

Share this post


Link to post
Share on other sites

Hi

Just to let you guys know I'm abandoning this project for the time being.

Once a user locks their machine, the script is paused and doesn't seem to resume properly once the machine in unlocked.

I'll be keeping an eye out for a freeware utility out there that will let me do this as I don't think AutoIt can do what I want.

I'll have to try and remember whatever I can from my delphi days I think.

Thanks for your help anyway guys!

Ben

Share this post


Link to post
Share on other sites

Once a user locks their machine, the script is paused and doesn't seem to resume properly once the machine in unlocked.

<{POST_SNAPBACK}>

Hey I don't think this should be a problem. I have a program I use that is always running in a while loop like yours (it is a hotkey program I wrote for launching webpage etc). I have a shortcut to it in my Startup folder, and it always comes back on when I log on (it should not exit when you lock the computer, only when you log off). I think if you write to your backup file fairly often, you should be able to do what you want without much trouble. Of course, if you add a startup task, you should name it something other than "the program I use to spy on employees" :)

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