Page 1 of 2

Idle

PostPosted: Fri May 11, 2012 5:28 am
by Alex
Hi,

Is there a way to know if the pub is in idle mode?

For example after 60 seconds then [idlemode] = 1 and if I use again the pub then [idlemode] = 0

Thanks


Alex

PostPosted: Fri May 11, 2012 6:47 am
by Tony Kroos
Book->Book Properties->Actions->Idle event

PostPosted: Fri May 11, 2012 6:51 am
by Alex
Hi,

Yes thanks, but when my pub is not on idle, how can I know it?

Thanks


Alex

PostPosted: Fri May 11, 2012 6:56 am
by Tony Kroos
and if I use again the pub then [idlemode] = 0

hmm... then I suppose you have to place [idlemode] = 0 in every action of every object on the page. Well, at least Mouse over actions... If mouse is moving then pub is not idle... it's stupid but will work )

PostPosted: Fri May 11, 2012 7:00 am
by Tony Kroos
if you have a background wallpaper then handle it's mouse events, that should be enough...

PostPosted: Fri May 11, 2012 7:02 am
by Alex
Hi,

Or maybe it is possible to know if the pub is on top?

Thanks


Alex

PostPosted: Fri May 11, 2012 7:09 am
by Tony Kroos
it is possible to know if the pub is on top?

yes but you will need a plugin

PostPosted: Fri May 11, 2012 7:10 am
by Alex
Hi,

Witch one?

Thanks


Alex

PostPosted: Fri May 11, 2012 7:39 am
by Tony Kroos
I don't remember... you need to get a state of any given window (by it's caption or handle), I've seen it somewhere... maybe one of HPW plugins?

PostPosted: Fri May 11, 2012 10:51 am
by Alex
Hi,

Ok thanks, maybe can Dave help us?

Thanks


Alex

PostPosted: Fri May 11, 2012 2:26 pm
by Alex
Hi,

I will explain it better.

I have a timer that I want to stop when the pub is on idle and that it starts again when the pub is not idle anymore.

Is there a way to do it?

Thanks


Alex

PostPosted: Fri May 11, 2012 6:23 pm
by Tony Kroos
Since there's no "Not Idle" action, you must define what is "not idle" by yourself. It may be mouse actions or user input, or something else... and put actions in appropriate place.
Ok thanks, maybe can Dave help us?
that's an easy way ) He may create a callback subroutine for "not idle" event (but define it first)

PostPosted: Fri May 11, 2012 6:28 pm
by josesito
In section "Idle Event" write:

TimerStop "TimerX"
SetVar "[WindowState]" "Minimized"

(don´t forget to activate this funtion otherwise it won´t work)

This will force your user to maximize the program again.

......................
In section "Activate" write:

TimerStart "TimerX" "1000"

(this will start your timer again)

PostPosted: Fri May 11, 2012 6:51 pm
by Gaev
Alex:

You are either confusing Idle (i.e. no mouse/keyboard action by user while your program has focus) with Deactivated/Activated (i.e. user navigates to another window/program ... and later returns to it) ... or you have changed your requirement during the course of this topic discussion.

If you just want to count the time that has elapsed when your pub/exe has focus ... then you can ...

1) Stop your Timer object in the pub's Deactivated section (also under Book Properties >>> Actions) ... and add time elapsed so far to [StoppedTime].

2) Recreate a Timer object in the pub's Activated section.

Each Timer's Interval section can show the accumulated elapsed time (say [Elapsedtime]) by adding the Timer's current elapsed time to [StoppedTime].


So you start with [StoppedTime] and [ElapsedTime] at zero.

Say the user stays on your pub for 5 seconds ... then [ElapsedTime] and [StoppedTime] are frozen at 5

Say user returns to your pub after xx seconds

After 1 second, [StoppedTime] is still 5 but [ElapsedTime] is 6 (5 + 1)

After 2 seconds, [StoppedTime] is still 5 but [ElapsedTime] is 7 (5 + 2)

If the user leaves your pub after 2 seconds, [StoppedTime] is now 7 (5 plus 2)

So when user returns, [ElapsedTime] is 7 + whatever time the new Timer is running.

PostPosted: Fri May 11, 2012 7:01 pm
by josesito
I am not confusing Idle with Deactivated/Activated, this is only a simple way to do it, of course there are other ways, this is only something Alex can do in order to achieve what he wants, I guess it depends on what the Timer is doing. Also, if neccesary there should be some reset of varibles in the Idle section to achive the correct results.

The timer should include something like this:

If "[stop]" "=" ""
GotoLine "continue"
Else
GotoLine "stop"
EndIf

:continue
SetVar "[stop]" ""
.do the proccess
.

:stop
.don´t do the proccess
.

..............
The Idle section should include:
SetVar "[stop]" "yes"

This will trigger the stop proccess inside the timer.

.............
Then the "Activate" section should include:
SetVar "[stop]" ""