Jump to content
Sign in to follow this  
Erik.

Timer for program

Recommended Posts

Erik.

Hello,

Is there a way so you can see how many times a program has started every day and how long it is running?

The program runs at the background and when you start a program you want to log autoit sees it and is counting howmany times it was started and how long.

Save it to a log file everyday updated

i do not know how to start and how can i count ow many times a process is started and how long it is running?

Edited by Erik.

I little problem, hard to find and fix

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

try to save the information in an ini file. Every time you start, you read the value from the ini and add one then write it back.

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

Share this post


Link to post
Share on other sites
Erik.

Thanks, i will take a look.

to record it to a ini file is not so different but i do not know how to record it so you can see how many times it is runing and how long..

Somone an example script?


I little problem, hard to find and fix

Share this post


Link to post
Share on other sites
erebus

Add this on top of your script:

$timesrun = IniRead("settings.ini", "MyProg", "TimesRun", "0")
$timesrun = $timesrun + 1
IniWrite("settings.ini", "MyProg", "TimesRun", $timesrun)
Edited by erebus

Share this post


Link to post
Share on other sites
Erik.

Whit that you can se ehow many times the script has been running?

I need to know how many time the program is running like, msn.exe


I little problem, hard to find and fix

Share this post


Link to post
Share on other sites
erebus

Use $timesrun -- it will always has the exact number the program has been executed.

Share this post


Link to post
Share on other sites
Dale2507

if you still want this, use TimerInit () and TimerDiff ( timestamp ) then start the timer when the process starts and get the TimerDiff when the process closes

Share this post


Link to post
Share on other sites
Erik.

Oh lol thanks...

I am now busy whit another program i will take a look


I little problem, hard to find and fix

Share this post


Link to post
Share on other sites
Kip

$Writed = 0
 $file = FileOpen("Runned.txt", 1)
 
 While 1
     If ProcessExists("msnmsgr.exe") Then
         If $Writed = 0 Then
             FileWrite($file, @CRLF & @MON & "." & @MDAY & " | " & @HOUR & "." & @MIN & "." & @SEC & "   MSN Started")
             FileClose($file)
             $file = FileOpen("Runned.txt", 1); close and then open? Yes!
             $Writed = 1
         EndIf
     Else
         If $Writed = 1 Then
             FileWrite($file, @CRLF & @MON & "." & @MDAY & " | " & @HOUR & "." & @MIN & "." & @SEC & "   MSN Ended")
             FileClose($file)
             $file = FileOpen("Runned.txt", 1)
             $Writed = 0
         EndIf
     EndIf
 WEnd
 
 FileClose($file)

Edited by kip

Share this post


Link to post
Share on other sites
Dale2507

$Writed = 0
   $file = FileOpen("Runned.txt", 1)
   
   While 1
       If ProcessExists("msnmsgr.exe") Then
           If $Writed = 0 Then
               FileWrite($file, @CRLF & @MON & "." & @MDAY & " | " & @HOUR & "." & @MIN & "." & @SEC & "     MSN Started")
               FileClose($file)
               $file = FileOpen("Runned.txt", 1); close and then open? Yes!
               $Writed = 1
           EndIf
       Else
           If $Writed = 1 Then
               FileWrite($file, @CRLF & @MON & "." & @MDAY & " | " & @HOUR & "." & @MIN & "." & @SEC & "     MSN Ended")
               FileClose($file)
               $file = FileOpen("Runned.txt", 1)
               $Writed = 0
           EndIf
       EndIf
   WEnd
   
   FileClose($file)

What's this code for?

If you want timer for how long a program runs for it would be something like:

CODE

$program = ""

If ProcessExists ($program) Then

$programtimer = TimerInit ()

Do

$programexists = ProcessExists ($program)

Until $programexists = 0

$Programtime = TimerDiff ($programtimer)

$hours = Int ($programtimer/3600000)

$minutes = Int(($programtimer-($hours*3600000))/60000)

$seconds = Int(($programtimer-($hours*3600000)-($minutes*60000))/1000)

EndIf

You will have to check the maths for the hours, minutes and seconds and you may want to include

CODE

$msg = GUIGetMsg ()

or

CODE

$msg = TrayGetMsg ()

then change

CODE

Until $programexists = 0

to

CODE

Until $programexists = 0 Or $msg = $close

or something similar to prevent an everlasting loop Edited by Gmail

Share this post


Link to post
Share on other sites
Valuater

add two lines to the top and 4 lines to the bottom of any program

#include <file.au3>
_FileWriteLog("Run-Log.txt", "StY   ][ÝÊBÈ[ÝØÜB[ÈÛ]]Ú]^]

BÑ[UÜ]SÙÊ   V÷Cµ'VâÔÆörçGBgV÷C²ÂgV÷C´fæ6VBgV÷C²fײ5$Äb¢W@¤VæDgVæ0

8)


NEWHeader1.png

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  

×