Page 1 of 1
Screen Saver
Posted: Mon Aug 05, 2013 8:48 am
by BKirch
Hi,
I was wondering if it's possible to have a screen saver on a iX T10A screen. I know there's a setting that turns the backlight off after a certain number of seconds, but I was hoping there's a way to get a specific screen to show after the certain number of seconds. Thanks for the help.
Re: Screen Saver
Posted: Mon Aug 05, 2013 9:48 am
by mark.monroe
You could use C# code in a
timer and have the HMI change screens. However, I do not know of a way to track how long it was since a operator used the screen. You would have to do some research and see if there is some C# function you could call that would give you the last time the touchscreen was pressed. Touchscreen input is treated the same way as mouse input is.
Re: Screen Saver
Posted: Thu Jul 06, 2017 9:09 am
by entronic
Hi,
Can you find a solution this problem?
thanks for the help.
Re: Screen Saver
Posted: Thu Jul 06, 2017 4:15 pm
by AMitchneck
Hi,
I've never tried this, but take a look at:
https://stackoverflow.com/questions/103 ... ith-the-os
Note on windows CE user32.dll and kernel32.dll are replaced with coredll.dll.
So time since last user interaction would be:
Code: Select all
using System;
using System.Runtime.InteropServices;
public class SystemIdleTime
{
[DllImport("coredll.dll")]
private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
[DllImport("coredll.dll")]
private static extern uint GetLastError();
internal struct LASTINPUTINFO
{
public uint cbSize;
public uint dwTime;
}
// Time (as Timespan) since the last user input
public static TimeSpan GetIdleTimespan()
{
return TimeSpan.FromMilliseconds(GetIdleTime());
}
// Time (in milliseconds) since the last user input
public static uint GetIdleTime()
{
return ((uint)Environment.TickCount - GetLastInputTime());
}
// Get the Last input time in milliseconds
public static uint GetLastInputTime()
{
LASTINPUTINFO lastInPut = new LASTINPUTINFO();
lastInPut.cbSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(lastInPut);
if (!GetLastInputInfo(ref lastInPut))
{
throw new Exception(GetLastError().ToString());
}
return lastInPut.dwTime;
}
}
To use this you could setup a threading timer to run in the background.
Code: Select all
public class IdleTimer
{
private static System.Threading.Timer checkIdle = null;
private static bool timerActive = false;
public static void Start()
{
if (checkIdle == null)
{
checkIdle = new System.Threading.Timer(checkIdle_Tick, null, 1000, 1000); // call timer function every 1000 milliseconds
timerActive = true;
}
else if (!timerActive)
{
checkIdle.Change(1000, 1000); // call timer function every 1000 milliseconds
timerActive = true;
}
}
public static void Stop()
{
if ((checkIdle != null) && timerActive)
{
checkIdle.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); // disable timer
timerActive = false;
}
}
private static void checkIdle_Tick(Object state)
{
// change screen if idle for 30 minutes
if (SystemIdleTime.GetIdleTime() >= 1800000)
{
Stop();
Globals.Screen1.Show();
}
}
}
In the Screen1 closing event you would add a call to IdleTimer.Start();
In the Screen1 open event you would add a call to IdleTimer.Stop();
If Screen1 is not your startup screen, then in your startup screen's open event you would also add IdleTimer.Start();