# Check what screen a client is open on

**URL:** <https://forum.inductiveautomation.com/t/check-what-screen-a-client-is-open-on/36970>\
**Category:** Ignition\
**Tags:** vision, ignition79\
**Created:** [July 22, 2020, 11:22pm UTC](https://forum.inductiveautomation.com/t/check-what-screen-a-client-is-open-on/36970 "2020-07-22T23:22:29Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![harold.bruulsema](https://avatars.discourse-cdn.com/v4/letter/h/e79b87/32.png) [@harold.bruulsema](https://forum.inductiveautomation.com/u/harold.bruulsema)\
**Post date:** [July 30, 2020, 3:01pm UTC](https://forum.inductiveautomation.com/t/check-what-screen-a-client-is-open-on/36970/17 "2020-07-30T15:01:22Z")

</div>

I use something that you could possibly use for this purpose:

- a Global (shared) script, that implements functions WindowOpened and WindowClosed, to write who opened/closed what window to the audit\_events table
- a script on the visionWindowOpened event (and a corresponding script on the visionWindowClosed event) on every window in the project.

I use this so I can track operator actions. I’m thinking you could query the most recent WindowOpened event in the audit\_events table, to see which window was most recently opened for the client of interest. I don’t know if this is the most effficient way to accomplish what I want, but it works for me.

**visionWindowOpened event:**

`shared.WindowScript.WindowOpened(system.gui.getParentWindow(event).name, '') 
`

**Global (shared) script (named “windowScript”)**

```auto
# these scripts by HAB are used to log all Operator Screen opens/closes to Audit_Events table
# called by event handler scripts on every screen - one script for ScreenOpen, one script for ScreenClosed 
def WindowOpened(WindowName, TagPath):
	Actor = system.tag.read("[System]Client/User/Username").value
	ActorHost = system.tag.read("[System]Client/Network/Hostname").value
	Action = 'OpenWindow'
	ActionTarget = WindowName
	ActionValue = TagPath
	from java.util import Date
	CurrTime = Date()
	StatusCode = 0
	OriginatingSystem = 'project='+system.tag.read("[System]Client/System/ProjectName").value
	OriginatingContext = 22 #value to enable searching for tag events
	try:
		system.db.runPrepUpdate("INSERT INTO audit_events " \
        	                    "(event_timestamp, actor, actor_host, action, action_target, " \
        	                    "action_value, status_code, originating_system, originating_context) " \
	                            "VALUES " \
	                            "(?, ?, ?, ?, ?, " \
	                            "?, ?, ?, ?)", 
 	                            [CurrTime, Actor, ActorHost, Action, ActionTarget,
	                            ActionValue, StatusCode, OriginatingSystem, OriginatingContext], 
	                            database='Ignition_SQL_App001') #must include database connection name
	except:
		pass 
```

---

_[View the full topic](https://forum.inductiveautomation.com/t/check-what-screen-a-client-is-open-on/36970)._
