NetAutoGUI/GUI.cs

(完整代码) 1KB

using System;
using System.IO;
using System.Reflection;

namespace NetAutoGUI
{
	public static class GUI
	{
		public static readonly IMouseController Mouse;
		public static readonly IKeyboardController Keyboard;
		public static readonly IMessageBoxController MessageBox;
		public static readonly IScreenshotController Screenshot;
		public static readonly IApplicationController Application;

		static GUI()
		{
			if (Environment.OSVersion.Platform == PlatformID.Win32NT)
			{
				Assembly asm;
				try
				{
					asm = Assembly.Load(new AssemblyName("NetAutoGUI.Windows"));
				}
				catch (FileNotFoundException)
				{
					throw new InvalidOperationException("Assembly of NetAutoGUI.Windows is not found, please: Install-Package NetAutoGUI.Windows");
				}
				Type serviceLoaderType = asm.GetType("NetAutoGUI.Windows.WindowsServiceLoader");
				IServiceLoader serviceLoader = (IServiceLoader)Activator.CreateInstance(serviceLoaderType);
				Mouse = serviceLoader.LoadMouseController();
				Keyboard = serviceLoader.LoadKeyboardController();
				MessageBox = serviceLoader.LoadMessageBoxController();
				Screenshot = serviceLoader.LoadScreenshotController();
				Application = serviceLoader.LoadApplicationController();
			}
			else
			{
				throw new NotImplementedException("Only Windows is supported now, welcome to contribute code to support Linux and MacOS.");
			}
		}
	}
}

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

AI 解读 AI

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

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