Win32Net 1.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Win32Net --version 1.3.0
NuGet\Install-Package Win32Net -Version 1.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Win32Net" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Win32Net --version 1.3.0
#r "nuget: Win32Net, 1.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Win32Net as a Cake Addin
#addin nuget:?package=Win32Net&version=1.3.0

// Install Win32Net as a Cake Tool
#tool nuget:?package=Win32Net&version=1.3.0

介绍

Win32API的.NET下封装,包含

1: 常用win32的API的net封装
2:鼠标、键盘、热键hook钩子模块,
3:模拟键盘输入文字(支持各种字符文字、不同语言的文字)、模拟鼠标点击移动滚动等操作
4:延迟函数Delay方法
5.系统硬件信息

本项目目前支持以下NET框架:

net40;net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netcoreapp3.1; net5.0-windows ;net6.0-windows 

安装教程

  1. Nuget搜索win32net,安装即可

使用说明

各种常用api

Win32命名空间下包含各种常用api,如:win32.User32.GetDesktopWindow()//获取桌面窗口句柄;

鼠标键盘钩子

Win32.Hooks,命名空间下包含鼠标键盘热荐的钩子相关类。

例如鼠标钩子:

Win32.Hooks.MouseHook mouseHook = new Hooks.MouseHook();//实例化鼠标钩子对象
mouseHook.LeftDown += MouseHook_LeftDown;//鼠标左键按下的事件监听回调方法
mouseHook.Start();//开始监听
mouseHook.Stop();//停止监听
Win32.Input.Keyboard.KeyDown(System.Windows.Forms.Keys.Enter);//按回车键
Win32.Input.Mouse.LeftClick(150, 100);//鼠标左键单击
Win32.Input.Wait.Delay(1500);//延迟1500毫秒
Win32.Input.Keyboard.Type("输入文字1234abc");//模拟输入文字,支持各种语言文字字符

全局快捷键注册

//WPF 窗口句柄
//IntPtr hwnd =   new WindowInteropHelper(WPFWindow对象).Handle;
//winform 窗口句柄
 IntPtr hwnd = this.Handle;
  //实例化热键对象,需要一个句柄,用于接收消息
 Win32.Hooks.SystemHotKey systemHotKey = new Win32.Hooks.SystemHotKey(hwnd);
//热键id,要求唯一
 int hotKeyId = 5000;
//注册Alt+Q快捷键
systemHotKey.AddHotKey(hotKeyId, Win32.KeyModifiers.Alt, Keys.Q,
 () =>
 {
 MessageBox.Show("你按了Alt+Q快捷键");
 }
);
//注册ESC快捷键
 systemHotKey.AddHotKey(hotKeyId + 1, Win32.KeyModifiers.None, Keys.Escape,
 () =>
 {
 this.Close();
 }
 );

系统硬件信息

SystemInfo systemInfo = new SystemInfo();
richTextBox1.AppendText("操作系统:" + systemInfo.operatingSystem.Caption + "\n");
richTextBox1.AppendText("系统ID:" + systemInfo.operatingSystem.SerialNumber + "\n");
richTextBox1.AppendText("操作系统平台:" + systemInfo.operatingSystem.OSLevel + "\n");
richTextBox1.AppendText("系统安装时间:" + systemInfo.operatingSystem.InstallDate + "\n");
richTextBox1.AppendText("系统最近启动时间:" + systemInfo.operatingSystem.LastBootUpTime + "\n");
richTextBox1.AppendText("系统时间:" + systemInfo.operatingSystem.LocalDateTime + "\n");
richTextBox1.AppendText("CPU:" + systemInfo.processor.Name + "\n");
richTextBox1.AppendText("CPU厂商:" + systemInfo.processor.Manufacturer + "\n");
richTextBox1.AppendText("CPU序列号:" + systemInfo.processor.SerialNumber + "\n");
richTextBox1.AppendText("物理内存:" + systemInfo.memory.TotalPhysicalMemory + "\n");

// CPU使用率,一个回调,1秒一次,可取消
SystemInfo.CpuUsageOnChanged

// 内存使用率,需要自己间隔一定时间获取,如200毫秒
 Win32.SystemInfo.MemoryUsage + "%";

喜欢的话就给个星,如果对你有用,就点个赞。开源不容易,为了造福大众。谢谢!

QQ交流群:318860399,有问题可以加QQ群咨询。微信公众号:明月心技术学堂,可以通过微信公众号获取微信群二维码。

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net5.0-windows7.0 is compatible.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net6.0-windows7.0 is compatible.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net7.0-windows7.0 is compatible.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 is compatible.  net452 is compatible.  net46 is compatible.  net461 is compatible.  net462 is compatible.  net463 was computed.  net47 is compatible.  net471 is compatible.  net472 is compatible.  net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

  • .NETFramework 4.0

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.5.1

    • No dependencies.
  • .NETFramework 4.5.2

    • No dependencies.
  • .NETFramework 4.6

    • No dependencies.
  • .NETFramework 4.6.1

    • No dependencies.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETFramework 4.7

    • No dependencies.
  • .NETFramework 4.7.1

    • No dependencies.
  • .NETFramework 4.7.2

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • net5.0-windows7.0

  • net6.0-windows7.0

  • net7.0-windows7.0

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Win32Net:

Package Downloads
YancheeGame

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.0 216 3/6/2024
1.3.0 915 11/25/2022
1.2.0 1,025 12/11/2021
1.0.1 2,757 11/25/2021
1.0.0 1,167 11/21/2021