Hi guys,
Im working with Ignition 7.9 and I want to make a window display a popup reminder every few hours that needs to me acknowlaged. My problem is there is other applications working on that station, so the client, that is supposed to get that pop-up, is often minimized when the script opening that window goes off - I want to switch view to that client in the same script, so even if the window is minimzed it will switch to that client displaying the reminder.. How could I achive this? I already tried some functions from other post i found, but they didn't seem to work for Vision client.
Thanks,
Kuba
It sounds like you might need to send a message to the operating system. Which is it? Linux / Windows / something else?
It's a Windows. Do you mean a message like in Client Event Scripts?
You would need to execute something in Windows to bring the application to the front. I've never had to do it.
See if How can I bring an application to the front with a batch script in Windows XP? - Super User is of any help. (Windows XP! Cool!)
This can be accomplished from by getting the window's jframe and setting its extended state. As a quick test, I threw the following script into the action performed event handler of a timer component in a windows environment, and it worked. The window went from minimized to maximized every time the if condition was met:
# Written for the action performed script event handler a timer component
# Maximize the window every 20 seconds
if event.source.value > 20: #[Adjust as needed]
# Recursively find retrieve the jframe from the upper level heiarchy
# ...This could also be accomplished with swing utilities get ancestor of class
def getJFrame(parent):
if 'JFrame' in parent.__class__.__name__:
return parent
elif getJFrame(parent.parent):
return getJFrame(parent.parent)
# Get the jframe of the timer component and set it to maximized every 20 seconds
jframe = getJFrame(event.source.parent)
jframe.extendedState = jframe.MAXIMIZED_BOTH
event.source.value = 0 # Reset timer
Probably simpler and a little faster to use Window.getWindows():
https://docs.oracle.com/javase%2F8%2Fdocs%2Fapi%2F%2F/java/awt/Window.html#getWindows--
Or Frame.getFrames():
https://docs.oracle.com/javase%2F8%2Fdocs%2Fapi%2F%2F/java/awt/Frame.html#getFrames--
And then just call toFront() on the window.
I'm not sure. I do a lot of multi monitor multi desktop stuff, so from that perspective it seems more complicated because I imagine that additional scripting would be needed to identify the correct jframe from the resultant array that is to be maximized.
This worked perfectly as intended. Thank you!