Microsoft Public License

项目介绍

HavenDV/H.InputSimulator 是一个托管在 GitHub 上的开源项目,主要使用 C# 编写,采用 Microsoft Public License 许可证,目前获得 109 个 Star、15 次 Fork。

仓库全名
HavenDV/H.InputSimulator
开源许可证
Microsoft Public License
Star 数
109
Fork 数
15
未关闭 Issue
2

README 摘要

H.InputSimulator Allows you to simulate global mouse and keyboard events. Features: Supports scan codes and multi-language input. Supports WPF/WinForms/Console windows apps. Supports .NET Standard 2.0+, .Net Framework 4.6.2 and .Net 8+. Supports trimming/nativeAOT, nullability, and other modern C# features. Supported OS: Windows Nuget Examples SelectCopyPaste OpenWindowsExplorer SelfDestructMessage…

完整内容见 GitHub 原始 README 或本页 。

常见问题

H.InputSimulator 用什么语言开发?

主要使用 C# 编写,采用 Microsoft Public License 许可证,目前有 109 个 Star。

H.InputSimulator 可以免费商用吗?

仓库标注的许可证为 Microsoft Public License,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 H.InputSimulator 的源码?

可以直接克隆仓库:git clone https://github.com/HavenDV/H.InputSimulator.git;安装与运行步骤见仓库 README。

H.InputSimulator 最近还在维护吗?

仓库最近一次更新为 6月15日,当前有 2 个未关闭 Issue;Star 数为 109,可作为社区活跃度的参考。

关于

Allows you to simulate global mouse and keyboard events.

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
248
价值分
80
活跃状态
活跃

语言占比

C#

README

H.InputSimulator

Allows you to simulate global mouse and keyboard events. Features:

  • Supports scan codes and multi-language input.
  • Supports WPF/WinForms/Console windows apps.
  • Supports .NET Standard 2.0+, .Net Framework 4.6.2 and .Net 8+.
  • Supports trimming/nativeAOT, nullability, and other modern C# features.

Supported OS:

  • Windows

Nuget

NuGet

Install-Package H.InputSimulator

Examples

SelectCopyPaste

new InputSimulator().Keyboard
    .ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_A)
    .ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C)
    .ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_V);

OpenWindowsExplorer

new InputSimulator().Keyboard
    .ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_E);

SelfDestructMessage

new InputSimulator().Keyboard
    .ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_R)
    .Sleep(1000)
    .TextEntry("notepad")
    .Sleep(1000)
    .KeyPress(VirtualKeyCode.RETURN)
    .Sleep(1000)
    .TextEntry("These are your orders if you choose to accept them...")
    .TextEntry("This message will self destruct in 5 seconds.")
    .Sleep(5000)
    .ModifiedKeyStroke(VirtualKeyCode.MENU, VirtualKeyCode.F4)
    .KeyPress(VirtualKeyCode.VK_N);

OpenPaintAndCreateLine

new InputSimulator().Keyboard
    .ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_R)
    .Sleep(1000)
    .TextEntry("mspaint")
    .Sleep(1000)
    .KeyPress(VirtualKeyCode.RETURN)
    .Sleep(1000)
    .Mouse
    .LeftButtonDown()
    .MoveMouseToPositionOnVirtualDesktop(65535 / 2, 65535 / 2)
    .LeftButtonUp();

Common problems

Some simulated input commands were not sent successfully.

Please think of the library as a high-level wrapper over Win32 SendInput call. Unfortunately, this is a limitation of the API itself, according to this documentation:

The easiest way to get around this is to run your application as an administrator.

Support

Priority place for bugs: https://github.com/HavenDV/H.InputSimulator/issues
Priority place for ideas and general questions: https://github.com/HavenDV/H.InputSimulator/discussions
I also have a Discord support channel:
https://discord.gg/g8u2t9dKgE

评论

暂无评论