# Execute script upon swapping windows

**URL:** <https://forum.inductiveautomation.com/t/execute-script-upon-swapping-windows/23611>\
**Category:** Ignition\
**Created:** [March 26, 2019, 5:51pm UTC](https://forum.inductiveautomation.com/t/execute-script-upon-swapping-windows/23611 "2019-03-26T17:51:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevincgc](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@kevincgc](https://forum.inductiveautomation.com/u/kevincgc)\
**Post date:** [March 26, 2019, 5:51pm UTC](https://forum.inductiveautomation.com/t/execute-script-upon-swapping-windows/23611/1 "2019-03-26T17:51:38Z")

</div>

I have a tab strip that I am using to swap between main windows. I want to execute a script to open a docked window based on which main windows I’m swapping to.

internalFrameOpened and visionWindowOpened will both only execute the script once when the client is opened. If I swap to another window and swap back, the script won’t execute.

internalFrameActivated requires me to click the main window to give it focus before it executes the script, but I would like the script to execute immediately when I swap windows.

Is there a good way of doing this?

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [March 26, 2019, 6:06pm UTC](https://forum.inductiveautomation.com/t/execute-script-upon-swapping-windows/23611/2 "2019-03-26T18:06:52Z")

</div>

Would a property change script tied to selected tab property of tab strip do what you’re looking for?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 26, 2019, 7:34pm UTC](https://forum.inductiveautomation.com/t/execute-script-upon-swapping-windows/23611/3 "2019-03-26T19:34:29Z")

</div>

> [@Nav Helper system.nav.openWindowInstace](http://forum.inductiveautomation.com/t/nav-helper-system-nav-openwindowinstace/1825/7):
>
> Here is an update. Changed to allow more than one property to be passed. [code]def findInstance(window,instanceId): import system for row in system.gui.getOpenedWindows(): if row.name == window and row.getRootContainer().Tag == instanceId: return row return None def openInstance(window,properties=None): import system, app.instanceControl windowInstance = app.instanceControl.findInstance(window,properties['Tag']) if windowInstance == None: windowInstance = system.nav.openWindowInstance…

---

<div class="post-metadata">

**Author:** ![kevincgc](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@kevincgc](https://forum.inductiveautomation.com/u/kevincgc)\
**Post date:** [March 26, 2019, 7:38pm UTC](https://forum.inductiveautomation.com/t/execute-script-upon-swapping-windows/23611/4 "2019-03-26T19:38:57Z")

</div>

I tried this to close the current main window and open a window based on the selected tab property.

It works but it loads slower than swapping windows. Thanks for the help.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [March 26, 2019, 7:49pm UTC](https://forum.inductiveautomation.com/t/execute-script-upon-swapping-windows/23611/5 "2019-03-26T19:49:25Z")

</div>

I may have misunderstood, but was thinking you’d continue swapping the main windows and use the script to update docked windows. It will be slower to open a window that isn’t already open. If you want instant, you could have the docked windows all open and adjust width (or height, depending where they are docked) to zero to hide all but the one you want to show at any given time.
