├── .gitattributes
├── .gitignore
├── README.md
├── Screenshot from 2020-03-09 16-36-29.png
├── SharpShot.sln
└── SharpShot
├── App.config
├── GDI32.cs
├── Program.cs
├── Properties
└── AssemblyInfo.cs
├── SharpShot.csproj
└── User32.cs
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | [Aa][Rr][Mm]/
24 | [Aa][Rr][Mm]64/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | [Ll]og/
29 |
30 | # Visual Studio 2015/2017 cache/options directory
31 | .vs/
32 | # Uncomment if you have tasks that create the project's static files in wwwroot
33 | #wwwroot/
34 |
35 | # Visual Studio 2017 auto generated files
36 | Generated\ Files/
37 |
38 | # MSTest test Results
39 | [Tt]est[Rr]esult*/
40 | [Bb]uild[Ll]og.*
41 |
42 | # NUNIT
43 | *.VisualState.xml
44 | TestResult.xml
45 |
46 | # Build Results of an ATL Project
47 | [Dd]ebugPS/
48 | [Rr]eleasePS/
49 | dlldata.c
50 |
51 | # Benchmark Results
52 | BenchmarkDotNet.Artifacts/
53 |
54 | # .NET Core
55 | project.lock.json
56 | project.fragment.lock.json
57 | artifacts/
58 |
59 | # StyleCop
60 | StyleCopReport.xml
61 |
62 | # Files built by Visual Studio
63 | *_i.c
64 | *_p.c
65 | *_h.h
66 | *.ilk
67 | *.meta
68 | *.obj
69 | *.iobj
70 | *.pch
71 | *.pdb
72 | *.ipdb
73 | *.pgc
74 | *.pgd
75 | *.rsp
76 | *.sbr
77 | *.tlb
78 | *.tli
79 | *.tlh
80 | *.tmp
81 | *.tmp_proj
82 | *_wpftmp.csproj
83 | *.log
84 | *.vspscc
85 | *.vssscc
86 | .builds
87 | *.pidb
88 | *.svclog
89 | *.scc
90 |
91 | # Chutzpah Test files
92 | _Chutzpah*
93 |
94 | # Visual C++ cache files
95 | ipch/
96 | *.aps
97 | *.ncb
98 | *.opendb
99 | *.opensdf
100 | *.sdf
101 | *.cachefile
102 | *.VC.db
103 | *.VC.VC.opendb
104 |
105 | # Visual Studio profiler
106 | *.psess
107 | *.vsp
108 | *.vspx
109 | *.sap
110 |
111 | # Visual Studio Trace Files
112 | *.e2e
113 |
114 | # TFS 2012 Local Workspace
115 | $tf/
116 |
117 | # Guidance Automation Toolkit
118 | *.gpState
119 |
120 | # ReSharper is a .NET coding add-in
121 | _ReSharper*/
122 | *.[Rr]e[Ss]harper
123 | *.DotSettings.user
124 |
125 | # JustCode is a .NET coding add-in
126 | .JustCode
127 |
128 | # TeamCity is a build add-in
129 | _TeamCity*
130 |
131 | # DotCover is a Code Coverage Tool
132 | *.dotCover
133 |
134 | # AxoCover is a Code Coverage Tool
135 | .axoCover/*
136 | !.axoCover/settings.json
137 |
138 | # Visual Studio code coverage results
139 | *.coverage
140 | *.coveragexml
141 |
142 | # NCrunch
143 | _NCrunch_*
144 | .*crunch*.local.xml
145 | nCrunchTemp_*
146 |
147 | # MightyMoose
148 | *.mm.*
149 | AutoTest.Net/
150 |
151 | # Web workbench (sass)
152 | .sass-cache/
153 |
154 | # Installshield output folder
155 | [Ee]xpress/
156 |
157 | # DocProject is a documentation generator add-in
158 | DocProject/buildhelp/
159 | DocProject/Help/*.HxT
160 | DocProject/Help/*.HxC
161 | DocProject/Help/*.hhc
162 | DocProject/Help/*.hhk
163 | DocProject/Help/*.hhp
164 | DocProject/Help/Html2
165 | DocProject/Help/html
166 |
167 | # Click-Once directory
168 | publish/
169 |
170 | # Publish Web Output
171 | *.[Pp]ublish.xml
172 | *.azurePubxml
173 | # Note: Comment the next line if you want to checkin your web deploy settings,
174 | # but database connection strings (with potential passwords) will be unencrypted
175 | *.pubxml
176 | *.publishproj
177 |
178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
179 | # checkin your Azure Web App publish settings, but sensitive information contained
180 | # in these scripts will be unencrypted
181 | PublishScripts/
182 |
183 | # NuGet Packages
184 | *.nupkg
185 | # The packages folder can be ignored because of Package Restore
186 | **/[Pp]ackages/*
187 | # except build/, which is used as an MSBuild target.
188 | !**/[Pp]ackages/build/
189 | # Uncomment if necessary however generally it will be regenerated when needed
190 | #!**/[Pp]ackages/repositories.config
191 | # NuGet v3's project.json files produces more ignorable files
192 | *.nuget.props
193 | *.nuget.targets
194 |
195 | # Microsoft Azure Build Output
196 | csx/
197 | *.build.csdef
198 |
199 | # Microsoft Azure Emulator
200 | ecf/
201 | rcf/
202 |
203 | # Windows Store app package directories and files
204 | AppPackages/
205 | BundleArtifacts/
206 | Package.StoreAssociation.xml
207 | _pkginfo.txt
208 | *.appx
209 |
210 | # Visual Studio cache files
211 | # files ending in .cache can be ignored
212 | *.[Cc]ache
213 | # but keep track of directories ending in .cache
214 | !?*.[Cc]ache/
215 |
216 | # Others
217 | ClientBin/
218 | ~$*
219 | *~
220 | *.dbmdl
221 | *.dbproj.schemaview
222 | *.jfm
223 | *.pfx
224 | *.publishsettings
225 | orleans.codegen.cs
226 |
227 | # Including strong name files can present a security risk
228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
229 | #*.snk
230 |
231 | # Since there are multiple workflows, uncomment next line to ignore bower_components
232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
233 | #bower_components/
234 |
235 | # RIA/Silverlight projects
236 | Generated_Code/
237 |
238 | # Backup & report files from converting an old project file
239 | # to a newer Visual Studio version. Backup files are not needed,
240 | # because we have git ;-)
241 | _UpgradeReport_Files/
242 | Backup*/
243 | UpgradeLog*.XML
244 | UpgradeLog*.htm
245 | ServiceFabricBackup/
246 | *.rptproj.bak
247 |
248 | # SQL Server files
249 | *.mdf
250 | *.ldf
251 | *.ndf
252 |
253 | # Business Intelligence projects
254 | *.rdl.data
255 | *.bim.layout
256 | *.bim_*.settings
257 | *.rptproj.rsuser
258 | *- Backup*.rdl
259 |
260 | # Microsoft Fakes
261 | FakesAssemblies/
262 |
263 | # GhostDoc plugin setting file
264 | *.GhostDoc.xml
265 |
266 | # Node.js Tools for Visual Studio
267 | .ntvs_analysis.dat
268 | node_modules/
269 |
270 | # Visual Studio 6 build log
271 | *.plg
272 |
273 | # Visual Studio 6 workspace options file
274 | *.opt
275 |
276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
277 | *.vbw
278 |
279 | # Visual Studio LightSwitch build output
280 | **/*.HTMLClient/GeneratedArtifacts
281 | **/*.DesktopClient/GeneratedArtifacts
282 | **/*.DesktopClient/ModelManifest.xml
283 | **/*.Server/GeneratedArtifacts
284 | **/*.Server/ModelManifest.xml
285 | _Pvt_Extensions
286 |
287 | # Paket dependency manager
288 | .paket/paket.exe
289 | paket-files/
290 |
291 | # FAKE - F# Make
292 | .fake/
293 |
294 | # JetBrains Rider
295 | .idea/
296 | *.sln.iml
297 |
298 | # CodeRush personal settings
299 | .cr/personal
300 |
301 | # Python Tools for Visual Studio (PTVS)
302 | __pycache__/
303 | *.pyc
304 |
305 | # Cake - Uncomment if you are using it
306 | # tools/**
307 | # !tools/packages.config
308 |
309 | # Tabs Studio
310 | *.tss
311 |
312 | # Telerik's JustMock configuration file
313 | *.jmconfig
314 |
315 | # BizTalk build output
316 | *.btp.cs
317 | *.btm.cs
318 | *.odx.cs
319 | *.xsd.cs
320 |
321 | # OpenCover UI analysis results
322 | OpenCover/
323 |
324 | # Azure Stream Analytics local run output
325 | ASALocalRun/
326 |
327 | # MSBuild Binary and Structured Log
328 | *.binlog
329 |
330 | # NVidia Nsight GPU debugger configuration file
331 | *.nvuser
332 |
333 | # MFractors (Xamarin productivity tool) working folder
334 | .mfractor/
335 |
336 | # Local History for Visual Studio
337 | .localhistory/
338 |
339 | # BeatPulse healthcheck temp database
340 | healthchecksdb
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SharpShot
2 | Capture screenshots from .NET, using either native Windows APIs or .NET methods.
3 | Screenshots can be saved to disk using a randomly generated file name, or output to the console in base64 encoded form (does not touch disk).
4 |
5 | Can be execued using beacons execute-assembly.
6 |
7 |
8 | ## Usage
9 |
10 | See the usage instructions:
11 | ```
12 | SharpShot.exe /help
13 | ```
14 |
15 | Capture a full window screenshot using the Windows API and save to disk:
16 | ```
17 | SharpShot.exe /outfolder:c:\windows\temp /outformat:img /native
18 | ```
19 |
20 | Capture a full window screenshot using .NET methods and save to disk:
21 | ```
22 | SharpShot.exe /outfolder:c:\windows\temp /outformat:img
23 | ```
24 |
25 | Capture a full window screenshot using the Windows API and output to the console as Base64:
26 | ```
27 | SharpShot.exe /outformat:base64 /native
28 | ```
29 |
30 | Capture a full window screenshot using .NET methods and output to the console as Base64:
31 | ```
32 | SharpShot.exe /outformat:base64
33 | ```
34 | ## Screenshot
35 |
36 | 
37 |
--------------------------------------------------------------------------------
/Screenshot from 2020-03-09 16-36-29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/two06/SharpShot/37f5cb43a1cebb4b2de23b8ce95ad542e28a50df/Screenshot from 2020-03-09 16-36-29.png
--------------------------------------------------------------------------------
/SharpShot.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29613.14
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpShot", "SharpShot\SharpShot.csproj", "{FA7E6914-8070-438F-9856-4A671202DDCC}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {FA7E6914-8070-438F-9856-4A671202DDCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {FA7E6914-8070-438F-9856-4A671202DDCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {FA7E6914-8070-438F-9856-4A671202DDCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {FA7E6914-8070-438F-9856-4A671202DDCC}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {F8052E10-658C-4CDF-9679-29ACE4C4A794}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/SharpShot/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/SharpShot/GDI32.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SharpShot
9 | {
10 | public static class GDI32
11 | {
12 | public const int SRCCOPY = 0x00CC0020; // BitBlt dwRop parameter
13 | [DllImport("gdi32.dll")]
14 | public static extern bool BitBlt(IntPtr hObject, int nXDest, int nYDest,
15 | int nWidth, int nHeight, IntPtr hObjectSource,
16 | int nXSrc, int nYSrc, int dwRop);
17 | [DllImport("gdi32.dll")]
18 | public static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth,
19 | int nHeight);
20 | [DllImport("gdi32.dll")]
21 | public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
22 | [DllImport("gdi32.dll")]
23 | public static extern bool DeleteDC(IntPtr hDC);
24 | [DllImport("gdi32.dll")]
25 | public static extern bool DeleteObject(IntPtr hObject);
26 | [DllImport("gdi32.dll")]
27 | public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/SharpShot/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using System.Drawing;
4 | using System.Windows.Forms;
5 | using System.Collections.Generic;
6 | using System.IO;
7 |
8 | namespace SharpShot
9 | {
10 | class Program
11 | {
12 | static void Main(string[] args)
13 | {
14 | printHeader();
15 | //parse the args into commands.
16 | var arguments = new Dictionary();
17 | foreach(var argument in args)
18 | {
19 | var idx = argument.IndexOf(':');
20 | if(idx > 0)
21 | {
22 | arguments[argument.Substring(0, idx).Remove(0,1)] = argument.Substring(idx + 1);
23 | }
24 | else
25 | {
26 | arguments[argument.Remove(0,1)] = string.Empty;
27 | }
28 | }
29 |
30 | if (arguments.ContainsKey("help"))
31 | {
32 | printUsage();
33 | return;
34 | }
35 | //
36 | if (arguments["outformat"] == "img")
37 | {
38 | if (!arguments.ContainsKey("outfolder"))
39 | {
40 | Console.WriteLine("[*] /outfolder is required when outputting as an image!");
41 | return;
42 | }
43 |
44 | try
45 | {
46 | var fileName = Path.GetRandomFileName();
47 | var filePath = arguments["outfolder"] + "\\" + fileName;
48 | if (arguments.ContainsKey("native"))
49 | {
50 | Console.WriteLine("[*] Taking Screenshot using Windows API...");
51 | var image = CaptureWindow(User32.GetDesktopWindow());
52 | image.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
53 | }
54 | else
55 | {
56 | Console.WriteLine("[*] Taking screenshot using .NET...");
57 | var image = CaptureWindowCLR();
58 | image.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
59 | }
60 | Console.WriteLine("[*] Screenshot saved to " + filePath);
61 | }
62 | catch (Exception)
63 | {
64 | Console.WriteLine("[*] Exception when taking screenshot!");
65 | }
66 |
67 | return;
68 | }
69 | else if (arguments["outformat"] == "base64")
70 | {
71 | Console.WriteLine("[*] Base64 selected...");
72 | try
73 | {
74 | if (arguments.ContainsKey("native"))
75 | {
76 | Console.WriteLine("[*] Taking screenshot using Windows API...");
77 | var image = CaptureWindow(User32.GetDesktopWindow());
78 | var base64 = GetCompressedImage(image);
79 | Console.WriteLine(base64);
80 | }
81 | else
82 | {
83 | Console.WriteLine("[*] Taking screenshot using .NET...");
84 | var bitmap = CaptureWindowCLR();
85 | var base64 = GetCompressedImage(bitmap);
86 | Console.WriteLine(base64);
87 | }
88 | }
89 | catch (Exception)
90 | {
91 | Console.WriteLine("[*] Exception when taking screenshot!");
92 | }
93 | Console.WriteLine("[*] Decode to recover image.");
94 | return;
95 | }
96 | else
97 | {
98 | printUsage();
99 | return;
100 | }
101 |
102 | }
103 |
104 | private static string GetCompressedImage(Image image)
105 | {
106 | using (var stream = new MemoryStream())
107 | {
108 | image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
109 | var bytes = stream.ToArray();
110 | var base64 = Convert.ToBase64String(bytes);
111 | return base64;
112 | }
113 | }
114 |
115 | private static Bitmap CaptureWindowCLR()
116 | {
117 | var bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
118 | using (Graphics g = Graphics.FromImage(bmp))
119 | {
120 | g.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size);
121 | return bmp;
122 | }
123 | }
124 |
125 |
126 |
127 |
128 | private static Image CaptureWindow(IntPtr handle)
129 | {
130 | //get the hDC of the target window
131 | IntPtr hdcSrc = User32.GetWindowDC(handle);
132 | //calculate the size
133 | User32.RECT windowRECT = new User32.RECT();
134 | User32.GetWindowRect(handle, ref windowRECT);
135 | int width = windowRECT.right - windowRECT.left;
136 | int height = windowRECT.bottom - windowRECT.top;
137 |
138 | //create the device context
139 | IntPtr hdcDest = GDI32.CreateCompatibleDC(hdcSrc);
140 | //create a bitmap
141 | IntPtr hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc, width, height);
142 | IntPtr hOld = GDI32.SelectObject(hdcDest, hBitmap);
143 | GDI32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, GDI32.SRCCOPY);
144 |
145 | GDI32.SelectObject(hdcDest, hOld);
146 |
147 | //Create a .NET bitmap we can use elsehwere
148 | var img = Image.FromHbitmap(hBitmap);
149 |
150 | //clean up
151 | GDI32.DeleteDC(hdcDest);
152 | User32.ReleaseDC(handle, hdcSrc);
153 | GDI32.DeleteObject(hBitmap);
154 |
155 | return img;
156 | }
157 |
158 | private static void printHeader()
159 | {
160 | Console.WriteLine(@" _____ _ _____ _ _ ");
161 | Console.WriteLine(@"/ ___| | / ___| | | | ");
162 | Console.WriteLine(@"\ `--.| |__ __ _ _ __ _ __ \ `--.| |__ ___ | |_ ");
163 | Console.WriteLine(@" `--. \ '_ \ / _` | '__| '_ \ `--. \ '_ \ / _ \| __|");
164 | Console.WriteLine(@"/\__/ / | | | (_| | | | |_) /\__/ / | | | (_) | |_ ");
165 | Console.WriteLine(@"\____/|_| |_|\__,_|_| | .__/\____/|_| |_|\___/ \__|");
166 | Console.WriteLine(@" | | ");
167 | Console.WriteLine(@" |_| ");
168 | Console.WriteLine("");
169 | Console.WriteLine("By @two06");
170 | Console.WriteLine("");
171 | Console.WriteLine("run SharpShot.exe /help for usage instructions");
172 | }
173 |
174 | private static void printUsage()
175 | {
176 | Console.WriteLine("Capture a full window screenshot using the Windows API and save to disk:");
177 | Console.WriteLine(@" SharpShot.exe /outfolder:c:\windows\temp /outformat:img /native");
178 | Console.WriteLine("");
179 | Console.WriteLine("Capture a full window screenshot using .NET methods and save to disk:");
180 | Console.WriteLine(@" SharpShot.exe /outfolder:c:\windows\temp /outformat:img");
181 | Console.WriteLine("");
182 | Console.WriteLine("Capture a full window screenshot using the Windows API and write to the console as base64:");
183 | Console.WriteLine(@" SharpShot.exe /outformat:base64 /native");
184 | Console.WriteLine("");
185 | Console.WriteLine("Capture a full window screenshot using .NET methods and write to the console as base64:");
186 | Console.WriteLine(@" SharpShot.exe /outformat:base64");
187 | }
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/SharpShot/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SharpShot")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SharpShot")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("fa7e6914-8070-438f-9856-4a671202ddcc")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/SharpShot/SharpShot.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {FA7E6914-8070-438F-9856-4A671202DDCC}
8 | Exe
9 | SharpShot
10 | SharpShot
11 | v4.6.1
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/SharpShot/User32.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SharpShot
9 | {
10 | public static class User32
11 | {
12 | [StructLayout(LayoutKind.Sequential)]
13 | public struct RECT
14 | {
15 | public int left;
16 | public int top;
17 | public int right;
18 | public int bottom;
19 | }
20 | [DllImport("user32.dll")]
21 | public static extern IntPtr GetDesktopWindow();
22 | [DllImport("user32.dll")]
23 | public static extern IntPtr GetWindowDC(IntPtr hWnd);
24 | [DllImport("user32.dll")]
25 | public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC);
26 | [DllImport("user32.dll")]
27 | public static extern IntPtr GetWindowRect(IntPtr hWnd, ref RECT rect);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------