|
#1
|
||||
|
||||
|
Is there a way to record how long the app have been running?
I know I can use the page.OnTimer to have it call the system time every minut or so but that calculation will be reset every time you leave or enter the page. I want to be able to display a timer in the project that tells people for how long they have been using the app. and I want the timer to pause when the app looses focus. I know all these things are posible seperatly but how to get them to work together..... anyone got any ideas? cheers, Jonas DK |
|
#2
|
||||
|
||||
|
Hi. Couple ways:
1. Check/compare the system time. 2. Use the timer and just add a "totalTime" variable assignment to it, so for example: Page.StartTimer(1000); Then in the timer area have something like this: totalSeconds = totalSeconds + 1; That variable's value is retained across different pages. Then you can easily translate that to minutes as needed, i.e. totalMinutes = totalSeconds/60; |
|
#3
|
||||
|
||||
|
of cause...
its so simple.... . o O (must be getting tired.. its 01:00 here) but what about pausing when loosing focus.. now that is tricky I tried some different things of what I could come up with but non of it works. |
|
#4
|
||||
|
||||
|
I'm not really adept at hooking windows, etc. because I rarely do that but it's definitely doable. I believe the gist of that would be to sandwich your variable incrementing inside of an IF statement which checks to see if your window has focus, so it's only incremented in that case.
To create the IF statement which checks to see if your window is focused, you'll need some help from one of the more advanced scripters like Brett or Worm. It's not super hard or anything but I think those are the guys with the ticket on that one. Search around the forum a bit, seems ot me I saw an example here once on checking for focus. |
|
#5
|
||||
|
||||
|
Quote:
Code:
strTimersec = strTimersec + 1;
if strTimesec >= "60" then
OnlineTime = strTimersec/60;
end
Paragraph.SetText("parTimer", "Du har i dag været online: "..OnlineTime.." Minuter");
problem is that if I let it update every secound it wont write out the entire paragraph and the text will be flashing... |
|
#6
|
||||
|
||||
|
forget my last post..
What if I only want it to update the paragraph every minute? |
|
#7
|
||||
|
||||
|
Couple ways. You can run the timer every second and use a flag variable, this works best if you have other script segments relying on that timer, or you can just set the timer to run once per minute if nothing else is relying on it. So to use a flag variable you would add something like this to your timer:
if totalSecs<60 then totalSecs = totalSecs + 1; else totalMins = totalMins + 1; totalSecs = 0; end Or for the second choice, to run your page timer once per minute, just use this: Page.StartTimer(60000); |
|
#8
|
||||
|
||||
|
nice one
think I'm going to use that flag one... for now I just used math.round to eleminate the enourmes amount of decimals then counting in minutes, that stops the text from flashing and works the same way as your flag variable will properbly do, but for the coding of it the flag variable is nicer... |
|
#9
|
||||
|
||||
|
Perfect.
|
|
#10
|
||||
|
||||
|
but changing the code will have to wait a couple of hours
We are now comming dangeresly close to saturday morning (here it is 02:30), aprocing the 24 hour mark. be back in a few hours time...
|
|
#11
|
|||
|
|||
|
Put this in your apps Preload event:
Code:
basetime = String.ToNumber(DLL.CallFunction(_SystemFolder .. "\\winmm.dll", "timeGetTime", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)); then whenever you want to know how much time has passed since the app started, do this: Code:
curtime = String.ToNumber(DLL.CallFunction(_SystemFolder .. "\\winmm.dll", "timeGetTime", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)); --get the elapsed time in miliseconds elapsedtime = curtime - basetime; |
|
#12
|
||||
|
||||
|
Worm you are a life saver...
Cheers mate |
|
#13
|
||||
|
||||
|
Sweet!
|
|
#14
|
||||
|
||||
|
Is it posible to start the Page.Timer from a project global like Project.OnStartup
or do I have to set Page.StartTimer on every page? |
|
#15
|
||||
|
||||
|
Quote:
On the otherhand, you can set a base time using Worm's method above on Project startup and then calculate the total running time on project shutdown. Tigg
__________________
TJ-Tigger "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools." "Draco dormiens nunquam titillandus." Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do we shut down a triggered app when it's already running? | Protocol | AutoPlay Media Studio 5.0 | 3 | 01-29-2005 11:22 PM |
| URGENT ! Buttons disapear at running time | cgirolet | AutoPlay Media Studio 5.0 | 2 | 01-16-2004 01:47 PM |
| Determine if an app is already running | KenWiens | AutoPlay Media Studio 4.0 | 3 | 07-14-2003 07:46 PM |
| Running date and time. How? | yoyo | AutoPlay Menu Studio 3.0 | 3 | 07-31-2002 04:25 PM |
| Detecting running app before installation | Beaverman | Setup Factory 5.0 | 1 | 09-29-2000 02:56 PM |
All times are GMT -6. The time now is 01:14 AM.








Linear Mode

