I would like to print to Image an Active X (IE) window.
All works except the Active X (IE) is Blank.
I would like to print to Image an Active X (IE) window.
All works except the Active X (IE) is Blank.
What version of Ignition are you using?
Java and ActiveX are like my kids: they don’t play very nicely with each other. Is it something that can be displayed outside of using an ActiveX?
I want to take a snap shot of a webpage every 15 minutes
Version 7.2.11
Yeah, this is definitely one of those “not play together” issues. I’ve tried a couple of different ways with no go.
Would you be able to use an httpGet and parse your stuff out the html you get back?
If you feel like getting your hands dirty, you might be able to use your handy mechanical friend, java.awt.robot, to do this for you.
Note: This is pretty advanced, as it digs into the Java API.
Full Code:
# Capture Test
from java.awt import Robot, Toolkit, Rectangle
from java.io import File
from javax.imageio import ImageIO
robot = Robot()
toolkit = Toolkit.getDefaultToolkit()
dimension = toolkit.getScreenSize()
bufferedImage = robot.createScreenCapture(Rectangle(0, 0, dimension.width, dimension.height))
filepath = system.file.saveFile("screenshot.png", "png", "png file")
if filepath is not None:
file = File(filepath)
if ImageIO.write(bufferedImage, "png", file):
system.gui.messageBox("Image saved.")
else:
system.gui.messageBox("Image write failed.")
If you want just a part of your screen, you could take the bufferedImage and manipulate it before saving. (or you could pass a different Rectangle to robot.createScreenCapture())
Hope this helps!
Kevin
Your code worked good!
Now I want to put it on a Ignition Timer (15 minutes or so), so i don’t want the save box to pop open, I want to hard code the save to path . such as ( c:\screenpic\Screenshot.png).
Then every 15 minutes or so I will have a refreshed Screenshot.png, which will open in a Doc Viewer on some client PC’s that don’t have internet access.
Is it possible for the screeshot to just be a Ignition container ?
Thanks for your Help !
Wow! Kevin, you got my mind a-runnin'!
This will save just the component (I called mine IEViewer for just the ActiveX Control, but you can use whatever component you wish.)
Reading deeper into the API let me come up with getLocationOnScreen() and getBounds() to define the rectangle for the createScreenCapture().
Jerry, this will also directly save the screencap.
Hope this helps!
[code]# Capture Test
from java.awt import Robot, Rectangle
from java.io import File
from javax.imageio import ImageIO
robot = Robot()
location=event.source.parent.getComponent('IEViewer').getLocationOnScreen()
bounds=event.source.parent.getComponent('IEViewer').getBounds()
rect=Rectangle(location.x, location.y, bounds.width, bounds.height)
bufferedImage = robot.createScreenCapture(rect)
file = File("C://screenpic/Screenshot.png")
ImageIO.write(bufferedImage, "png", file)[/code]
Reminds me of the line from Hitchhiker's Guide to the Galaxy: "Your plastic pal who's fun to be with!"
Jordan
Code worked Great !
Thanks for your Help !
This would be good to add to the Users manual !
Well, that sort of stuff is already documented in the javadocs. To put everything in the User manual would be a bit redundant-- not to mention potentially dangerous-- not that I’ve ever done anything like that… just what I’ve heard… from others…
Just to give you an idea, here’s the link to the Java API docs.
Thanks I am sure this will be useful.