Sign in to follow this  
Followers 0
mark309

Double variabele

5 posts in this topic

Hello,

Trying to make an autoit script that starts applications and benchmarks them, there is only one thing i am stuck on (maybe because its monday :))

I am trying to make a function that times how long an application is running: for instance msword

$appname=msword
Start_timer($appname)

Func start_timer()
$msword=timerinit() <-- here is the problem
EndFunc

As you see, I would like the timer to start the count in $msword but I really cant figure out how to make it variable

Hope one of you knows a good trick!

Thanks, Mark

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Maybe this helps

$count = 1
While 1
;~  sleep(1000)
    If $appname = Running Then  $count =+ 1 for example adds +1 each second the proces is running
    MsgBox(0,'',$count)
WEnd
Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Using mark's original idea is the best way to go, as it's accurate to the ms.

$appname=”msword”
Start_timer($appname)

Func start_timer()
$msword=timerinit() <-- here is the problem
EndFunc

You almost had it right there. (but if you're gonna run and test several programs you might want to have a look at arrays):

#include <Array.au3>
Dim $AppArray[3][3]; Contains 3 programs, 3 elements about each: its Path on the harddrive, its timer, and its process id(as returned when started)

; Programs: (change these to whatever apps you wanna test)
$AppArray[0][0] = @WindowsDir & "\Notepad.exe"; Program #1
$AppArray[1][0] = @WindowsDir & "\Notepad.exe"; Program #2
$AppArray[2][0] = @WindowsDir & "\Notepad.exe"; Program #3

Dim $ProgramCount = 0

For $i = 0 To UBound($AppArray)-1
    _StartTimer($AppArray[$i][0], $AppArray[$i][1], $AppArray[$i][2])
Next

While $ProgramCount
    
    For $i = 0 To UBound($AppArray)-1
        If Not ProcessExists($AppArray[$i][2]) And $AppArray[$i][2] <> 0 Then
            $AppArray[$i][2] = 0
            $AppArray[$i][1] = Round(TimerDiff($AppArray[$i][1])/1000, 3); Returns result in milliseconds with 3 decimals
            $ProgramCount -= 1
;~          MsgBox(0, StringTrimRight($AppArray[$i][0], StringInStr($AppArray[$i][0], "\", 0, -1)) & " closed", "Time Run: " & $AppArray[$i][1] & " ms")
        EndIf
    Next
    
WEnd

_ArrayDisplay($AppArray); Displays our result

Func _StartTimer($s_AppPath, ByRef $i_AppTimer, ByRef $i_AppPID)
    
    $i_AppPID = Run($s_AppPath)
    $i_AppTimer = TimerInit()
    $ProgramCount += 1
    
EndFunc

I took the liberty, I hope you understand it, or perhaps might even learn something from it. ;)

Edit:

Whops, forgot to include the function. :)

Edited by FreeFry

Share this post


Link to post
Share on other sites

Using mark's original idea is the best way to go, as it's accurate to the ms.

Ill definently look into arrays!

The final result wil be someting like this:

timer start(total)
timer_start(msword)
word_start()
word_typeletter()
timer_stop(msword)
timer_stop(total)

So ill be busy for a while, thanks for youre help so far!

Share this post


Link to post
Share on other sites

Good Luck. :)

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