Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for printwindow.cs

(view source code of printwindow.cs as plain text)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Drawing;
  5. using System.Drawing.Imaging;
  6. using System.IO;
  7. using System.Runtime.InteropServices;
  8. using System.Text.RegularExpressions;
  9.  
  10.  
  11. namespace RobvanderWoude
  12. {
  13. 	class PrintWindow
  14. 	{
  15. 		static readonly string progver = "1.01";
  16.  
  17.  
  18. 		static bool debug = false;
  19. 		static string matchingtitle = string.Empty;
  20.  
  21.  
  22. 		static int Main( string[] args )
  23. 		{
  24. 			string windowtitle = string.Empty;
  25. 			string outputfile = string.Empty;
  26. 			string exact = "partial ";
  27. 			bool exacttitle = false;
  28. 			bool openscreenshot = false;
  29. 			int correctionBottom = 0;
  30. 			int correctionLeft = 0;
  31. 			int correctionRight = 0;
  32. 			int correctionTop = 0;
  33.  
  34.  
  35. 			#region Parse and Validate Command Line
  36.  
  37. 			foreach ( string arg in args )
  38. 			{
  39. 				if ( arg[0] == '/' )
  40. 				{
  41. 					switch ( arg.ToUpper( ) )
  42. 					{
  43. 						case "/?":
  44. 							return ShowHelp( );
  45. 						case "/D":
  46. 						case "/DEBUG":
  47. 							if ( debug )
  48. 							{
  49. 								return ShowHelp( "Duplicate switch /D" );
  50. 							}
  51. 							debug = true;
  52. 							break;
  53. 						case "/O":
  54. 						case "/OPEN":
  55. 							if ( openscreenshot )
  56. 							{
  57. 								return ShowHelp( "Duplicate switch /O" );
  58. 							}
  59. 							openscreenshot = true;
  60. 							break;
  61. 						case "/X":
  62. 						case "/EXACT":
  63. 							if ( exacttitle )
  64. 							{
  65. 								return ShowHelp( "Duplicate switch /X" );
  66. 							}
  67. 							exacttitle = true;
  68. 							exact = "exact ";
  69. 							break;
  70. 						default:
  71. 							if ( arg.ToUpper( ).Substring( 0, 3 ) == "/C:" )
  72. 							{
  73. 								if ( correctionBottom != 0 || correctionLeft != 0 || correctionRight != 0 || correctionTop != 0 )
  74. 								{
  75. 									return ShowHelp( "Duplicate switch /C" );
  76. 								}
  77. 								string pattern = @"""?-?\d+,-?\d+,-?\d+,-?\d+""?";
  78. 								Regex regex = new Regex( pattern );
  79. 								if ( regex.IsMatch( arg.ToUpper( ).Substring( 3, arg.Length - 3 ) ) )
  80. 								{
  81. 									string[] corrections = arg.Substring( 3 ).Replace( "\"", "" ).Split( ",".ToCharArray( ) );
  82. 									if ( !Int32.TryParse( corrections[0], out correctionTop ) || !Int32.TryParse( corrections[1], out correctionRight ) || !Int32.TryParse( corrections[2], out correctionBottom ) || !Int32.TryParse( corrections[3], out correctionLeft ) )
  83. 									{
  84. 										return ShowHelp( "Invalid values for /C switch" );
  85. 									}
  86. 								}
  87. 								else
  88. 								{
  89. 									return ShowHelp( "Invalid values for /C switch" );
  90. 								}
  91. 								break;
  92. 							}
  93. 							else
  94. 							{
  95. 								return ShowHelp( "Invalid switch \"{0}\"", arg );
  96. 							}
  97. 					}
  98. 				}
  99. 				else
  100. 				{
  101. 					if ( string.IsNullOrWhiteSpace( windowtitle ) )
  102. 					{
  103. 						// First unnamed argument is title
  104. 						windowtitle = arg;
  105. 					}
  106. 					else if ( string.IsNullOrWhiteSpace( outputfile ) )
  107. 					{
  108. 						// Second unnamed argument is output file
  109. 						outputfile = arg;
  110. 					}
  111. 					else
  112. 					{
  113. 						// No third unnamed argument allowed
  114. 						return ShowHelp( "Invalid unnamed argument \"{0}\"", arg );
  115. 					}
  116. 				}
  117. 			}
  118.  
  119. 			if ( string.IsNullOrWhiteSpace( outputfile ) )
  120. 			{
  121. 				return ShowHelp( "Please specify an output file" );
  122. 			}
  123.  
  124. 			if ( !Directory.Exists( Directory.GetParent( outputfile ).FullName ) )
  125. 			{
  126. 				return ShowHelp( "Parent folder of specified output file not found" );
  127. 			}
  128.  
  129. #if DEBUG
  130. 			debug = true;
  131. #endif
  132.  
  133.  
  134. 			#endregion Parse and validate Command Line
  135.  
  136.  
  137. 			// Delete the specified output file if it already exists
  138. 			if ( File.Exists( outputfile ) )
  139. 			{
  140. 				File.Delete( outputfile );
  141. 			}
  142.  
  143. 			// Find the window with the specified title
  144. 			IntPtr handle = FindWindow( windowtitle, exacttitle );
  145. 			if ( handle == IntPtr.Zero )
  146. 			{
  147. 				return ShowHelp( "No window was found with {0}title \"{1}\"", exact, windowtitle );
  148. 			}
  149. 			else
  150. 			{
  151. 				if ( debug && !exacttitle )
  152. 				{
  153. 					Console.WriteLine( "Specified title : \"{0}\"\nMatching title  : \"{1}\"\n", windowtitle, matchingtitle );
  154. 				}
  155. 				// If found, make it the foreground window
  156. 				if ( SetForegroundWindow( handle ) )
  157. 				{
  158. 					// First find the required correction values for the GetWindowRect function
  159. 					// Get a single system metric value
  160. 					int rectXcorrection = 8;
  161. 					int rectYcorrection = 8;
  162. 					rectXcorrection = GetSystemMetricByName( "SM_CXFRAME", rectXcorrection );
  163. 					rectYcorrection = GetSystemMetricByName( "SM_CYFRAME", rectYcorrection );
  164. 					if ( debug )
  165. 					{
  166. 						Console.WriteLine( "Window size correction X,Y: {0},{1}", rectXcorrection, rectYcorrection );
  167. 					}
  168.  
  169.  
  170. 					// Get the window position and size
  171. 					SetProcessDPIAware( );
  172. 					GetWindowRect( handle, out Rectangle rect );
  173. 					// Returned coordinates of lower right window corner relative to upper left corner of
  174. 					// screen, so subtract coordinates of upper left window corner to get width and height
  175. 					rect.Width -= rect.X - 2 - correctionRight + correctionLeft;
  176. 					rect.Height -= rect.Y - 1 - correctionBottom + correctionTop;
  177. 					rect.X += correctionLeft;
  178. 					rect.Y += correctionTop;
  179.  
  180. 					if ( debug )
  181. 					{
  182. 						Console.WriteLine( "X = {0}\nY = {1}\nWidth = {2}\nHeight = {3}\n", rect.X, rect.Y, rect.Width, rect.Height );
  183. 					}
  184.  
  185. 					// Subtract another 16 to correct for an error in Windows 7 and later
  186. 					//rect.Width -= 16;
  187. 					rect.Width -= 2 * rectXcorrection;
  188. 					// Likewise for Height, though Y of upper left window corner is correct so we only need to correct by 8 instead of 16
  189. 					//rect.Height -= 8;
  190. 					rect.Height -= rectYcorrection;
  191.  
  192. 					if ( debug )
  193. 					{
  194. 						Console.WriteLine( "X = {0}\nY = {1}\nWidth = {2}\nHeight = {3}\n", rect.X, rect.Y, rect.Width, rect.Height );
  195. 					}
  196.  
  197. 					// Based on code by Ali Hamdar (http://alihamdar.com/)
  198. 					// http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/79efecc4-fa6d-4078-afe4-bb1379bb968b
  199. 					using ( Bitmap printscreen = new Bitmap( rect.Width, rect.Height ) )
  200. 					{
  201. 						Graphics graphics = Graphics.FromImage( (Image) printscreen );
  202. 						if ( debug )
  203. 						{
  204. 							Console.WriteLine( "graphics.CopyFromScreen( {0}, {1}, {2}, {3}, {4} )", rect.X, rect.Y, 0, 0, printscreen.Size );
  205. 						}
  206. 						// Real Width is measured Width - 2 * rectXcorrection, shift X of left window position by rectXcorrection
  207. 						graphics.CopyFromScreen( rect.X + rectXcorrection - 1, rect.Y, 0, 0, printscreen.Size );
  208. 						printscreen.Save( outputfile, ImageFormat.Jpeg );
  209. 					}
  210.  
  211. 					if ( debug || openscreenshot )
  212. 					{
  213. 						Process.Start( outputfile );
  214. 					}
  215. 				}
  216. 				else
  217. 				{
  218. 					return ShowHelp( "Unable to move the specified window to the foreground" );
  219. 				}
  220. 			}
  221.  
  222. 			return 0;
  223. 		}
  224.  
  225.  
  226. 		static IntPtr FindWindow( string title, bool exacttitlematch = false )
  227. 		{
  228. 			foreach ( Process process in Process.GetProcesses( ) )
  229. 			{
  230. 				if ( process.MainWindowTitle.Equals( title ) )
  231. 				{
  232. 					return process.MainWindowHandle; // Return the FIRST matching window
  233. 				}
  234. 				else if ( !exacttitlematch )
  235. 				{
  236. 					if ( process.MainWindowTitle.Contains( title ) )
  237. 					{
  238. 						matchingtitle = process.MainWindowTitle;
  239. 						return process.MainWindowHandle; // Return the FIRST matching window
  240. 					}
  241. 				}
  242. 			}
  243. 			return IntPtr.Zero; // In case no matching title was found
  244. 		}
  245.  
  246.  
  247. 		static int GetSystemMetricByName( string systemmetricname, int defaultvalue = 0 )
  248. 		{
  249. 			int systemmetricvalue = defaultvalue;
  250. 			if ( Enum.TryParse<SystemMetric>( systemmetricname, true, out SystemMetric systemmetric ) )
  251. 			{
  252. 				systemmetricvalue = GetSystemMetrics( systemmetric );
  253. 			}
  254. 			return systemmetricvalue;
  255. 		}
  256.  
  257.  
  258. 		#region DLL Imports
  259.  
  260. 		[DllImport( "user32.dll" )]
  261. 		private static extern bool SetProcessDPIAware( );
  262.  
  263.  
  264. 		[DllImport( "user32.dll", SetLastError = true )]
  265. 		[return: MarshalAs( UnmanagedType.Bool )]
  266. 		//static extern bool GetWindowRect( HandleRef hWnd, out Rectangle lpRect );
  267. 		static extern bool GetWindowRect( IntPtr hWnd, out Rectangle lpRect );
  268.  
  269.  
  270. 		[DllImport( "user32.dll" )]
  271. 		[return: MarshalAs( UnmanagedType.Bool )]
  272. 		static extern bool SetForegroundWindow( IntPtr hWnd );
  273.  
  274. 		[DllImport( "user32.dll" )]
  275. 		static extern int GetSystemMetrics( SystemMetric smIndex );
  276.  
  277. 		#endregion DLL Imports
  278.  
  279.  
  280. 		#region Error handling
  281.  
  282. 		static int ShowHelp( params string[] errmsg )
  283. 		{
  284. 			#region Error Message
  285.  
  286. 			if ( errmsg.Length > 0 )
  287. 			{
  288. 				List<string> errargs = new List<string>( errmsg );
  289. 				errargs.RemoveAt( 0 );
  290. 				Console.Error.WriteLine( );
  291. 				Console.ForegroundColor = ConsoleColor.Red;
  292. 				Console.Error.Write( "ERROR:\t" );
  293. 				Console.ForegroundColor = ConsoleColor.White;
  294. 				Console.Error.WriteLine( errmsg[0], errargs.ToArray( ) );
  295. 				Console.ResetColor( );
  296. 			}
  297.  
  298. 			#endregion Error Message
  299.  
  300.  
  301. 			#region Help Text
  302.  
  303. 			/*
  304. 			PrintWindow.exe,  Version 1.01
  305. 			Take a screenshot of the specified window
  306.  
  307. 			Usage:   PrintWindow.exe  title  outputfile  [ options ]
  308.  
  309. 			Where:   title         is the window title
  310. 			         outputfile    is the file to contain the screenshot
  311.  
  312. 			Options: /C:"T,R,B,L"  Correct screenshot dimensions for Top, Right,
  313. 			                       Bottom, Left in pixels, e.g. /C:"-1,1,1,-1" to
  314. 			                       add 1 pixel at each side (note the minus sign)
  315. 			         /D            Debug mode: show the screen coordinates used
  316. 			         /O            Open the resulting output file (implied with /D)
  317. 			         /X            window title and specified title must match eXactly
  318. 			                       (default: window title contains specified title)
  319.  
  320. 			Credits: Get window position and size
  321. 			         https://stackoverflow.com/a/1434577
  322. 			         Screenshot based on code by Ali Hamdar (http://alihamdar.com/)
  323. 			         http://social.msdn.microsoft.com/Forums/en/csharpgeneral
  324. 			         /thread/79efecc4-fa6d-4078-afe4-bb1379bb968b
  325. 			         SystemMetric enumeration published by Gabriel T. Sharp on PInvoke.net
  326. 			         http://pinvoke.net/default.aspx/Enums/SystemMetric.html
  327.  
  328. 			Note:    Return code -1 in case of errors, otherwise 0.
  329.  
  330. 			Written by Rob van der Woude
  331. 			https://www.robvanderwoude.com
  332. 			*/
  333.  
  334. 			#endregion Help Text
  335.  
  336.  
  337. 			#region Display Help Text
  338.  
  339. 			Console.Error.WriteLine( );
  340.  
  341. 			Console.Error.WriteLine( "PrintWindow.exe,  Version {0}", progver );
  342.  
  343. 			Console.Error.WriteLine( "Take a screenshot of the specified window" );
  344.  
  345. 			Console.Error.WriteLine( );
  346.  
  347. 			Console.Error.Write( "Usage:   " );
  348. 			Console.ForegroundColor = ConsoleColor.White;
  349. 			Console.Error.WriteLine( "PrintWindow.exe  title  outputfile  [ options ]" );
  350. 			Console.ResetColor( );
  351.  
  352. 			Console.Error.WriteLine( );
  353.  
  354. 			Console.Write( "Where:   " );
  355. 			Console.ForegroundColor = ConsoleColor.White;
  356. 			Console.Write( "title         " );
  357. 			Console.ResetColor( );
  358. 			Console.WriteLine( "is the window title" );
  359.  
  360. 			Console.ForegroundColor = ConsoleColor.White;
  361. 			Console.Write( "         outputfile    " );
  362. 			Console.ResetColor( );
  363. 			Console.WriteLine( "is the file to contain the screenshot" );
  364.  
  365. 			Console.Error.WriteLine( );
  366.  
  367. 			Console.Error.Write( "Options: " );
  368. 			Console.ForegroundColor = ConsoleColor.White;
  369. 			Console.Error.Write( "/C:\"T,R,B,L\"  C" );
  370. 			Console.ResetColor( );
  371. 			Console.Error.Write( "orrect screenshot dimensions for " );
  372. 			Console.ForegroundColor = ConsoleColor.White;
  373. 			Console.Error.Write( "T" );
  374. 			Console.ResetColor( );
  375. 			Console.Error.Write( "op, " );
  376. 			Console.ForegroundColor = ConsoleColor.White;
  377. 			Console.Error.Write( "R" );
  378. 			Console.ResetColor( );
  379. 			Console.Error.WriteLine( "ight," );
  380.  
  381. 			Console.ForegroundColor = ConsoleColor.White;
  382. 			Console.Error.Write( "                       B" );
  383. 			Console.ResetColor( );
  384. 			Console.Error.Write( "ottom, " );
  385. 			Console.ForegroundColor = ConsoleColor.White;
  386. 			Console.Error.Write( "L" );
  387. 			Console.ResetColor( );
  388. 			Console.Error.Write( "eft in pixels, e.g. " );
  389. 			Console.ForegroundColor = ConsoleColor.White;
  390. 			Console.Error.Write( "/C:\"-1,1,1,-1\" " );
  391. 			Console.ResetColor( );
  392. 			Console.Error.WriteLine( "to" );
  393.  
  394. 			Console.Error.WriteLine( "                       add 1 pixel at each side (note the minus sign)" );
  395.  
  396. 			Console.ForegroundColor = ConsoleColor.White;
  397. 			Console.Error.Write( "         /D            D" );
  398. 			Console.ResetColor( );
  399. 			Console.Error.WriteLine( "ebug mode: show the screen coordinates used" );
  400.  
  401. 			Console.ForegroundColor = ConsoleColor.White;
  402. 			Console.Error.Write( "         /O            O" );
  403. 			Console.ResetColor( );
  404. 			Console.Error.Write( "pen the resulting output file (implied with " );
  405. 			Console.ForegroundColor = ConsoleColor.White;
  406. 			Console.Error.Write( "/D" );
  407. 			Console.ResetColor( );
  408. 			Console.Error.WriteLine( ")" );
  409.  
  410. 			Console.ForegroundColor = ConsoleColor.White;
  411. 			Console.Error.Write( "         /X            " );
  412. 			Console.ResetColor( );
  413. 			Console.Error.Write( "window title and specified title must match e" );
  414. 			Console.ForegroundColor = ConsoleColor.White;
  415. 			Console.Error.Write( "X" );
  416. 			Console.ResetColor( );
  417. 			Console.Error.WriteLine( "actly" );
  418.  
  419. 			Console.Error.Write( "                       (default: window title " );
  420. 			Console.ForegroundColor = ConsoleColor.White;
  421. 			Console.Error.Write( "contains " );
  422. 			Console.ResetColor( );
  423. 			Console.Error.WriteLine( "specified title)" );
  424.  
  425. 			Console.Error.WriteLine( );
  426.  
  427. 			Console.Error.WriteLine( "Credits: Get window position and size" );
  428.  
  429. 			Console.ForegroundColor = ConsoleColor.DarkGray;
  430. 			Console.Error.WriteLine( "         https://stackoverflow.com/a/1434577" );
  431. 			Console.ResetColor( );
  432.  
  433. 			Console.Error.Write( "         Screenshot based on code by Ali Hamdar (" );
  434. 			Console.ForegroundColor = ConsoleColor.DarkGray;
  435. 			Console.Error.Write( "http://alihamdar.com/" );
  436. 			Console.ResetColor( );
  437. 			Console.Error.WriteLine( ")" );
  438.  
  439. 			Console.ForegroundColor = ConsoleColor.DarkGray;
  440. 			Console.Error.WriteLine( "         http://social.msdn.microsoft.com/Forums/en/csharpgeneral" );
  441.  
  442. 			Console.Error.WriteLine( "         /thread/79efecc4-fa6d-4078-afe4-bb1379bb968b" );
  443. 			Console.ResetColor( );
  444.  
  445. 			Console.Error.WriteLine( "         SystemMetric enumeration published by Gabriel T. Sharp on PInvoke.net" );
  446.  
  447. 			Console.ForegroundColor = ConsoleColor.DarkGray;
  448. 			Console.Error.WriteLine( "         http://pinvoke.net/default.aspx/Enums/SystemMetric.html" );
  449. 			Console.ResetColor( );
  450.  
  451. 			Console.Error.WriteLine( );
  452.  
  453. 			Console.Error.WriteLine( "Note:    Return code -1 in case of errors, otherwise 0." );
  454.  
  455. 			Console.Error.WriteLine( );
  456.  
  457. 			Console.Error.WriteLine( "Written by Rob van der Woude" );
  458.  
  459. 			Console.Error.WriteLine( "https://www.robvanderwoude.com" );
  460.  
  461. 			#endregion Display Help Text
  462.  
  463.  
  464. 			return -1;
  465. 		}
  466.  
  467. 		#endregion Error handling
  468.  
  469.  
  470. 		/// <summary>
  471. 		/// Flags used with the Windows API (User32.dll):GetSystemMetrics(SystemMetric smIndex)
  472. 		///  
  473. 		/// This Enum and declaration signature was written by Gabriel T. Sharp
  474. 		/// ai_productions@verizon.net or osirisgothra@hotmail.com
  475. 		/// Obtained on pinvoke.net, please contribute your code to support the wiki!
  476. 		/// </summary>
  477. 		public enum SystemMetric : int
  478. 		{
  479. 			/// <summary>
  480. 			/// The flags that specify how the system arranged minimized windows. For more information, see the Remarks section in this topic.
  481. 			/// </summary>
  482. 			SM_ARRANGE = 56,
  483.  
  484. 			/// <summary>
  485. 			/// The value that specifies how the system is started:
  486. 			/// 0 Normal boot
  487. 			/// 1 Fail-safe boot
  488. 			/// 2 Fail-safe with network boot
  489. 			/// A fail-safe boot (also called SafeBoot, Safe Mode, or Clean Boot) bypasses the user startup files.
  490. 			/// </summary>
  491. 			SM_CLEANBOOT = 67,
  492.  
  493. 			/// <summary>
  494. 			/// The number of display monitors on a desktop. For more information, see the Remarks section in this topic.
  495. 			/// </summary>
  496. 			SM_CMONITORS = 80,
  497.  
  498. 			/// <summary>
  499. 			/// The number of buttons on a mouse, or zero if no mouse is installed.
  500. 			/// </summary>
  501. 			SM_CMOUSEBUTTONS = 43,
  502.  
  503. 			/// <summary>
  504. 			/// The width of a window border, in pixels. This is equivalent to the SM_CXEDGE value for windows with the 3-D look.
  505. 			/// </summary>
  506. 			SM_CXBORDER = 5,
  507.  
  508. 			/// <summary>
  509. 			/// The width of a cursor, in pixels. The system cannot create cursors of other sizes.
  510. 			/// </summary>
  511. 			SM_CXCURSOR = 13,
  512.  
  513. 			/// <summary>
  514. 			/// This value is the same as SM_CXFIXEDFRAME.
  515. 			/// </summary>
  516. 			SM_CXDLGFRAME = 7,
  517.  
  518. 			/// <summary>
  519. 			/// The width of the rectangle around the location of a first click in a double-click sequence, in pixels. ,
  520. 			/// The second click must occur within the rectangle that is defined by SM_CXDOUBLECLK and SM_CYDOUBLECLK for the system
  521. 			/// to consider the two clicks a double-click. The two clicks must also occur within a specified time.
  522. 			/// To set the width of the double-click rectangle, call SystemParametersInfo with SPI_SETDOUBLECLKWIDTH.
  523. 			/// </summary>
  524. 			SM_CXDOUBLECLK = 36,
  525.  
  526. 			/// <summary>
  527. 			/// The number of pixels on either side of a mouse-down point that the mouse pointer can move before a drag operation begins.
  528. 			/// This allows the user to click and release the mouse button easily without unintentionally starting a drag operation.
  529. 			/// If this value is negative, it is subtracted from the left of the mouse-down point and added to the right of it.
  530. 			/// </summary>
  531. 			SM_CXDRAG = 68,
  532.  
  533. 			/// <summary>
  534. 			/// The width of a 3-D border, in pixels. This metric is the 3-D counterpart of SM_CXBORDER.
  535. 			/// </summary>
  536. 			SM_CXEDGE = 45,
  537.  
  538. 			/// <summary>
  539. 			/// The thickness of the frame around the perimeter of a window that has a caption but is not sizable, in pixels.
  540. 			/// SM_CXFIXEDFRAME is the height of the horizontal border, and SM_CYFIXEDFRAME is the width of the vertical border.
  541. 			/// This value is the same as SM_CXDLGFRAME.
  542. 			/// </summary>
  543. 			SM_CXFIXEDFRAME = 7,
  544.  
  545. 			/// <summary>
  546. 			/// The width of the left and right edges of the focus rectangle that the DrawFocusRectdraws.
  547. 			/// This value is in pixels.
  548. 			/// Windows 2000:  This value is not supported.
  549. 			/// </summary>
  550. 			SM_CXFOCUSBORDER = 83,
  551.  
  552. 			/// <summary>
  553. 			/// This value is the same as SM_CXSIZEFRAME.
  554. 			/// </summary>
  555. 			SM_CXFRAME = 32,
  556.  
  557. 			/// <summary>
  558. 			/// The width of the client area for a full-screen window on the primary display monitor, in pixels.
  559. 			/// To get the coordinates of the portion of the screen that is not obscured by the system taskbar or by application desktop toolbars,
  560. 			/// call the SystemParametersInfofunction with the SPI_GETWORKAREA value.
  561. 			/// </summary>
  562. 			SM_CXFULLSCREEN = 16,
  563.  
  564. 			/// <summary>
  565. 			/// The width of the arrow bitmap on a horizontal scroll bar, in pixels.
  566. 			/// </summary>
  567. 			SM_CXHSCROLL = 21,
  568.  
  569. 			/// <summary>
  570. 			/// The width of the thumb box in a horizontal scroll bar, in pixels.
  571. 			/// </summary>
  572. 			SM_CXHTHUMB = 10,
  573.  
  574. 			/// <summary>
  575. 			/// The default width of an icon, in pixels. The LoadIcon function can load only icons with the dimensions
  576. 			/// that SM_CXICON and SM_CYICON specifies.
  577. 			/// </summary>
  578. 			SM_CXICON = 11,
  579.  
  580. 			/// <summary>
  581. 			/// The width of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of size
  582. 			/// SM_CXICONSPACING by SM_CYICONSPACING when arranged. This value is always greater than or equal to SM_CXICON.
  583. 			/// </summary>
  584. 			SM_CXICONSPACING = 38,
  585.  
  586. 			/// <summary>
  587. 			/// The default width, in pixels, of a maximized top-level window on the primary display monitor.
  588. 			/// </summary>
  589. 			SM_CXMAXIMIZED = 61,
  590.  
  591. 			/// <summary>
  592. 			/// The default maximum width of a window that has a caption and sizing borders, in pixels.
  593. 			/// This metric refers to the entire desktop. The user cannot drag the window frame to a size larger than these dimensions.
  594. 			/// A window can override this value by processing the WM_GETMINMAXINFO message.
  595. 			/// </summary>
  596. 			SM_CXMAXTRACK = 59,
  597.  
  598. 			/// <summary>
  599. 			/// The width of the default menu check-mark bitmap, in pixels.
  600. 			/// </summary>
  601. 			SM_CXMENUCHECK = 71,
  602.  
  603. 			/// <summary>
  604. 			/// The width of menu bar buttons, such as the child window close button that is used in the multiple document interface, in pixels.
  605. 			/// </summary>
  606. 			SM_CXMENUSIZE = 54,
  607.  
  608. 			/// <summary>
  609. 			/// The minimum width of a window, in pixels.
  610. 			/// </summary>
  611. 			SM_CXMIN = 28,
  612.  
  613. 			/// <summary>
  614. 			/// The width of a minimized window, in pixels.
  615. 			/// </summary>
  616. 			SM_CXMINIMIZED = 57,
  617.  
  618. 			/// <summary>
  619. 			/// The width of a grid cell for a minimized window, in pixels. Each minimized window fits into a rectangle this size when arranged.
  620. 			/// This value is always greater than or equal to SM_CXMINIMIZED.
  621. 			/// </summary>
  622. 			SM_CXMINSPACING = 47,
  623.  
  624. 			/// <summary>
  625. 			/// The minimum tracking width of a window, in pixels. The user cannot drag the window frame to a size smaller than these dimensions.
  626. 			/// A window can override this value by processing the WM_GETMINMAXINFO message.
  627. 			/// </summary>
  628. 			SM_CXMINTRACK = 34,
  629.  
  630. 			/// <summary>
  631. 			/// The amount of border padding for captioned windows, in pixels. Windows XP/2000:  This value is not supported.
  632. 			/// </summary>
  633. 			SM_CXPADDEDBORDER = 92,
  634.  
  635. 			/// <summary>
  636. 			/// The width of the screen of the primary display monitor, in pixels. This is the same value obtained by calling 
  637. 			/// GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, HORZRES).
  638. 			/// </summary>
  639. 			SM_CXSCREEN = 0,
  640.  
  641. 			/// <summary>
  642. 			/// The width of a button in a window caption or title bar, in pixels.
  643. 			/// </summary>
  644. 			SM_CXSIZE = 30,
  645.  
  646. 			/// <summary>
  647. 			/// The thickness of the sizing border around the perimeter of a window that can be resized, in pixels.
  648. 			/// SM_CXSIZEFRAME is the width of the horizontal border, and SM_CYSIZEFRAME is the height of the vertical border.
  649. 			/// This value is the same as SM_CXFRAME.
  650. 			/// </summary>
  651. 			SM_CXSIZEFRAME = 32,
  652.  
  653. 			/// <summary>
  654. 			/// The recommended width of a small icon, in pixels. Small icons typically appear in window captions and in small icon view.
  655. 			/// </summary>
  656. 			SM_CXSMICON = 49,
  657.  
  658. 			/// <summary>
  659. 			/// The width of small caption buttons, in pixels.
  660. 			/// </summary>
  661. 			SM_CXSMSIZE = 52,
  662.  
  663. 			/// <summary>
  664. 			/// The width of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors.
  665. 			/// The SM_XVIRTUALSCREEN metric is the coordinates for the left side of the virtual screen.
  666. 			/// </summary>
  667. 			SM_CXVIRTUALSCREEN = 78,
  668.  
  669. 			/// <summary>
  670. 			/// The width of a vertical scroll bar, in pixels.
  671. 			/// </summary>
  672. 			SM_CXVSCROLL = 2,
  673.  
  674. 			/// <summary>
  675. 			/// The height of a window border, in pixels. This is equivalent to the SM_CYEDGE value for windows with the 3-D look.
  676. 			/// </summary>
  677. 			SM_CYBORDER = 6,
  678.  
  679. 			/// <summary>
  680. 			/// The height of a caption area, in pixels.
  681. 			/// </summary>
  682. 			SM_CYCAPTION = 4,
  683.  
  684. 			/// <summary>
  685. 			/// The height of a cursor, in pixels. The system cannot create cursors of other sizes.
  686. 			/// </summary>
  687. 			SM_CYCURSOR = 14,
  688.  
  689. 			/// <summary>
  690. 			/// This value is the same as SM_CYFIXEDFRAME.
  691. 			/// </summary>
  692. 			SM_CYDLGFRAME = 8,
  693.  
  694. 			/// <summary>
  695. 			/// The height of the rectangle around the location of a first click in a double-click sequence, in pixels.
  696. 			/// The second click must occur within the rectangle defined by SM_CXDOUBLECLK and SM_CYDOUBLECLK for the system to consider
  697. 			/// the two clicks a double-click. The two clicks must also occur within a specified time. To set the height of the double-click
  698. 			/// rectangle, call SystemParametersInfo with SPI_SETDOUBLECLKHEIGHT.
  699. 			/// </summary>
  700. 			SM_CYDOUBLECLK = 37,
  701.  
  702. 			/// <summary>
  703. 			/// The number of pixels above and below a mouse-down point that the mouse pointer can move before a drag operation begins.
  704. 			/// This allows the user to click and release the mouse button easily without unintentionally starting a drag operation.
  705. 			/// If this value is negative, it is subtracted from above the mouse-down point and added below it.
  706. 			/// </summary>
  707. 			SM_CYDRAG = 69,
  708.  
  709. 			/// <summary>
  710. 			/// The height of a 3-D border, in pixels. This is the 3-D counterpart of SM_CYBORDER.
  711. 			/// </summary>
  712. 			SM_CYEDGE = 46,
  713.  
  714. 			/// <summary>
  715. 			/// The thickness of the frame around the perimeter of a window that has a caption but is not sizable, in pixels.
  716. 			/// SM_CXFIXEDFRAME is the height of the horizontal border, and SM_CYFIXEDFRAME is the width of the vertical border.
  717. 			/// This value is the same as SM_CYDLGFRAME.
  718. 			/// </summary>
  719. 			SM_CYFIXEDFRAME = 8,
  720.  
  721. 			/// <summary>
  722. 			/// The height of the top and bottom edges of the focus rectangle drawn byDrawFocusRect.
  723. 			/// This value is in pixels.
  724. 			/// Windows 2000:  This value is not supported.
  725. 			/// </summary>
  726. 			SM_CYFOCUSBORDER = 84,
  727.  
  728. 			/// <summary>
  729. 			/// This value is the same as SM_CYSIZEFRAME.
  730. 			/// </summary>
  731. 			SM_CYFRAME = 33,
  732.  
  733. 			/// <summary>
  734. 			/// The height of the client area for a full-screen window on the primary display monitor, in pixels.
  735. 			/// To get the coordinates of the portion of the screen not obscured by the system taskbar or by application desktop toolbars,
  736. 			/// call the SystemParametersInfo function with the SPI_GETWORKAREA value.
  737. 			/// </summary>
  738. 			SM_CYFULLSCREEN = 17,
  739.  
  740. 			/// <summary>
  741. 			/// The height of a horizontal scroll bar, in pixels.
  742. 			/// </summary>
  743. 			SM_CYHSCROLL = 3,
  744.  
  745. 			/// <summary>
  746. 			/// The default height of an icon, in pixels. The LoadIcon function can load only icons with the dimensions SM_CXICON and SM_CYICON.
  747. 			/// </summary>
  748. 			SM_CYICON = 12,
  749.  
  750. 			/// <summary>
  751. 			/// The height of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of size
  752. 			/// SM_CXICONSPACING by SM_CYICONSPACING when arranged. This value is always greater than or equal to SM_CYICON.
  753. 			/// </summary>
  754. 			SM_CYICONSPACING = 39,
  755.  
  756. 			/// <summary>
  757. 			/// For double byte character set versions of the system, this is the height of the Kanji window at the bottom of the screen, in pixels.
  758. 			/// </summary>
  759. 			SM_CYKANJIWINDOW = 18,
  760.  
  761. 			/// <summary>
  762. 			/// The default height, in pixels, of a maximized top-level window on the primary display monitor.
  763. 			/// </summary>
  764. 			SM_CYMAXIMIZED = 62,
  765.  
  766. 			/// <summary>
  767. 			/// The default maximum height of a window that has a caption and sizing borders, in pixels. This metric refers to the entire desktop.
  768. 			/// The user cannot drag the window frame to a size larger than these dimensions. A window can override this value by processing
  769. 			/// the WM_GETMINMAXINFO message.
  770. 			/// </summary>
  771. 			SM_CYMAXTRACK = 60,
  772.  
  773. 			/// <summary>
  774. 			/// The height of a single-line menu bar, in pixels.
  775. 			/// </summary>
  776. 			SM_CYMENU = 15,
  777.  
  778. 			/// <summary>
  779. 			/// The height of the default menu check-mark bitmap, in pixels.
  780. 			/// </summary>
  781. 			SM_CYMENUCHECK = 72,
  782.  
  783. 			/// <summary>
  784. 			/// The height of menu bar buttons, such as the child window close button that is used in the multiple document interface, in pixels.
  785. 			/// </summary>
  786. 			SM_CYMENUSIZE = 55,
  787.  
  788. 			/// <summary>
  789. 			/// The minimum height of a window, in pixels.
  790. 			/// </summary>
  791. 			SM_CYMIN = 29,
  792.  
  793. 			/// <summary>
  794. 			/// The height of a minimized window, in pixels.
  795. 			/// </summary>
  796. 			SM_CYMINIMIZED = 58,
  797.  
  798. 			/// <summary>
  799. 			/// The height of a grid cell for a minimized window, in pixels. Each minimized window fits into a rectangle this size when arranged.
  800. 			/// This value is always greater than or equal to SM_CYMINIMIZED.
  801. 			/// </summary>
  802. 			SM_CYMINSPACING = 48,
  803.  
  804. 			/// <summary>
  805. 			/// The minimum tracking height of a window, in pixels. The user cannot drag the window frame to a size smaller than these dimensions.
  806. 			/// A window can override this value by processing the WM_GETMINMAXINFO message.
  807. 			/// </summary>
  808. 			SM_CYMINTRACK = 35,
  809.  
  810. 			/// <summary>
  811. 			/// The height of the screen of the primary display monitor, in pixels. This is the same value obtained by calling 
  812. 			/// GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, VERTRES).
  813. 			/// </summary>
  814. 			SM_CYSCREEN = 1,
  815.  
  816. 			/// <summary>
  817. 			/// The height of a button in a window caption or title bar, in pixels.
  818. 			/// </summary>
  819. 			SM_CYSIZE = 31,
  820.  
  821. 			/// <summary>
  822. 			/// The thickness of the sizing border around the perimeter of a window that can be resized, in pixels.
  823. 			/// SM_CXSIZEFRAME is the width of the horizontal border, and SM_CYSIZEFRAME is the height of the vertical border.
  824. 			/// This value is the same as SM_CYFRAME.
  825. 			/// </summary>
  826. 			SM_CYSIZEFRAME = 33,
  827.  
  828. 			/// <summary>
  829. 			/// The height of a small caption, in pixels.
  830. 			/// </summary>
  831. 			SM_CYSMCAPTION = 51,
  832.  
  833. 			/// <summary>
  834. 			/// The recommended height of a small icon, in pixels. Small icons typically appear in window captions and in small icon view.
  835. 			/// </summary>
  836. 			SM_CYSMICON = 50,
  837.  
  838. 			/// <summary>
  839. 			/// The height of small caption buttons, in pixels.
  840. 			/// </summary>
  841. 			SM_CYSMSIZE = 53,
  842.  
  843. 			/// <summary>
  844. 			/// The height of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors.
  845. 			/// The SM_YVIRTUALSCREEN metric is the coordinates for the top of the virtual screen.
  846. 			/// </summary>
  847. 			SM_CYVIRTUALSCREEN = 79,
  848.  
  849. 			/// <summary>
  850. 			/// The height of the arrow bitmap on a vertical scroll bar, in pixels.
  851. 			/// </summary>
  852. 			SM_CYVSCROLL = 20,
  853.  
  854. 			/// <summary>
  855. 			/// The height of the thumb box in a vertical scroll bar, in pixels.
  856. 			/// </summary>
  857. 			SM_CYVTHUMB = 9,
  858.  
  859. 			/// <summary>
  860. 			/// Nonzero if User32.dll supports DBCS; otherwise, 0.
  861. 			/// </summary>
  862. 			SM_DBCSENABLED = 42,
  863.  
  864. 			/// <summary>
  865. 			/// Nonzero if the debug version of User.exe is installed; otherwise, 0.
  866. 			/// </summary>
  867. 			SM_DEBUG = 22,
  868.  
  869. 			/// <summary>
  870. 			/// Nonzero if the current operating system is Windows 7 or Windows Server 2008 R2 and the Tablet PC Input
  871. 			/// service is started; otherwise, 0. The return value is a bitmask that specifies the type of digitizer input supported by the device.
  872. 			/// For more information, see Remarks.
  873. 			/// Windows Server 2008, Windows Vista, and Windows XP/2000:  This value is not supported.
  874. 			/// </summary>
  875. 			SM_DIGITIZER = 94,
  876.  
  877. 			/// <summary>
  878. 			/// Nonzero if Input Method Manager/Input Method Editor features are enabled; otherwise, 0.
  879. 			/// SM_IMMENABLED indicates whether the system is ready to use a Unicode-based IME on a Unicode application.
  880. 			/// To ensure that a language-dependent IME works, check SM_DBCSENABLED and the system ANSI code page.
  881. 			/// Otherwise the ANSI-to-Unicode conversion may not be performed correctly, or some components like fonts
  882. 			/// or registry settings may not be present.
  883. 			/// </summary>
  884. 			SM_IMMENABLED = 82,
  885.  
  886. 			/// <summary>
  887. 			/// Nonzero if there are digitizers in the system; otherwise, 0. SM_MAXIMUMTOUCHES returns the aggregate maximum of the
  888. 			/// maximum number of contacts supported by every digitizer in the system. If the system has only single-touch digitizers,
  889. 			/// the return value is 1. If the system has multi-touch digitizers, the return value is the number of simultaneous contacts
  890. 			/// the hardware can provide. Windows Server 2008, Windows Vista, and Windows XP/2000:  This value is not supported.
  891. 			/// </summary>
  892. 			SM_MAXIMUMTOUCHES = 95,
  893.  
  894. 			/// <summary>
  895. 			/// Nonzero if the current operating system is the Windows XP, Media Center Edition, 0 if not.
  896. 			/// </summary>
  897. 			SM_MEDIACENTER = 87,
  898.  
  899. 			/// <summary>
  900. 			/// Nonzero if drop-down menus are right-aligned with the corresponding menu-bar item; 0 if the menus are left-aligned.
  901. 			/// </summary>
  902. 			SM_MENUDROPALIGNMENT = 40,
  903.  
  904. 			/// <summary>
  905. 			/// Nonzero if the system is enabled for Hebrew and Arabic languages, 0 if not.
  906. 			/// </summary>
  907. 			SM_MIDEASTENABLED = 74,
  908.  
  909. 			/// <summary>
  910. 			/// Nonzero if a mouse is installed; otherwise, 0. This value is rarely zero, because of support for virtual mice and because
  911. 			/// some systems detect the presence of the port instead of the presence of a mouse.
  912. 			/// </summary>
  913. 			SM_MOUSEPRESENT = 19,
  914.  
  915. 			/// <summary>
  916. 			/// Nonzero if a mouse with a horizontal scroll wheel is installed; otherwise 0.
  917. 			/// </summary>
  918. 			SM_MOUSEHORIZONTALWHEELPRESENT = 91,
  919.  
  920. 			/// <summary>
  921. 			/// Nonzero if a mouse with a vertical scroll wheel is installed; otherwise 0.
  922. 			/// </summary>
  923. 			SM_MOUSEWHEELPRESENT = 75,
  924.  
  925. 			/// <summary>
  926. 			/// The least significant bit is set if a network is present; otherwise, it is cleared. The other bits are reserved for future use.
  927. 			/// </summary>
  928. 			SM_NETWORK = 63,
  929.  
  930. 			/// <summary>
  931. 			/// Nonzero if the Microsoft Windows for Pen computing extensions are installed; zero otherwise.
  932. 			/// </summary>
  933. 			SM_PENWINDOWS = 41,
  934.  
  935. 			/// <summary>
  936. 			/// This system metric is used in a Terminal Services environment to determine if the current Terminal Server session is
  937. 			/// being remotely controlled. Its value is nonzero if the current session is remotely controlled; otherwise, 0.
  938. 			/// You can use terminal services management tools such as Terminal Services Manager (tsadmin.msc) and shadow.exe to
  939. 			/// control a remote session. When a session is being remotely controlled, another user can view the contents of that session
  940. 			/// and potentially interact with it.
  941. 			/// </summary>
  942. 			SM_REMOTECONTROL = 0x2001,
  943.  
  944. 			/// <summary>
  945. 			/// This system metric is used in a Terminal Services environment. If the calling process is associated with a Terminal Services
  946. 			/// client session, the return value is nonzero. If the calling process is associated with the Terminal Services console session,
  947. 			/// the return value is 0.
  948. 			/// Windows Server 2003 and Windows XP:  The console session is not necessarily the physical console.
  949. 			/// For more information, seeWTSGetActiveConsoleSessionId.
  950. 			/// </summary>
  951. 			SM_REMOTESESSION = 0x1000,
  952.  
  953. 			/// <summary>
  954. 			/// Nonzero if all the display monitors have the same color format, otherwise, 0. Two displays can have the same bit depth,
  955. 			/// but different color formats. For example, the red, green, and blue pixels can be encoded with different numbers of bits,
  956. 			/// or those bits can be located in different places in a pixel color value.
  957. 			/// </summary>
  958. 			SM_SAMEDISPLAYFORMAT = 81,
  959.  
  960. 			/// <summary>
  961. 			/// This system metric should be ignored; it always returns 0.
  962. 			/// </summary>
  963. 			SM_SECURE = 44,
  964.  
  965. 			/// <summary>
  966. 			/// The build number if the system is Windows Server 2003 R2; otherwise, 0.
  967. 			/// </summary>
  968. 			SM_SERVERR2 = 89,
  969.  
  970. 			/// <summary>
  971. 			/// Nonzero if the user requires an application to present information visually in situations where it would otherwise present
  972. 			/// the information only in audible form; otherwise, 0.
  973. 			/// </summary>
  974. 			SM_SHOWSOUNDS = 70,
  975.  
  976. 			/// <summary>
  977. 			/// Nonzero if the current session is shutting down; otherwise, 0. Windows 2000:  This value is not supported.
  978. 			/// </summary>
  979. 			SM_SHUTTINGDOWN = 0x2000,
  980.  
  981. 			/// <summary>
  982. 			/// Nonzero if the computer has a low-end (slow) processor; otherwise, 0.
  983. 			/// </summary>
  984. 			SM_SLOWMACHINE = 73,
  985.  
  986. 			/// <summary>
  987. 			/// Nonzero if the current operating system is Windows 7 Starter Edition, Windows Vista Starter, or Windows XP Starter Edition; otherwise, 0.
  988. 			/// </summary>
  989. 			SM_STARTER = 88,
  990.  
  991. 			/// <summary>
  992. 			/// Nonzero if the meanings of the left and right mouse buttons are swapped; otherwise, 0.
  993. 			/// </summary>
  994. 			SM_SWAPBUTTON = 23,
  995.  
  996. 			/// <summary>
  997. 			/// Nonzero if the current operating system is the Windows XP Tablet PC edition or if the current operating system is Windows Vista
  998. 			/// or Windows 7 and the Tablet PC Input service is started; otherwise, 0. The SM_DIGITIZER setting indicates the type of digitizer
  999. 			/// input supported by a device running Windows 7 or Windows Server 2008 R2. For more information, see Remarks.
  1000. 			/// </summary>
  1001. 			SM_TABLETPC = 86,
  1002.  
  1003. 			/// <summary>
  1004. 			/// The coordinates for the left side of the virtual screen. The virtual screen is the bounding rectangle of all display monitors.
  1005. 			/// The SM_CXVIRTUALSCREEN metric is the width of the virtual screen.
  1006. 			/// </summary>
  1007. 			SM_XVIRTUALSCREEN = 76,
  1008.  
  1009. 			/// <summary>
  1010. 			/// The coordinates for the top of the virtual screen. The virtual screen is the bounding rectangle of all display monitors.
  1011. 			/// The SM_CYVIRTUALSCREEN metric is the height of the virtual screen.
  1012. 			/// </summary>
  1013. 			SM_YVIRTUALSCREEN = 77,
  1014. 		}
  1015. 	}
  1016. }
  1017.  

page last modified: 2024-04-16; loaded in 0.0176 seconds