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()
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.
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.
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.
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.
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?
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
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.
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()
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.
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.
Not sure you can close the warning box but here is a script that can get you started:
"""
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.
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.
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!
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”.
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.
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
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.