Taking a screenshot

Hello,

I need a script that takes a screenshot.

I want to have two adjustable properties when taking screenshots.

For example, let him work for an hour and take screenshots every five minutes.

Another example, let it run for five hours, take a screenshot every ten minutes.

And save them in a folder. Let the name of the folder be the date of that day.

Would you help me with this topic.

I wish you good work

Hi hguler07,

Thanks for your script request. We have asked our script developers to check and provide feedback.

Kind Regards,
PremJK

Hi @hguler07,

Please try this script prepared by our script developers and provide your feedback
https://scripts.itarian.com/frontend/web/topic/customer-script-to-take-screen-short-and-save-it-in-folder

Kind Regards,
PremJK

Hello,

As soon as the notification came, I tried the code you wrote immediately.
When I run it as logged on user, I get an error.

I am passing you on the screenshot of the error image I received. Could you check in a convenient time please

KOD:

0
Directory: C:\ProgramData


Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 04.12.2020 14:46 2020-12-04
60.0
C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1 : The term 'C:\Users\XXX\AppData\Local\Temp\powershell_file.p s1'
is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
+ CategoryInfo : ObjectNotFound: (C:\Users\XXX\A...rshell_file.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
120.0
C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1 : The term 'C:\Users\XXX\AppData\Local\Temp\powershell_file.p s1'
is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
+ CategoryInfo : ObjectNotFound: (C:\Users\XXX\A...rshell_file.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
180.0
C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1 : The term 'C:\Users\XXX\AppData\Local\Temp\powershell_file.p s1'
is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
+ CategoryInfo : ObjectNotFound: (C:\Users\XXX\A...rshell_file.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
240.0
C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1 : The term 'C:\Users\XXX\AppData\Local\Temp\powershell_file.p s1'
is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
+ CategoryInfo : ObjectNotFound: (C:\Users\XXX\A...rshell_file.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
300.0
C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1 : The term 'C:\Users\XXX\AppData\Local\Temp\powershell_file.p s1'
is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
+ CategoryInfo : ObjectNotFound: (C:\Users\XXX\A...rshell_file.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Hi @hguler07,

Thanks for your prompt reply. We have shared the error with our script developers to check.
Will update you here, once issue is resolved.

Kind Regards,
PremJK

Hi @hguler07,

Can you please try this updated version provided by our script developers and provide your output.

Kind Regards,
PremJK

20201207-screenshort_v2.json (4.08 KB)

Hello

Thank you for the information. I cannot download the file you provided. I’m getting an error.

I looked at all the ways it gave output. But I can’t find the specified items. What should I do. where should i look What am I doing wrong :frowning:

I want the output of the code I run.

Logged in User code output;

C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1
0
Directory: C:\ProgramData


Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 07.12.2020 17:19 2020-12-07
Screenshot saved to:
C:\ProgramData\2020-12-07\XXXBILGIISLEM-XXX-2020-19-07-0519.bmp
60.0
C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1 : The term 'C:\Users\XXX\AppData\Local\Temp\powershell_file.p s1'
is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
+ CategoryInfo : ObjectNotFound: (C:\Users\XXX\A...rshell_file.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
120.0
C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1 : The term 'C:\Users\XXX\AppData\Local\Temp\powershell_file.p s1'
is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
+ CategoryInfo : ObjectNotFound: (C:\Users\XXX\A...rshell_file.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
180.0
C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1 : The term 'C:\Users\XXX\AppData\Local\Temp\powershell_file.p s1'
is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
+ CategoryInfo : ObjectNotFound: (C:\Users\XXX\A...rshell_file.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
240.0
C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1 : The term 'C:\Users\XXX\AppData\Local\Temp\powershell_file.p s1'
is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
+ CategoryInfo : ObjectNotFound: (C:\Users\XXX\A...rshell_file.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
300.0
C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1 : The term 'C:\Users\XXX\AppData\Local\Temp\powershell_file.p s1'
is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Users\XXX\AppData\Local\Temp\powershell_file.ps 1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
+ CategoryInfo : ObjectNotFound: (C:\Users\XXX\A...rshell_file.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

LocalSystem User code output;

C:\WINDOWS\TEMP\powershell_file.ps1
0
Directory: C:\ProgramData


Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7.12.2020 17:33 2020-12-07
Screenshot saved to:
C:\ProgramData\2020-12-07\XXXBILGIISLEM-XXXBILGIISLEM$-2020-33-07-0533.bmp
60.0
C:\WINDOWS\TEMP\powershell_file.ps1 : The term 'C:\WINDOWS\TEMP\powershell_file.ps1' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ C:\WINDOWS\TEMP\powershell_file.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\WINDOWS\TEMP\powershell_file.ps1:String) [], CommandNotFoundExceptio
n
+ FullyQualifiedErrorId : CommandNotFoundException
120.0
C:\WINDOWS\TEMP\powershell_file.ps1 : The term 'C:\WINDOWS\TEMP\powershell_file.ps1' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ C:\WINDOWS\TEMP\powershell_file.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\WINDOWS\TEMP\powershell_file.ps1:String) [], CommandNotFoundExceptio
n
+ FullyQualifiedErrorId : CommandNotFoundException
180.0
C:\WINDOWS\TEMP\powershell_file.ps1 : The term 'C:\WINDOWS\TEMP\powershell_file.ps1' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ C:\WINDOWS\TEMP\powershell_file.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\WINDOWS\TEMP\powershell_file.ps1:String) [], CommandNotFoundExceptio
n
+ FullyQualifiedErrorId : CommandNotFoundException
240.0
C:\WINDOWS\TEMP\powershell_file.ps1 : The term 'C:\WINDOWS\TEMP\powershell_file.ps1' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ C:\WINDOWS\TEMP\powershell_file.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\WINDOWS\TEMP\powershell_file.ps1:String) [], CommandNotFoundExceptio
n
+ FullyQualifiedErrorId : CommandNotFoundException
300.0
C:\WINDOWS\TEMP\powershell_file.ps1 : The term 'C:\WINDOWS\TEMP\powershell_file.ps1' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ C:\WINDOWS\TEMP\powershell_file.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\WINDOWS\TEMP\powershell_file.ps1:String) [], CommandNotFoundExceptio
n
+ FullyQualifiedErrorId : CommandNotFoundException

Hi @hguler07,

What error you are getting while downloading the file. Can you please share the screenshot.

Kind Regards,
​​​​​​​PremJK

Hello,
I encountered this error when I tried to download the code you shared, but. my persistent clicks finally managed to download

I ran the code. The code says it was successful.

However, I cannot find the folder he created and the screenshots he took.

C: \ ProgramData
C: \ Users \ XXX \ AppData \ Local \ Temp
C: \ WINDOWS
C: \ WINDOWS \ TEMP

No matter where I look, there are no screenshots he says he took. Either there is a minor error in the code or I’m doing something wrong.

But I directly imported the json code you provided, I didn’t make any changes.

I’m adding screenshots

Hi @hguler07,

Thanks for your response. Will share your issue with our script developers to check.

Kind Regards,
PremJk

Hi @hguler07,

Our script developers like to have a remote session to investigate the issue. Can you please provide remote session.
If yes, we would create a support ticket to reach you for arranging remote.

Kind Regards,
PremJK

Hello,

Thank you. I created a support ticket. It was the first time I did this though, the screen felt a bit professional. I have filled in the relevant places, I am waiting. I definitely keep you informed of the developments.

Hello @hguler07

We have created a support ticket in regards to your report and will reach you via your forum registered email for further correspondence.

Hello

It has been a while since I created a support ticket, but I haven’t received a feedback yet.
A few emails were sent to the support ticket, but I did not understand what to do. I don’t know if it is coming automatically or sending someone. That screen met a little bit against my eyes.
Actually a script on your website is taking a screenshot. But the purpose of this script is about taking pictures and sending mail.

Since I do not make smtp settings, it does not send mail, but it takes a screenshot. The screenshot capture code in this code. Do you have any chance to change it as I want.

If you want to run and view the code on our computer, I can provide you with remote connection. Like TW or Anydesk.

I wish you good work.

Toaddress =itsm.getParameter("Enter_to_Address") # Enter the email id where you want to send screenshot. Type as STRING.

import time;
import os;
import re;
import ctypes
file='C:\\Windows\Temp\Take-ScreenShot.ps1';
Toaddress='"'+Toaddress+'"'


input="""
################################################## ###########################
# Capturing a screenshot
################################################## ###########################
$timer = (Get-Date -Format yyy-mm-dd-hhmm)
$File = "C:\ProgramData\$env:computername-$env:username-$timer.bmp"
Add-Type -AssemblyName System.Windows.Forms
Add-type -AssemblyName System.Drawing
# Gather Screen resolution information
$Screen = [System.Windows.Forms.SystemInformation]::VirtualScreen
$Width = $Screen.Width
$Height = $Screen.Height
$Left = $Screen.Left
$Top = $Screen.Top
# Create bitmap using the top-left and bottom-right bounds
$bitmap = New-Object System.Drawing.Bitmap $Width, $Height
# Create Graphics object
$graphic = [System.Drawing.Graphics]::FromImage($bitmap)
# Capture screen
$graphic.CopyFromScreen($Left, $Top, 0, 0, $bitmap.Size)
# Save to file
$bitmap.Save($File)
Write-Output "Screenshot saved to:"
Write-Output $File
$fileType = $file.Substring(($file.IndexOf('.'))+1) #get image file extension

function do_mail ($myhtml) {

$SMTPServer = "smtp.gmail.com"
$SMTPPort = "587"
$Username = "coneoperations@gmail.com"
$Password = "Comodo@123"
$time = Get-Date
$to = %s
$subject = "Screenshot of $env:computername on $time"
$body = @"
<html>
<body>
<img src="cid:$env:computername-$env:username-$timer.jpg">
</body>
</html>

Hi hguler07,

It has been a while since I created a support ticket, but I haven’t received a feedback yet.

Our support team have created support ticket to reach you with your registered forum email id. Can you please check that and provide requested details to arrange remote session.
Sorry, the ticket you have created is internal one. Please reply to the ticket which we have created.

Kind Regards,
PremJK

Hello ,

Since I used this ticket system for the first time, I thought they would communicate through the forum. Or because they send a message to the company e-mail address where I created the Ticket. They sent it to my forum mail address. They asked for a contact number for the remote connection. They can connect directly to my computer, as I will have difficulty speaking English. Did I pass an Anydesk id. I have stated that I am available for connection for 17:11: 2020 and I have communicated the hours. In fact, they can now connect. Our shift ends at 18:00. Thank you for the information. I will definitely inform you of the results.

Hi @hguler07,

Thank you so much for your prompt reply. Our Support team will reach you through provided details.

Kind Regards,
PremJK

Hello,

An official from the support department remotely connected to my computer and solved my problem. Forgive me if I’m writing wrong, her name is Om prakash. Although there was a problem with the keyboard control, he corrected about two clock codes by making changes to the code with the on-screen keyboard. He ended his connection after making sure that the code was completely working properly. Thank you once again.

I wish you good work.

Best regards

Hi @hguler07,

Happy to know that issue is solved. Thanks for taking time to provide feedback.

Kind Regards,
PremJK