NetAutoGUI.Windows/InputBuilder.cs

(开头部分) 12KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using static Vanara.PInvoke.User32;

namespace NetAutoGUI.Windows
{
	/// <summary>
	/// Adapted from https://github.com/GregsStack/InputSimulatorStandard
	/// </summary>
	internal class InputBuilder
	{
		private readonly List<INPUT> inputList = new List<INPUT>();

		private static readonly List<VirtualKeyCode> ExtendedKeys = new List<VirtualKeyCode>
		{
			VirtualKeyCode.NUMPAD_RETURN,
			VirtualKeyCode.MENU,
			VirtualKeyCode.RMENU,
			VirtualKeyCode.CONTROL,
			VirtualKeyCode.RCONTROL,
			VirtualKeyCode.INSERT,
			VirtualKeyCode.DELETE,
			VirtualKeyCode.HOME,
			VirtualKeyCode.END,
			VirtualKeyCode.PRIOR,
			VirtualKeyCode.NEXT,
			VirtualKeyCode.RIGHT,
			VirtualKeyCode.UP,
			VirtualKeyCode.LEFT,
			VirtualKeyCode.DOWN,
			VirtualKeyCode.NUMLOCK,
			VirtualKeyCode.CANCEL,
			VirtualKeyCode.SNAPSHOT,
			VirtualKeyCode.DIVIDE
		};


		/// <summary>
		/// Returns the list of <see cref="Input"/> messages as a <see cref="Array"/> of <see cref="Input"/> messages.
		/// </summary>
		/// <returns>The <see cref="System.Array"/> of <see cref="Input"/> messages.</returns>
		public INPUT[] ToArray() => this.inputList.ToArray();

		/// <summary>
		/// Determines if the <see cref="VirtualKeyCode"/> is an ExtendedKey
		/// </summary>
		/// <param name="keyCode">The key code.</param>
		/// <returns>true if the key code is an extended key; otherwise, false.</returns>
		/// <remarks>
		/// The extended keys consist of the ALT and CTRL keys on the right-hand side of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and arrow keys in the clusters to the left of the numeric keypad; the NUM LOCK key; the BREAK (CTRL+PAUSE) key; the PRINT SCRN key; and the divide (/) and ENTER keys in the numeric keypad.
		///
		/// See http://msdn.microsoft.com/en-us/library/ms646267(v=vs.85).aspx Section "Extended-Key Flag"
		/// </remarks>
		public static bool IsExtendedKey(VirtualKeyCode keyCode) => ExtendedKeys.Contains(keyCode);

		/// <summary>
		/// Adds a key down to the list of <see cref="Input"/> messages.
		/// </summary>
		/// <param name="keyCode">The <see cref="VirtualKeyCode"/>.</param>
		/// <returns>This <see cref="InputBuilder"/> instance.</returns>
后面还有 360 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。