# Auto - Close Error Box

**URL:** <https://forum.inductiveautomation.com/t/auto-close-error-box/12786>\
**Category:** General Discussion\
**Created:** [March 14, 2017, 5:31pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786 "2017-03-14T17:31:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kblankenship](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@kblankenship](https://forum.inductiveautomation.com/u/kblankenship)\
**Post date:** [March 14, 2017, 5:31pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/1 "2017-03-14T17:31:45Z")

</div>

We have clients that, due to anti-virus that our IT will not turn off, have “Unexpected End to ZLIB Input Stream” errors pop up constantly on or department display boards. When this happens, we have to remote into every PC and close the error box.

I have found a way to auto-close these boxes by putting this in a timer script on the client:

`from java.awt import Window, Container, Component, Frame
from javax.swing import JFrame, JDialog
Window = None
jDialog = JDialog(Window,"Demo Dialog")
for wind in jDialog.getWindows():
	if isinstance(wind,JFrame):
		if wind.getTitle() == '':
			wind.dispose()`

The error box titles are “” so this finds any error box with no title and closes it. PLEASE NOTE, THIS IS ANY WINDOW WITH NO TITLE!!!

EDIT: Removed the JDialog component. It was creating a Dialog box in the background that never closed. This avoids the use of that altogether.

`from java.awt import Window, Frame
from javax.swing import JFrame
for wind in Window.getWindows():
	if isinstance(wind,JFrame):
		if wind.getTitle() == '':
			wind.dispose()`

---

<div class="post-metadata">

**Author:** ![khashey.ahmed](https://avatars.discourse-cdn.com/v4/letter/k/c5a1d2/32.png) [@khashey.ahmed](https://forum.inductiveautomation.com/u/khashey.ahmed)\
**Post date:** [August 1, 2018, 11:57pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/2 "2018-08-01T23:57:37Z")

</div>

is there any way of closing it without using awt and swing we have clients running on raspi and it doesn’t seem to work well for them.

---

<div class="post-metadata">

**Author:** ![cdavis](https://avatars.discourse-cdn.com/v4/letter/c/e9bcb4/32.png) [@cdavis](https://forum.inductiveautomation.com/u/cdavis)\
**Post date:** [August 5, 2018, 11:04pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/3 "2018-08-05T23:04:19Z")

</div>

Are you putting this in the client event scripts or a timer component? I am trying to close an error message that pops up while the images are loading during the first time my PI is booted up.

---

<div class="post-metadata">

**Author:** ![kblankenship](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@kblankenship](https://forum.inductiveautomation.com/u/kblankenship)\
**Post date:** [August 6, 2018, 1:43pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/4 "2018-08-06T13:43:11Z")

</div>

I have not been able to find anything other than this. The issue is they do not make the error window available with any kind of built-in Ignition function, but I found they are actually just JWindows, hence the logic using the awt.Window to find and close it. Sorry I can’t be of more help but if I find anything further I will be sure to update here.

---

<div class="post-metadata">

**Author:** ![kblankenship](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@kblankenship](https://forum.inductiveautomation.com/u/kblankenship)\
**Post date:** [August 6, 2018, 1:44pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/5 "2018-08-06T13:44:51Z")

</div>

I have this in a Client Timer Script running every 5 min. Since my error box was popping up at around 1AM when no one was in, it was only an issue if it was still open at 7AM when people arrived. You can have this run as a delayed function using system.util.invokeLater() after your loading is complete I would think, otherwise, you could set it to run every 30 seconds.

---

<div class="post-metadata">

**Author:** ![cdavis](https://avatars.discourse-cdn.com/v4/letter/c/e9bcb4/32.png) [@cdavis](https://forum.inductiveautomation.com/u/cdavis)\
**Post date:** [October 31, 2018, 12:36pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/6 "2018-10-31T12:36:53Z")

</div>

Is there anything I need to add to the edited script? I put the code edited script in a client event timer script running at a fixed rate of 5,000 ms and it is not working for me. I even put the script in a button and that still did not close the error popup.

---

<div class="post-metadata">

**Author:** ![kblankenship](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@kblankenship](https://forum.inductiveautomation.com/u/kblankenship)\
**Post date:** [November 16, 2018, 2:09pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/7 "2018-11-16T14:09:31Z")

</div>

Was it a generic popup generated by the system or was it something you created with “system.gui.errorBox()”? If you created it and named it something other than “”, it will not find it. The catch here is that all of the generic error boxes I was dealing with were named “” so it is searching for the window names and closing them. If possible could you post your project and I can try to replicate it?

---

<div class="post-metadata">

**Author:** ![aburgess](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@aburgess](https://forum.inductiveautomation.com/u/aburgess)\
**Post date:** [January 28, 2019, 10:06pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/8 "2019-01-28T22:06:56Z")

</div>

@kblankenship

I’ve been running this script on our Windows based clients with no issues. However, we are trying to migrate our clients over to Linux based machines (at IT’s request). I haven’t been able to track down why, but on Linux, the only window that is detected is with the getWindows command is the main window that is open in our project.

I have run some test code to print a list of all the windows that it finds and, on Linux, the main window is the only window listed. On the Windows machines it finds the error boxes, navigation bar, etc.

I am by no means a Java expert, but I would have expected the getWindows command to work the same across OS’s. Any thoughts?

The client device in question is running the following:  
Ubuntu 18.04.1 LTS  
GNOME 3.28.2  
Java version 1.8.0\_191

---

<div class="post-metadata">

**Author:** ![Lalillo1](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@Lalillo1](https://forum.inductiveautomation.com/u/Lalillo1)\
**Post date:** [January 30, 2019, 7:02pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/9 "2019-01-30T19:02:49Z")

</div>

Hello,

I tried that code, and it didn’t work for me.  
Per your instructions, this is how I did it.  
Maybe there is something that I am missing.  
I would very much appreciate your feedback.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/83de42cc0521fedfcd52c1cfa5e356a67222fa83.png)

```auto
from java.awt import Window, Frame 
from javax.swing import JFrame 
for wind in Window.getWindows(): 
	if isinstance(wind,JFrame): 
		if wind.getTitle() == '': wind.dispose()

```

---

<div class="post-metadata">

**Author:** ![kblankenship](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@kblankenship](https://forum.inductiveautomation.com/u/kblankenship)\
**Post date:** [January 30, 2019, 7:59pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/10 "2019-01-30T19:59:53Z")

</div>

I am sorry but I am no longer working on Ignition as I have changed positions. I have heard from some people that this does not work on Linux or Mac as they have different window managers. I would investigate into either the wrapper logs or dive inot the java.awt.Window and javax.swing.JFrame docs to see if there is something there that may help you out.

---

<div class="post-metadata">

**Author:** ![kblankenship](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@kblankenship](https://forum.inductiveautomation.com/u/kblankenship)\
**Post date:** [January 30, 2019, 8:01pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/11 "2019-01-30T20:01:12Z")

</div>

A quick search shows that Linux does have a different window manager compared to WIndows. I do not work on Ignition anymore unfortunately, but would recommend looking into javax.swing.JFrame on Ubuntu to see if that can point you in the right direction.

---

<div class="post-metadata">

**Author:** ![aburgess](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@aburgess](https://forum.inductiveautomation.com/u/aburgess)\
**Post date:** [February 4, 2019, 7:25pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/12 "2019-02-04T19:25:11Z")

</div>

Noted.

Thanks for the help. If I do find a fix for this, I’ll go ahead and update this thread.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 18, 2020, 8:35pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/13 "2020-06-18T20:35:21Z")

</div>

I’m trying to auto close a warning box in a client running on a raspberry pi.  
Using a pushbutton running this code

```auto
from java.awt import Window, Frame 
from javax.swing import JFrame 
for w in Window.getWindows(): 
     print w

```

which then yields the following in the console

```auto
com.inductiveautomation.ignition.client.launch.BootstrapSwingFS[frame0,0,0,1040x624,invalid,layout=java.awt.BorderLayout,title=Se$
javax.swing.Popup$HeavyWeightWindow[win0,61,22,277x49,invalid,hidden,layout=java.awt.BorderLayout,rootPaneCheckingEnabled=true]

```

It seems that my warning box is a popup not a JFrame window, so I modified the code to this

```auto
from java.awt import Window, Frame 
from javax.swing import Popup
for w in Window.getWindows(): 
	if isinstance(w,Popup): 
		w.hide()

```

This code did close my diagnostics window haha, but not the warning box. I’m a Java newb, any suggestions?

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [June 18, 2020, 9:14pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/14 "2020-06-18T21:14:32Z")

</div>

Not sure you can close the warning box but here is a script that can get you started:

```auto
"""
Description: The warning box in Ignition can be minimized and therefore not seen again.
				To fix this, we will add a window listener that will intercept the minimize action 
				and remaximize that said window
"""
from javax.swing import SwingUtilities
from java.awt.event import WindowAdapter
from javax.swing import JFrame
class WarnBoxListener(WindowAdapter):
	def windowIconified(self,event):
		event.source.setState(JFrame.NORMAL)
# Create an instance of the warning box
system.gui.warningBox("warning","Warning")
# Find the warning box
par = event.source
par = SwingUtilities.getRoot(par)
errwindow = None
print par
try:
	getwindows = [w for w in par.getWindows()]
	errwindow = [w for w in getwindows if "title=Warning" in str(w)][0]
	print errwindow
except:
	pass
if errwindow!=None:
	errwindow.addWindowListener(WarnBoxListener())
	errwindow.close()

```

The only thing I think you need to change is to set the state to MINIMIZED. That way it will never be seen.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 18, 2020, 9:16pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/15 "2020-06-18T21:16:41Z")

</div>

If it’s a true warning box, it’ll be a JDialog, and modal - meaning that while it’s up, the rest of the event dispatch thread (and therefore any code you have) won’t actually be running. You would need to kick off a periodic task in an asynchronous thread to close such a dialog.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 19, 2020, 12:18pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/16 "2020-06-19T12:18:12Z")

</div>

The warning box is from a sendMessage() action that I use to communicate to about 80 clients. I guess it would be smarter to create a custom popup window and call that to display the message. From there it would be much easier to close automatically. Not sure why I didn’t think of that yesterday, however I believe the suggestions above may still come in handy down the line. Thanks!

---

<div class="post-metadata">

**Author:** ![pphillips](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@pphillips](https://forum.inductiveautomation.com/u/pphillips)\
**Post date:** [July 7, 2020, 9:25pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/17 "2020-07-07T21:25:46Z")

</div>

Some time ago I had need for a suite of Java dialog boxes that would close after a time out, since the kiosk type client sessions were subject to being abandoned, and I didn’t want leftover dialog boxes hanging around for the next user. Admittedly, the most rock-solid way to do this is just make pop-up windows that contain timers to close themselves. However, I’ve used the attached Java dialog boxes with good success for quite a while now.

As-is, these require a boolean client tag “Dialog\_Box\_Open”.

[gui.py](https://forum.inductiveautomation.com/uploads/short-url/v4p05S2qJ3qsnOIQP4kGoWIKuUM.py) (6.7 KB)

---

<div class="post-metadata">

**Author:** ![mlatour](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@mlatour](https://forum.inductiveautomation.com/u/mlatour)\
**Post date:** [September 9, 2020, 3:34pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/18 "2020-09-09T15:34:46Z")

</div>

Hi, just wondering if you ever figured this out for a Raspberry Pi. We have an issue where an error box will popup on a Vision application running on some TV’s, and the only way to get it off the middle of the screen is to VNC in and close it, or move it off screen. As others have said, the scripting above works on Windows, but on the Pi, the error box doesn’t appear to be a JFrame. I also couldn’t get the Popup to work, as you said.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [September 9, 2020, 4:42pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/19 "2020-09-09T16:42:00Z")

</div>

I used a popup window to display any messages. The popup window has an “openTime” parameter. Then I have an expression to monitor time the message has been open

```auto
minutesBetween({Root Container.openTime},now())

```

If minutesBetween \>= 5 then

```auto
system.nav.closeParentWindow()

```

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [May 12, 2021, 11:28pm UTC](https://forum.inductiveautomation.com/t/auto-close-error-box/12786/20 "2021-05-12T23:28:42Z")

</div>

I've followed the script above and added the following for diagnostics:

```auto
logger.debug(wind.getTitle())

```

I get the following output regardless of whether an error popup is open or not..

> 10:59:51.077 [client-script-shared-timer-[Gisborne01]] DEBUG Tamaki Scripting - Launching  
> 10:59:51.079 [client-script-shared-timer-[Gisborne01]] DEBUG Tamaki Scripting - Error  
> 10:59:51.079 [client-script-shared-timer-[Gisborne01]] DEBUG Tamaki Scripting -  
> 10:59:51.079 [client-script-shared-timer-[Gisborne01]] DEBUG Tamaki Scripting - Output Console  
> 10:59:51.079 [client-script-shared-timer-[Gisborne01]] DEBUG Tamaki Scripting - Gisborne01 - Main Window (STAGING)  
> 10:59:51.079 [client-script-shared-timer-[Gisborne01]] DEBUG Tamaki Scripting - Diagnostics

Why would this be the case?  
It seems to work if i close the window with the title "Error", but it doesn't work if i close the window with no title.

EDIT: happy that i have a solution that works, but i'd just like to understand why there is a window with title "Error" regardless of whether a popup is in view or not.

[Next page](https://forum.inductiveautomation.com/t/auto-close-error-box/12786.md?page=2)
