Does anyone have experience with adding a python module via installing python and pip? I am looking to use the pyauogui library in order to take a screenshot. I am assuming this isn't a standard library to use? If I go ahead and install python, then pip, and install this package can I call this function within a script without having to do anything else?
This article talks about using pip and external libraries: https://support.inductiveautomation.com/hc/en-us/articles/360056397252-Python-In-Ignition
That said, you don't need an external library to take a screenshot. Just use the java.awt.Robot API.
system.print.createImage, depending on exactly what you're trying to do.
Note that you simply cannot take/request screenshots/render Perspective content into an image at this time. All scripting solutions will only work in Vision.
I currently have everything setup in perspective. There is no way to take a screenshot using scripting in perspective at all? Even with importing something like selenium library? Since perspective is run on a web browser I would think this would work:. Here is the link I found for something that does this:
No, not possible at the moment. All Python code runs on the backend, and there's no facility for providing or running code on the front end, except for developing your own custom module.
It's been discussed as a possible feature some day but nothing has changed AFAIK: https://forum.inductiveautomation.com/t/perspective-screenshot-capture/
Once a day I need to take a screenshot of one screen and send it in an email to someone. This stinks. Looks like I will have to recreate everything I did in perspective over to vision now.
You can use an external tool like Selenium to capture a screenshot of Perspective. You just can't do it from within Ignition by dropping in a Python library. You would have to set up a Python environment, Selenium and a web browser "driver".
That stinks. Will have to recreate everything in vision now. Please tell me you are able to send emails through scripting in vision?!?! I am using Ignition Edge and once a day need to send a screenshot of one screen and also create a csv file with data saved to the internal database due to Edge.
Check the "Can I run Python 3 code from Ignition?" section of the article Kevin linked above.
You can send emails from Vision, yes. Assuming you have an SMTP server available to you. And assuming your Ignition Edge has the "compute" plugin for scripting (I think...?).
But yeah, if you don't need to take a screenshot of a screen you're currently looking at, invoked by a button press or whatever, then you may be able to salvage the work you've already done by pointing Selenium or something at the right project/page and using it to get a screenshot, like Paul is suggesting.
Basically a poor man's scheduled report, by the sound of it.
I will have the Compute plugin. Creating a bottle or flask from the article definitely seems a bit over my head and complicated. If I am able to process the commands directly from Ignition versus having other things running in the background and making things more complicated, as much as it sucks, I will probably be better off recreating in vision versus setting up things I don't have experience doing.
For the screenshot I simply have to take one picture of the screen in the morning, automatically at a certain time, and send in an email. I also have to create a csv file with values from the internal history throughout the day and send that as well.
Does this all seem possible in vision with the compute module?
Yes, and before you do any work actually building the screen you can play around with code from the other post to take a screenshot and test sending an email, to verify this all works.
I assume you realize this means having a Vision client open and running 24/7 on some computer somewhere so that it can actually take the screenshot and send it.
He's using Edge, so presumably Edge panel. Running Vision 24/7 would be pretty common.
Yes I am using Panel so it would be available 24/7
Is there a way to send an email with a few files created without having to go down the route of installing python, then pip, then installing the package? In otherwords if I used vision can I get around having to do this with a function already available within ignition?
Yes, Vision client scripts can use system.net.sendEmail(). (See the "Scope" statement in the doc.)
So just to come back around...there is no way to do a screenshot unless you install python, pip, a package that would do it, create a script with the external python folder, and then call that script somehow within ignition. with vision you can use the above example to take a screenshot of a vision window without having to install python...etc. As far as the email goes the system.net.sendEmail can be used for either perspective or vision.
Yes, I would say that's an accurate summation.
Perspective is, fundamentally, subject to the privileges and restrictions of the browser environment.
Pros are no installation time, zero update lag, and compatibility with a huge range of devices.
Cons are the browser sandbox - because the last 3 decades have shown time and time again that any capability web browsers expose is a capability someone will exploit for malicious purposes.
When someone asks for scheduled emails, I've found web-accessible Perspective reports (#2 & 3 below--not reporting module, just views of desired data, and often a download button to get it in Excel) are generally an appreciated upgrade. Some ideas that may or may not be relevant to your use case:
I'm not sure what the desired screenshot shows, but if there's a way to present the required data textually, a simple email would be easy from Edge.
If your Edge system is connected to a central server, you could take a daily record of the data behind what's on that screen instead of the screenshot. This data could be used to recreate a view like the daily screenshot available on demand from the central server via Perspective app. And it would support other uses of the data too.
Even without a central server, I believe Edge Compute would supply the necessary tools to store the daily data in a dataset tag or other format on local file system. If local Edge client is Perspective Workstation (not browser), last I heard you can connect one remote Perspective client too, which would allow viewing the daily reports in your Perspective app.