Quote from PaulJonestindall on May 15, 2020, 4:42 pmI'm just putting this out there: I've discovered that if you have a Timer Object active, the Idle Event feature will not work, at least in some cases.
In my case I have a Timer Object that checks a file every few minutes. I set the Idle Event to occur after 60 minutes. The Idle Event did not occur. I then removed the Timer Object, the Idle Event occurred.
I need to find a workaround.
I'm just putting this out there: I've discovered that if you have a Timer Object active, the Idle Event feature will not work, at least in some cases.
In my case I have a Timer Object that checks a file every few minutes. I set the Idle Event to occur after 60 minutes. The Idle Event did not occur. I then removed the Timer Object, the Idle Event occurred.
I need to find a workaround.
Quote from Gaev on May 15, 2020, 8:30 pm@pauljonestindall
I have a Timer Object that checks a file every few minutes.
I set the Idle Event to occur after 60 minutes.
I need to find a workaround.Can you provide some details of what actions are taken ... both, "every few minutes" and "if the system remained Idle for 60 minutes"
I have a Timer Object that checks a file every few minutes.
I set the Idle Event to occur after 60 minutes.
I need to find a workaround.
Can you provide some details of what actions are taken ... both, "every few minutes" and "if the system remained Idle for 60 minutes"
Quote from PaulJonestindall on May 18, 2020, 4:27 pm@gaev
Timer:
Set to start on page open, 300,000 ms or 5 minutes.Timer Action:
FileExists "[PubDir]data.dat" "[DataExistsYN]"
If "[DataExistsYN]" "=" "True"
FileRead "[PubDir]data.dat" "All" "[data]"
FileErase "[PubDir]data.dat"
EndIfIdle Event (every 3600 seconds):
StickyNote "-1" "-1" "You Have Been Idle for One Hour - Shutting Down" "4000"
Delay "4000"
Exit "" ""This should work assuming the Idle Event feature is looking for mouse or keyboard activity (or inactivity). If I remove the Timer Object though, the Idle Event action will then work.
Timer:
Set to start on page open, 300,000 ms or 5 minutes.
Timer Action:
FileExists "[PubDir]data.dat" "[DataExistsYN]"
If "[DataExistsYN]" "=" "True"
FileRead "[PubDir]data.dat" "All" "[data]"
FileErase "[PubDir]data.dat"
EndIf
Idle Event (every 3600 seconds):
StickyNote "-1" "-1" "You Have Been Idle for One Hour - Shutting Down" "4000"
Delay "4000"
Exit "" ""
This should work assuming the Idle Event feature is looking for mouse or keyboard activity (or inactivity). If I remove the Timer Object though, the Idle Event action will then work.
Quote from Gaev on May 18, 2020, 7:19 pm@pauljonestindall
Assuming that the IdleEvent does not fire when you have an active Timer ... your requirements present quite a dilemma.
Here is a suggested design that will work as long as the user is inactive for a 3 or 5 second period within any 300 second period.
1) Set the Time Interval for your Idle Event to somewhere between 3 and 5 seconds
2) In your Start Up section ...
... set a timestamp value in [FileCheckTime] that is 5 minutes from now GoSub "SetNextFileCheckTime" ... set a timestamp value in [IdleExitTime] that is 60 minutes from now GoSub "SetIdleTimeValue"3) In your Idle Event section (which will be triggered whenever there is no activity for 3 to 5 seconds) ...
... check if [IdleExitTime] exceeded ; if true, do the StickyNote/Delay/Exit thing GoSub "ExitIfIdleExceeded" ... return here if [IdleExitTime] NOT exceeded ... check if [FileCheckTime] is exceeded; refresh if necessary GoSub "CheckFileRefresh"4) subroutine to check if it is time to do a file refresh ...
:CheckFileRefresh ... compare now against [FileCheckTime] ... if exceeded, do the File commands and GoSub "SetNextFileCheckTime" ... else, do nothing ReturnI have not shown the code for setting or comparing Timestamp values (can do if you run into difficulties)
This design will cause the Idle Event code to be triggered each time the user is inactive (mouse, keyboard) for about 3 to 5 seconds ... when triggered, it will check (previously set up times when File Refresh or Exit actions need to be invoked) ... if exceeded, it will take appropriate actions.
Hopefully you don't have a (super) user that does not pause for an hour !!!
Good luck.
Assuming that the IdleEvent does not fire when you have an active Timer ... your requirements present quite a dilemma.
Here is a suggested design that will work as long as the user is inactive for a 3 or 5 second period within any 300 second period.
1) Set the Time Interval for your Idle Event to somewhere between 3 and 5 seconds
2) In your Start Up section ...
... set a timestamp value in [FileCheckTime] that is 5 minutes from now GoSub "SetNextFileCheckTime" ... set a timestamp value in [IdleExitTime] that is 60 minutes from now GoSub "SetIdleTimeValue"
3) In your Idle Event section (which will be triggered whenever there is no activity for 3 to 5 seconds) ...
... check if [IdleExitTime] exceeded ; if true, do the StickyNote/Delay/Exit thing GoSub "ExitIfIdleExceeded" ... return here if [IdleExitTime] NOT exceeded ... check if [FileCheckTime] is exceeded; refresh if necessary GoSub "CheckFileRefresh"
4) subroutine to check if it is time to do a file refresh ...
:CheckFileRefresh ... compare now against [FileCheckTime] ... if exceeded, do the File commands and GoSub "SetNextFileCheckTime" ... else, do nothing Return
I have not shown the code for setting or comparing Timestamp values (can do if you run into difficulties)
This design will cause the Idle Event code to be triggered each time the user is inactive (mouse, keyboard) for about 3 to 5 seconds ... when triggered, it will check (previously set up times when File Refresh or Exit actions need to be invoked) ... if exceeded, it will take appropriate actions.
Hopefully you don't have a (super) user that does not pause for an hour !!!
Good luck.
Quote from PaulJonestindall on May 22, 2020, 4:10 pm@gaev
Thanks for the workaround. I totally get the concept. I can make it work.
As for my users... It's not that they pause for an hour, it's more an issue of running the program and walking away or leaving it running overnight. The program's used on a shared drive network system and at this stage I'm still making updates to it, so... I had to figure out a way to "kill" the program remotely. Also I need the timers to update files, refresh DB, etc.
Thanks again.
Thanks for the workaround. I totally get the concept. I can make it work.
As for my users... It's not that they pause for an hour, it's more an issue of running the program and walking away or leaving it running overnight. The program's used on a shared drive network system and at this stage I'm still making updates to it, so... I had to figure out a way to "kill" the program remotely. Also I need the timers to update files, refresh DB, etc.
Thanks again.
Quote from Gaev on May 22, 2020, 4:56 pm@pauljonestindall
it's more an issue of leaving it running overnight.
The program's used on a shared drive network system and at this stage I'm still making updates to it, so I had to figure out a way to "kill" the program remotely.Assuming you can initiate running of programs from your remote perch , you could attempt to run a second copy of the program with a special/unique command line parameter (e.g. KillYourself).
From the Help file ...
You can detect when a user attempts to launch a second instance of your publication by creating a special subroutine called CommandLine_OnChange. VisualNEO for Windows will automatically execute this subroutine whenever the user attempts to start more than one copy of your publication. For example:
:CommandLine_OnChange
AlertBox "Warning" "An attempt was made to launch a second copy of this app."
Return
More details on this Help file page ... https://winhelp.visualneo.com/Access.html
Also I need the timers to update files, refresh DB, etc.
You could also consider having your users invoke a "parent program" that ...
- would invoke (Run command) the "child program" (where the user does all the keyboard/mouse activity)
- periodically (via a timer in the "parent program") invoke the "child program" with a parameter like "RefreshFiles"... and leave the "Idle Event" management inside the "child program" (as before)
it's more an issue of leaving it running overnight.
The program's used on a shared drive network system and at this stage I'm still making updates to it, so I had to figure out a way to "kill" the program remotely.
Assuming you can initiate running of programs from your remote perch , you could attempt to run a second copy of the program with a special/unique command line parameter (e.g. KillYourself).
From the Help file ...
You can detect when a user attempts to launch a second instance of your publication by creating a special subroutine called CommandLine_OnChange. VisualNEO for Windows will automatically execute this subroutine whenever the user attempts to start more than one copy of your publication. For example:
:CommandLine_OnChange
AlertBox "Warning" "An attempt was made to launch a second copy of this app."
Return
More details on this Help file page ... https://winhelp.visualneo.com/Access.html
Also I need the timers to update files, refresh DB, etc.
You could also consider having your users invoke a "parent program" that ...
- would invoke (Run command) the "child program" (where the user does all the keyboard/mouse activity)
- periodically (via a timer in the "parent program") invoke the "child program" with a parameter like "RefreshFiles"
... and leave the "Idle Event" management inside the "child program" (as before)
Quote from PaulJonestindall on May 22, 2020, 6:12 pmThat's a very interesting point. I may be able to use the CommandLine feature in future.
But here's my thing... One of the beauties of NeoBook/VisualNeo is that programs can be created to run "stand alone", without being installed, having to be registered, etc. I have one executable on shared network drive that multiple users can run. I do however have the Book Properties>Access switch set to prevent multiple copies from running and that prevents users from initiating more than one instance on their particular computer. This is helpful because it lets me track which user and what computer is currently running the program.
So, for my purposes for now, I think I can utilize some variation of your first suggestion. That's a great idea. Thanks.
That's a very interesting point. I may be able to use the CommandLine feature in future.
But here's my thing... One of the beauties of NeoBook/VisualNeo is that programs can be created to run "stand alone", without being installed, having to be registered, etc. I have one executable on shared network drive that multiple users can run. I do however have the Book Properties>Access switch set to prevent multiple copies from running and that prevents users from initiating more than one instance on their particular computer. This is helpful because it lets me track which user and what computer is currently running the program.
So, for my purposes for now, I think I can utilize some variation of your first suggestion. That's a great idea. Thanks.
Quote from Gaev on May 22, 2020, 7:43 pm@pauljonestindall
I have one executable on shared network drive that multiple users can run. I do however have the Book Properties>Access switch set to prevent multiple copies from running and that prevents users from initiating more than one instance on their particular computer.
You might still be able to control that ...
a) have the :CommandLine_OnChange subroutine check if a "log" file exists at start up time ... if it does, prevent the second copy ... else FileWrite something like ...
Started on 22/05/2020 at 09:30:35
b) do a FileDelete at exit time
Also, as long as users ALWAYS run the "parent program", you could still make it so the "parent program" is set to only run one copy on each computer.
More than one way to "skin a c@t' ... oops that is not PC anymore :-)
Whatever design best fits your needs.
I have one executable on shared network drive that multiple users can run. I do however have the Book Properties>Access switch set to prevent multiple copies from running and that prevents users from initiating more than one instance on their particular computer.
You might still be able to control that ...
a) have the :CommandLine_OnChange subroutine check if a "log" file exists at start up time ... if it does, prevent the second copy ... else FileWrite something like ...
Started on 22/05/2020 at 09:30:35
b) do a FileDelete at exit time
Also, as long as users ALWAYS run the "parent program", you could still make it so the "parent program" is set to only run one copy on each computer.
More than one way to "skin a c@t' ... oops that is not PC anymore :-)
Whatever design best fits your needs.