AUTO return to Startup screen

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
Kardanas
Posts: 3
Joined: Tue Sep 15, 2015 12:45 am

AUTO return to Startup screen

Post by Kardanas »

Good day,

I was wondering is there function that after some time of inactivity application returns to startup screen?
(operators tend to leave settings screen and since startup screen usually is used as process parameters monitoring scree - they can miss


Thank you.

baaron
Posts: 4
Joined: Thu Aug 22, 2019 11:14 pm

Re: AUTO return to Startup screen

Post by baaron »

Here is an example of a Script Module modified from a VNC Disconnect script.

Script Module Name is : "Inactivity_screen" be sure to create the

Code: Select all

void Inactivity_screen_Created(System.Object sender, System.EventArgs e)
by clicking on the left side
Change

Code: Select all

Globals.Screen1.Show();
to the name of your home screen.

You will need additional tags to the project(all are INT16, ReadWrite):
System_InacticityTimeBeforeLogout: Set Initial Value to time taken before screen changes
Mouse_Move_Hysterisis: Amount of mouse moment to count as activity
In_Act_Time_Acc: Time accumulated inactive. If reaches System_InacticityTimeBeforeLogout value will change screen.

Code: Select all

//--------------------------------------------------------------
// Press F1 to get help about using script.
// To access an object that is not located in the current class, start the call with Globals.
// When using events and timers be cautious not to generate memoryleaks,
// please see the help for more information.
//---------------------------------------------------------------

namespace Neo.ApplicationFramework.Generated
{
    using System.Windows.Forms;
    using System;
    using System.Drawing;
    using Neo.ApplicationFramework.Tools;
    using Neo.ApplicationFramework.Common.Graphics.Logic;
    using Neo.ApplicationFramework.Controls;
    using Neo.ApplicationFramework.Interfaces;
    
    
    public partial class Inactivity_screen
    {


		//*****************************************************************************************************************************************
		//CHECK INACTIVITY
		//*****************************************************************************************************************************************
		
		private static System.Windows.Forms.Timer inactivity_timer;
		private int _mouseX = -1;
		private int _mouseY = -1;
		private int _mouseMoved;
		private int _keep_down_time;

		private void TimerTick(Object sender, EventArgs e)//TimerTick event called by the inactivity_timer tick 
		{
			var x = System.Windows.Forms.Control.MousePosition.X;//Mouse X position mouse is considered to be at last touch location
			var y = System.Windows.Forms.Control.MousePosition.Y;//Mouse Y position mouse is considered to be at last touch location
			
			if( ( Math.Abs(_mouseX-x) > Globals.Tags.Mouse_Move_Hysterisis.Value ) || ( Math.Abs(_mouseY-y) > Globals.Tags.Mouse_Move_Hysterisis.Value ) ) //See if mouse has moved more than the defined Hysterisis
			{
				_mouseMoved=0;//Set inactivity timer to 0
				try 
				{	
					//If you wanted some event to fire at any activity you would put that here
					//	MessageBox.Show( "Activity!");
				}
				catch (Exception ex)
				{	
					//Catch for Activity event
					MessageBox.Show(ex.ToString(), "Error!! Could not perform action associated with activity");
				}	
			}
			else
			{
				
					_mouseMoved++; //Counts seconds since mouse last moved
					Globals.Tags.In_Act_Time_Acc.Value = _mouseMoved;//puts seconds into a tag for display purposes
			
			


				var inactivityTimeout = Globals.Tags.System_InactivityTimeBeforeLogout.Value; //Gets inactivity setpoint from tag

				if((inactivityTimeout>0) && (_mouseMoved > inactivityTimeout))//compares seconds of inactivity to setpoint
				{	
					
					try 
					{	
						Globals.Screen1.Show();
						_mouseMoved = 0;
						
					}
					catch (Exception ex)
					{	
						MessageBox.Show(ex.ToString(), "Error!! Could not perform inactivity action");//If Process could not be found this should fire.
					}
				}
			}	
			_mouseX = x;
			_mouseY = y;
		}


		
	
		
		void Inactivity_screen_Created(System.Object sender, System.EventArgs e)
		{
			// Set up timer that monitors if the mouse has moved
			inactivity_timer = new System.Windows.Forms.Timer {Interval = 1000};//Timer Ticks or counts every 1000ms
			inactivity_timer.Tick += TimerTick; //Fire TimerTick event Line 64 every time the timer ticks
			inactivity_timer.Enabled = true;	//Start Counting
		}
	}
    
}
I would like to put another check that only counts up when you are on any page that isnt home so it isnt always changing even after already being moved to the correct page. Ex: if(Globals.Screen1.Active == false) but I dont think that exists and you might have to do something with a bit tag to flag it being displayed or not.

Post Reply