Help on log out navigation

Modified to execute only if a user other than ‘view’ is logged in:

# Switch to Main Window and view user when inactive and current user is not view.
if system.util.getInactivitySeconds() > 10 and system.security.getUsername() != 'view':
	system.nav.swapTo('Main Window')
	system.security.switchUser('view', 'view')

If you need to do this only for certain users (not for all users other than ‘view’), you would check against a list like this:

# Switch to Main Window and view user when inactive and current user is in list.
runForUsersInThisList = ['userName1', 'userName2', 'userName3', 'userName4']
if system.util.getInactivitySeconds() > 10 and system.security.getUsername() in runForUsersInThisList:
	system.nav.swapTo('Main Window')
	system.security.switchUser('view', 'view')
2 Likes

I used a combination of both and it does exactly what I want!! Thank you very much. here is what I put in.

Check for inactivity for a non-user account

if system.util.getInactivitySeconds() > 300 and system.security.getUsername() != “view”:
# Check if setup screen is showing
if system.nav.getCurrentWindow() == “1 Fenceline East Diagnostics”:
# Swap to main screen
system.nav.swapTo(“Main Window”)
# switch to default user
system.security.switchUser(‘view’, ‘view’)
else:
# Otherwise, just switch to the default user
system.security.switchUser(‘view’, ‘view’)

for the current window, I have at least 20 plus, on other programs, I can assign number to screens. Instead of using a bunch of commas, I can use a memory screen tag that shows any of the number of the screens active.

1 Like

Glad you have it working like you want it to! This should do the same thing with a couple less lines of code:

# Check for inactivity and a non-user account.
if system.util.getInactivitySeconds() > 300 and system.security.getUsername() != "view":
	# If setup screen is showing, swap to main screen.
	if system.nav.getCurrentWindow() == "1 Fenceline East Diagnostics":
		system.nav.swapTo("Main Window")
	# Switch to default user.
	system.security.switchUser('view', 'view')
1 Like