# Open popup window in Perspective based on timer?

**URL:** <https://forum.inductiveautomation.com/t/open-popup-window-in-perspective-based-on-timer/66083>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [November 3, 2022, 5:09pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-in-perspective-based-on-timer/66083 "2022-11-03T17:09:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hhbauss](https://avatars.discourse-cdn.com/v4/letter/h/ecae2f/32.png) [@hhbauss](https://forum.inductiveautomation.com/u/hhbauss)\
**Post date:** [November 3, 2022, 5:09pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-in-perspective-based-on-timer/66083/1 "2022-11-03T17:09:31Z")

</div>

Greetings all! I am having a hard time getting this script to run as a Gateway Event Script/timer:

```auto
import time

#Speed tag that I am monitoring
badSpeed = system.tag.readBlocking('[default]SpeedTag')[0].value

#Set time allowed before script runs
maxTime = 20

#If max time
if badSpeed < 10:
	start = time.time()
	time.clock()
	elapsed = 0
	while elapsed < maxTime:
		elapsed = time.time() - start
		
	system.nav.openWindow('Popup')

```

I am just trying to have a window pop up after _x_ minutes that makes the user take an action. If the user doesn't take an action in x minutes after window is open, it closes automatically and sets a different tag to a default value.

I can't get the window to pop up?? Any help for a rookie or an idea?

Thanks!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 3, 2022, 5:17pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-in-perspective-based-on-timer/66083/2 "2022-11-03T17:17:01Z")

</div>

Under no circumstances should burn CPU time in such a busy loop. ~~Don't use~~ Avoid using any form of `.sleep()`, either ~~, as it will also lock up your user interface~~.

Wait. You are also trying to open a Vision window with `system.nav.` but your post is tagged Perspective.

Perspective is a bit more tolerant of `.sleep()`, but a state machine driven by timer events or time binding changes (using a `now()` expression) are far superior. And you can abort the action if conditions change.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 3, 2022, 5:20pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-in-perspective-based-on-timer/66083/3 "2022-11-03T17:20:39Z")

</div>

Further, gateway events and tag change events do not have access to your user interfaces. Instead, in the user interface where you want the popup to open, bind that speed tag to a custom property. Then use an onChange action script to perform your other logic. I recommend saving a timestamp in another custom property and using that to determine if your minute has expired.

---

<div class="post-metadata">

**Author:** ![hhbauss](https://avatars.discourse-cdn.com/v4/letter/h/ecae2f/32.png) [@hhbauss](https://forum.inductiveautomation.com/u/hhbauss)\
**Post date:** [November 3, 2022, 5:52pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-in-perspective-based-on-timer/66083/4 "2022-11-03T17:52:34Z")

</div>

Yes, this will be in Perspective only. Ok thanks, I will try using the custom properties in the view I want the popup to occur. Thanks for the advice! I'll report back any results.
