Indigo Rose Software
  #1  
Old 09-23-2005
Jonas DK's Avatar
Jonas DK Jonas DK is offline
Forum Member
 
Join Date: Jul 2004
Location: Denmark
Posts: 282
Huh? Time app running?

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
Reply With Quote
  #2  
Old 09-23-2005
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
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;

Reply With Quote
  #3  
Old 09-23-2005
Jonas DK's Avatar
Jonas DK Jonas DK is offline
Forum Member
 
Join Date: Jul 2004
Location: Denmark
Posts: 282
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.
Reply With Quote
  #4  
Old 09-23-2005
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
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.
Reply With Quote
  #5  
Old 09-23-2005
Jonas DK's Avatar
Jonas DK Jonas DK is offline
Forum Member
 
Join Date: Jul 2004
Location: Denmark
Posts: 282
Quote:
Originally Posted by Corey
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;

I added this to the ontimer

Code:
strTimersec = strTimersec + 1;
if strTimesec >= "60" then
OnlineTime = strTimersec/60;
end
Paragraph.SetText("parTimer", "Du har i dag været online: "..OnlineTime.." Minuter");
But I get an error in line 2 about trying to compare to nill
problem is that if I let it update every secound it wont write out the entire paragraph and the text will be flashing...
Reply With Quote
  #6  
Old 09-23-2005
Jonas DK's Avatar
Jonas DK Jonas DK is offline
Forum Member
 
Join Date: Jul 2004
Location: Denmark
Posts: 282
forget my last post..

What if I only want it to update the paragraph every minute?
Reply With Quote
  #7  
Old 09-23-2005
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
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);

Reply With Quote
  #8  
Old 09-23-2005
Jonas DK's Avatar
Jonas DK Jonas DK is offline
Forum Member
 
Join Date: Jul 2004
Location: Denmark
Posts: 282
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...
Reply With Quote
  #9  
Old 09-23-2005
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
Perfect.
Reply With Quote
  #10  
Old 09-23-2005
Jonas DK's Avatar
Jonas DK Jonas DK is offline
Forum Member
 
Join Date: Jul 2004
Location: Denmark
Posts: 282
Cool

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...
Reply With Quote
  #11  
Old 09-23-2005
Worm Worm is offline
Indigo Rose Customer
 
Join Date: Jul 2002
Location: USA
Posts: 3,937
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;
Reply With Quote
  #12  
Old 09-23-2005
Jonas DK's Avatar
Jonas DK Jonas DK is offline
Forum Member
 
Join Date: Jul 2004
Location: Denmark
Posts: 282
Worm you are a life saver...

Cheers mate
Reply With Quote
  #13  
Old 09-23-2005
Corey's Avatar
Corey Corey is offline
Registered User
 
Join Date: Aug 2002
Posts: 9,746
Sweet!
Reply With Quote
  #14  
Old 09-24-2005
Jonas DK's Avatar
Jonas DK Jonas DK is offline
Forum Member
 
Join Date: Jul 2004
Location: Denmark
Posts: 282
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?
Reply With Quote
  #15  
Old 09-24-2005
TJ_Tigger's Avatar
TJ_Tigger TJ_Tigger is offline
Indigo Rose Customer
 
Join Date: Sep 2002
Location: Sol 3
Posts: 3,188
Quote:
Originally Posted by Jonas DK
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?
The Timer is a page specific action. If your user is to be navigating between pages within your app then you will need to restart the timer everytime they jump pages.

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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


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.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software