From 45437aeb327b490a60f2b56ecbcdba65a0a7df71 Mon Sep 17 00:00:00 2001 From: Chaoses Ib Date: Tue, 11 Jan 2022 19:48:49 +0800 Subject: [PATCH 01/26] AhkDll: Fix screen resolution updating --- AhkDll/SendTypes/Base.hpp | 12 +++++++++--- AhkDll/SendTypes/DD.hpp | 5 +++++ AhkDll/SendTypes/Logitech.hpp | 5 +++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/AhkDll/SendTypes/Base.hpp b/AhkDll/SendTypes/Base.hpp index 5555855..14e9a0d 100644 --- a/AhkDll/SendTypes/Base.hpp +++ b/AhkDll/SendTypes/Base.hpp @@ -54,6 +54,14 @@ namespace Send::Type::Internal { absolute.y = absolute.y * screen.y / 65536; } + void update_screen_resolution() { + screen.x = GetSystemMetrics(SM_CXSCREEN); //#TODO: SM_CXVIRTUALSCREEN? + screen.y = GetSystemMetrics(SM_CYSCREEN); + + // the overhead of WM_DISPLAYCHANGE is a bit high + } + + // need to call update_screen_resolution first static void mouse_screen_to_relative(POINT& screen_point) { POINT point; GetCursorPos(&point); @@ -62,12 +70,10 @@ namespace Send::Type::Internal { screen_point.x -= point.x; screen_point.y -= point.y; } + public: void create_base(decltype(&::GetAsyncKeyState)* get_key_state_fallback) { this->get_key_state_fallback = get_key_state_fallback; - - screen.x = GetSystemMetrics(SM_CXSCREEN); //#TODO: may change - screen.y = GetSystemMetrics(SM_CYSCREEN); } virtual void destroy() = 0; diff --git a/AhkDll/SendTypes/DD.hpp b/AhkDll/SendTypes/DD.hpp index 503a019..355e3d8 100644 --- a/AhkDll/SendTypes/DD.hpp +++ b/AhkDll/SendTypes/DD.hpp @@ -64,6 +64,11 @@ namespace Send::Type::Internal { FreeLibrary(dd); } + uint32_t send_mouse_input(const INPUT inputs[], uint32_t n) override { + update_screen_resolution(); + return Base::send_mouse_input(inputs, n); + } + bool send_mouse_input(const MOUSEINPUT& mi) override { //#TODO: MOUSEEVENTF_MOVE_NOCOALESCE, MOUSEEVENTF_VIRTUALDESK if (mi.dwFlags & MOUSEEVENTF_MOVE) { diff --git a/AhkDll/SendTypes/Logitech.hpp b/AhkDll/SendTypes/Logitech.hpp index 1f2d381..6c3a458 100644 --- a/AhkDll/SendTypes/Logitech.hpp +++ b/AhkDll/SendTypes/Logitech.hpp @@ -248,6 +248,11 @@ namespace Send::Type::Internal { std::mutex mouse_mutex; public: + uint32_t send_mouse_input(const INPUT inputs[], uint32_t n) override { + update_screen_resolution(); + return Base::send_mouse_input(inputs, n); + } + bool send_mouse_input(const MOUSEINPUT& mi) override { std::lock_guard lock(mouse_mutex); From 2155a454ab07cc6daaedea9a15848f34b4561845 Mon Sep 17 00:00:00 2001 From: Chaoses Ib Date: Fri, 14 Jan 2022 02:53:43 +0800 Subject: [PATCH 02/26] Docs: Add credits --- README.md | 20 ++++++++++++++------ README.zh-Hans.md | 20 ++++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 06fa8dc..3586c24 100644 --- a/README.md +++ b/README.md @@ -71,11 +71,7 @@ MouseClickDrag, Left, 5, 5, 150, 50 ## Downloading [Releases](../../releases) -## See Also -* [IbLogiSoftExt](https://github.com/Chaoses-Ib/IbLogiSoftExt) - -## For Developers -### Building +## Building 1. Put [IbWinCppLib](https://github.com/Chaoses-Ib/IbWinCppLib/tree/master/WinCppLib/IbWinCppLib) in `C:\L\C++\packages` (in other locations you need to modify the .vcxproj files). 1. [vcpkg](https://github.com/microsoft/vcpkg) ``` @@ -86,4 +82,16 @@ MouseClickDrag, Left, 5, 5, 150, 50 ``` vcpkg install boost-test fmt ``` - Change VCPKG_DEFAULT_TRIPLET to x86-windows-static-md if you need x86 version. \ No newline at end of file + Change VCPKG_DEFAULT_TRIPLET to x86-windows-static-md if you need x86 version. + +## See Also +* [IbLogiSoftExt](https://github.com/Chaoses-Ib/IbLogiSoftExt) + +## Credits +* Logitech + * @The-BigEagle + * [ekknod/logitech-cve](https://github.com/ekknod/logitech-cve) for learning that Logitech devices can be opened directly +* Razer + * [Sadmeme/rzctl](https://github.com/Sadmeme/rzctl) + * @任性 for providing test environment +* @任性 for providing feedback and sponsorship \ No newline at end of file diff --git a/README.zh-Hans.md b/README.zh-Hans.md index b2818fe..25f02eb 100644 --- a/README.zh-Hans.md +++ b/README.zh-Hans.md @@ -69,11 +69,7 @@ MouseClickDrag, Left, 5, 5, 150, 50 ## 下载 [Releases](../../releases) -## 相关推荐 -* [IbLogiSoftExt](https://github.com/Chaoses-Ib/IbLogiSoftExt) - -## 开发者 -### 构建 +## 构建 1. 将 [IbWinCppLib](https://github.com/Chaoses-Ib/IbWinCppLib/tree/master/WinCppLib/IbWinCppLib) 放入 `C:\L\C++\packages`(其它位置需要修改 .vcxproj 文件)。 1. [vcpkg](https://github.com/microsoft/vcpkg) ``` @@ -84,4 +80,16 @@ MouseClickDrag, Left, 5, 5, 150, 50 ``` vcpkg install boost-test fmt ``` - 如果需要 x86 版本就把 VCPKG_DEFAULT_TRIPLET 改为 x86-windows-static-md。 \ No newline at end of file + 如果需要 x86 版本就把 VCPKG_DEFAULT_TRIPLET 改为 x86-windows-static-md。 + +## 相关推荐 +* [IbLogiSoftExt](https://github.com/Chaoses-Ib/IbLogiSoftExt) + +## 鸣谢 +* 罗技 + * @The-BigEagle + * [ekknod/logitech-cve](https://github.com/ekknod/logitech-cve):了解到罗技设备可以被直接打开 +* 雷蛇 + * [Sadmeme/rzctl](https://github.com/Sadmeme/rzctl) + * @任性:提供测试环境 +* @任性:提供反馈和赞助 \ No newline at end of file From 90f167e69979ada51847a525a5e0e4c7aad899f6 Mon Sep 17 00:00:00 2001 From: Chaoses Ib Date: Fri, 14 Jan 2022 16:58:04 +0800 Subject: [PATCH 03/26] Rename project IbInputSimulator --- AhkDll.Ahk/v1/test/type Logitech.ahk | 4 --- AhkDll.Ahk/v1/test/type Razer.ahk | 4 --- AhkDll.Ahk/v1/test/type SendInput.ahk | 4 --- AhkDll.Ahk/v2/test/type Logitech.ahk | 3 -- AhkDll.Ahk/v2/test/type Razer.ahk | 3 -- AhkDll.Ahk/v2/test/type SendInput.ahk | 3 -- .../IbInputSimulator.ahk | 34 +++++++++---------- .../v1 => Binding.AHK1}/test/KeyHistory.ahk | 0 .../v1 => Binding.AHK1}/test/mode 0.ahk | 2 +- .../v1 => Binding.AHK1}/test/mode 1.ahk | 2 +- .../v1 => Binding.AHK1}/test/mode ahk.ahk | 0 .../v1 => Binding.AHK1}/test/type DD.ahk | 4 +-- Binding.AHK1/test/type Logitech.ahk | 4 +++ Binding.AHK1/test/type Razer.ahk | 4 +++ Binding.AHK1/test/type SendInput.ahk | 4 +++ .../IbInputSimulator.ahk | 32 ++++++++--------- .../v2 => Binding.AHK2}/test/KeyHistory.ahk | 0 .../v2 => Binding.AHK2}/test/mode 0.ahk | 2 +- .../v2 => Binding.AHK2}/test/mode 1.ahk | 2 +- .../v2 => Binding.AHK2}/test/mode ahk.ahk | 0 .../v2 => Binding.AHK2}/test/type DD.ahk | 4 +-- Binding.AHK2/test/type Logitech.ahk | 3 ++ Binding.AHK2/test/type Razer.ahk | 3 ++ Binding.AHK2/test/type SendInput.ahk | 3 ++ IbAhkSendLib.sln => IbInputSimulator.sln | 4 +-- README.md | 6 ++-- README.zh-Hans.md | 6 ++-- {AhkDll => Simulator}/API 2.cpp | 2 +- {AhkDll => Simulator}/API 3.cpp | 2 +- .../IbInputSimulator.hpp | 2 +- {AhkDll => Simulator}/SendTypes/Base.hpp | 0 {AhkDll => Simulator}/SendTypes/DD.hpp | 0 {AhkDll => Simulator}/SendTypes/Logitech.hpp | 0 {AhkDll => Simulator}/SendTypes/Razer.hpp | 0 {AhkDll => Simulator}/SendTypes/SendInput.hpp | 0 {AhkDll => Simulator}/SendTypes/Types.hpp | 0 {AhkDll => Simulator}/SendTypes/Usb.hpp | 0 .../Simulator.vcxproj | 20 +++++------ .../Simulator.vcxproj.filters | 2 +- {AhkDll => Simulator}/common.hpp | 4 +-- {AhkDll => Simulator}/dllmain.cpp | 2 +- {AhkDll => Simulator}/framework.h | 0 {AhkDll => Simulator}/pch.cpp | 0 {AhkDll => Simulator}/pch.h | 0 AhkDll.Test/AhkDll.Test.cpp => Test/Test.cpp | 4 +-- .../AhkDll.Test.vcxproj => Test/Test.vcxproj | 6 ++-- .../Test.vcxproj.filters | 2 +- {AhkDll.Test => Test}/Vk.hpp | 0 48 files changed, 93 insertions(+), 93 deletions(-) delete mode 100644 AhkDll.Ahk/v1/test/type Logitech.ahk delete mode 100644 AhkDll.Ahk/v1/test/type Razer.ahk delete mode 100644 AhkDll.Ahk/v1/test/type SendInput.ahk delete mode 100644 AhkDll.Ahk/v2/test/type Logitech.ahk delete mode 100644 AhkDll.Ahk/v2/test/type Razer.ahk delete mode 100644 AhkDll.Ahk/v2/test/type SendInput.ahk rename AhkDll.Ahk/v1/IbAhkSend.ahk => Binding.AHK1/IbInputSimulator.ahk (51%) rename {AhkDll.Ahk/v1 => Binding.AHK1}/test/KeyHistory.ahk (100%) rename {AhkDll.Ahk/v1 => Binding.AHK1}/test/mode 0.ahk (91%) rename {AhkDll.Ahk/v1 => Binding.AHK1}/test/mode 1.ahk (90%) rename {AhkDll.Ahk/v1 => Binding.AHK1}/test/mode ahk.ahk (100%) rename {AhkDll.Ahk/v1 => Binding.AHK1}/test/type DD.ahk (61%) create mode 100644 Binding.AHK1/test/type Logitech.ahk create mode 100644 Binding.AHK1/test/type Razer.ahk create mode 100644 Binding.AHK1/test/type SendInput.ahk rename AhkDll.Ahk/v2/IbAhkSend.ahk => Binding.AHK2/IbInputSimulator.ahk (59%) rename {AhkDll.Ahk/v2 => Binding.AHK2}/test/KeyHistory.ahk (100%) rename {AhkDll.Ahk/v2 => Binding.AHK2}/test/mode 0.ahk (89%) rename {AhkDll.Ahk/v2 => Binding.AHK2}/test/mode 1.ahk (88%) rename {AhkDll.Ahk/v2 => Binding.AHK2}/test/mode ahk.ahk (100%) rename {AhkDll.Ahk/v2 => Binding.AHK2}/test/type DD.ahk (52%) create mode 100644 Binding.AHK2/test/type Logitech.ahk create mode 100644 Binding.AHK2/test/type Razer.ahk create mode 100644 Binding.AHK2/test/type SendInput.ahk rename IbAhkSendLib.sln => IbInputSimulator.sln (87%) rename {AhkDll => Simulator}/API 2.cpp (96%) rename {AhkDll => Simulator}/API 3.cpp (99%) rename AhkDll/IbAhkSend.hpp => Simulator/IbInputSimulator.hpp (99%) rename {AhkDll => Simulator}/SendTypes/Base.hpp (100%) rename {AhkDll => Simulator}/SendTypes/DD.hpp (100%) rename {AhkDll => Simulator}/SendTypes/Logitech.hpp (100%) rename {AhkDll => Simulator}/SendTypes/Razer.hpp (100%) rename {AhkDll => Simulator}/SendTypes/SendInput.hpp (100%) rename {AhkDll => Simulator}/SendTypes/Types.hpp (100%) rename {AhkDll => Simulator}/SendTypes/Usb.hpp (100%) rename AhkDll/AhkDll.vcxproj => Simulator/Simulator.vcxproj (91%) rename AhkDll/AhkDll.vcxproj.filters => Simulator/Simulator.vcxproj.filters (98%) rename {AhkDll => Simulator}/common.hpp (90%) rename {AhkDll => Simulator}/dllmain.cpp (99%) rename {AhkDll => Simulator}/framework.h (100%) rename {AhkDll => Simulator}/pch.cpp (100%) rename {AhkDll => Simulator}/pch.h (100%) rename AhkDll.Test/AhkDll.Test.cpp => Test/Test.cpp (99%) rename AhkDll.Test/AhkDll.Test.vcxproj => Test/Test.vcxproj (98%) rename AhkDll.Test/AhkDll.Test.vcxproj.filters => Test/Test.vcxproj.filters (96%) rename {AhkDll.Test => Test}/Vk.hpp (100%) diff --git a/AhkDll.Ahk/v1/test/type Logitech.ahk b/AhkDll.Ahk/v1/test/type Logitech.ahk deleted file mode 100644 index a0ea735..0000000 --- a/AhkDll.Ahk/v1/test/type Logitech.ahk +++ /dev/null @@ -1,4 +0,0 @@ -#Include %A_ScriptDir% -#Include ..\IbAhkSend.ahk -IbSendInit("Logitech") -#include mode ahk.ahk \ No newline at end of file diff --git a/AhkDll.Ahk/v1/test/type Razer.ahk b/AhkDll.Ahk/v1/test/type Razer.ahk deleted file mode 100644 index e6a4796..0000000 --- a/AhkDll.Ahk/v1/test/type Razer.ahk +++ /dev/null @@ -1,4 +0,0 @@ -#Include %A_ScriptDir% -#Include ..\IbAhkSend.ahk -IbSendInit("Razer") -#include mode ahk.ahk \ No newline at end of file diff --git a/AhkDll.Ahk/v1/test/type SendInput.ahk b/AhkDll.Ahk/v1/test/type SendInput.ahk deleted file mode 100644 index 3ac4356..0000000 --- a/AhkDll.Ahk/v1/test/type SendInput.ahk +++ /dev/null @@ -1,4 +0,0 @@ -#Include %A_ScriptDir% -#Include ..\IbAhkSend.ahk -IbSendInit("SendInput") -#include mode ahk.ahk \ No newline at end of file diff --git a/AhkDll.Ahk/v2/test/type Logitech.ahk b/AhkDll.Ahk/v2/test/type Logitech.ahk deleted file mode 100644 index 01464d9..0000000 --- a/AhkDll.Ahk/v2/test/type Logitech.ahk +++ /dev/null @@ -1,3 +0,0 @@ -#Include "..\IbAhkSend.ahk" -IbSendInit("Logitech") -#include "mode ahk.ahk" \ No newline at end of file diff --git a/AhkDll.Ahk/v2/test/type Razer.ahk b/AhkDll.Ahk/v2/test/type Razer.ahk deleted file mode 100644 index 910fb02..0000000 --- a/AhkDll.Ahk/v2/test/type Razer.ahk +++ /dev/null @@ -1,3 +0,0 @@ -#Include "..\IbAhkSend.ahk" -IbSendInit("Razer") -#include "mode ahk.ahk" \ No newline at end of file diff --git a/AhkDll.Ahk/v2/test/type SendInput.ahk b/AhkDll.Ahk/v2/test/type SendInput.ahk deleted file mode 100644 index 0385f7e..0000000 --- a/AhkDll.Ahk/v2/test/type SendInput.ahk +++ /dev/null @@ -1,3 +0,0 @@ -#Include "..\IbAhkSend.ahk" -IbSendInit("SendInput") -#include "mode ahk.ahk" \ No newline at end of file diff --git a/AhkDll.Ahk/v1/IbAhkSend.ahk b/Binding.AHK1/IbInputSimulator.ahk similarity index 51% rename from AhkDll.Ahk/v1/IbAhkSend.ahk rename to Binding.AHK1/IbInputSimulator.ahk index 348f060..f3d5602 100644 --- a/AhkDll.Ahk/v1/IbAhkSend.ahk +++ b/Binding.AHK1/IbInputSimulator.ahk @@ -1,36 +1,36 @@ -; IbAhkSendLib (v1) +; IbInputSimulator (v1) ; Description: Enable AHK to send keystrokes by drivers. ; Author: Chaoses Ib ; Version: 0.3 -; Git: https://github.com/Chaoses-Ib/IbAhkSendLib +; Git: https://github.com/Chaoses-Ib/IbInputSimulator IbSendInit(send_type := "AnyDriver", mode := 1, args*){ workding_dir := A_WorkingDir SetWorkingDir, %A_ScriptDir% - static hModule := DllCall("LoadLibrary", "Str", A_ScriptDir "\IbAhkSend.dll", "Ptr") + static hModule := DllCall("LoadLibrary", "Str", A_ScriptDir "\IbInputSimulator.dll", "Ptr") if (hModule == 0){ if (A_PtrSize == 4) throw "SendLibLoadFailed: Please use AutoHotkey x64" - else if (!FileExist("IbAhkSend.dll")) - throw "SendLibLoadFailed: Please put IbAhkSend.dll with your script file (or use AHK v2 instead, which can locate those DLLs that are put with the library files)" + else if (!FileExist("IbInputSimulator.dll")) + throw "SendLibLoadFailed: Please put IbInputSimulator.dll with your script file (or use AHK v2 instead, which can locate those DLLs that are put with the library files)" else throw "SendLibLoadFailed" } if (send_type == "AnyDriver") - result := DllCall("IbAhkSend\IbSendInit", "Int", 0, "Int", 0, "Ptr", 0, "Int") + result := DllCall("IbInputSimulator\IbSendInit", "Int", 0, "Int", 0, "Ptr", 0, "Int") else if (send_type == "SendInput") - result := DllCall("IbAhkSend\IbSendInit", "Int", 1, "Int", 0, "Ptr", 0, "Int") + result := DllCall("IbInputSimulator\IbSendInit", "Int", 1, "Int", 0, "Ptr", 0, "Int") else if (send_type == "Logitech") - result := DllCall("IbAhkSend\IbSendInit", "Int", 2, "Int", 0, "Ptr", 0, "Int") + result := DllCall("IbInputSimulator\IbSendInit", "Int", 2, "Int", 0, "Ptr", 0, "Int") else if (send_type == "Razer") - result := DllCall("IbAhkSend\IbSendInit", "Int", 3, "Int", 0, "Ptr", 0, "Int") + result := DllCall("IbInputSimulator\IbSendInit", "Int", 3, "Int", 0, "Ptr", 0, "Int") else if (send_type == "DD"){ if (args.MaxIndex() == 1) - result := DllCall("IbAhkSend\IbSendInit", "Int", 4, "Int", 0, "WStr", args[1], "Int") + result := DllCall("IbInputSimulator\IbSendInit", "Int", 4, "Int", 0, "WStr", args[1], "Int") else - result := DllCall("IbAhkSend\IbSendInit", "Int", 4, "Int", 0, "Ptr", 0, "Int") + result := DllCall("IbInputSimulator\IbSendInit", "Int", 4, "Int", 0, "Ptr", 0, "Int") } else throw "Invalid send type" @@ -49,28 +49,28 @@ IbSendInit(send_type := "AnyDriver", mode := 1, args*){ IbSendMode(mode){ static ahk_mode := "" if (mode == 1){ - DllCall("IbAhkSend\IbSendInputHook", "Int", 1) + DllCall("IbInputSimulator\IbSendInputHook", "Int", 1) ahk_mode := A_SendMode SendMode Input } else if (mode == 0){ SendMode %ahk_mode% - DllCall("IbAhkSend\IbSendInputHook", "Int", 0) + DllCall("IbInputSimulator\IbSendInputHook", "Int", 0) } else { throw "Invalid send mode" } } IbSendDestroy(){ - DllCall("IbAhkSend\IbSendDestroy") + DllCall("IbInputSimulator\IbSendDestroy") ;DllCall("FreeLibrary", "Ptr", hModule) } IbSyncKeyStates(){ - DllCall("IbAhkSend\IbSendSyncKeyStates") + DllCall("IbInputSimulator\IbSendSyncKeyStates") } IbSend(keys){ - DllCall("IbAhkSend\IbSendInputHook", "Int", 1) ;or IbSendMode(1) + DllCall("IbInputSimulator\IbSendInputHook", "Int", 1) ;or IbSendMode(1) SendInput %keys% - DllCall("IbAhkSend\IbSendInputHook", "Int", 0) ;or IbSendMode(0) + DllCall("IbInputSimulator\IbSendInputHook", "Int", 0) ;or IbSendMode(0) } \ No newline at end of file diff --git a/AhkDll.Ahk/v1/test/KeyHistory.ahk b/Binding.AHK1/test/KeyHistory.ahk similarity index 100% rename from AhkDll.Ahk/v1/test/KeyHistory.ahk rename to Binding.AHK1/test/KeyHistory.ahk diff --git a/AhkDll.Ahk/v1/test/mode 0.ahk b/Binding.AHK1/test/mode 0.ahk similarity index 91% rename from AhkDll.Ahk/v1/test/mode 0.ahk rename to Binding.AHK1/test/mode 0.ahk index 7134b08..e3ae2b3 100644 --- a/AhkDll.Ahk/v1/test/mode 0.ahk +++ b/Binding.AHK1/test/mode 0.ahk @@ -2,7 +2,7 @@ ; Run Notepad, type "Hello world!" and then select all text by mouse. #Include %A_ScriptDir% -#Include ..\IbAhkSend.ahk +#Include ..\IbInputSimulator.ahk IbSendInit("AnyDriver", 0) diff --git a/AhkDll.Ahk/v1/test/mode 1.ahk b/Binding.AHK1/test/mode 1.ahk similarity index 90% rename from AhkDll.Ahk/v1/test/mode 1.ahk rename to Binding.AHK1/test/mode 1.ahk index b2d9d63..2d7c94a 100644 --- a/AhkDll.Ahk/v1/test/mode 1.ahk +++ b/Binding.AHK1/test/mode 1.ahk @@ -2,7 +2,7 @@ ; Run Notepad, type "Hello world!" and then select all text by mouse. #Include %A_ScriptDir% -#Include ..\IbAhkSend.ahk +#Include ..\IbInputSimulator.ahk IbSendInit() diff --git a/AhkDll.Ahk/v1/test/mode ahk.ahk b/Binding.AHK1/test/mode ahk.ahk similarity index 100% rename from AhkDll.Ahk/v1/test/mode ahk.ahk rename to Binding.AHK1/test/mode ahk.ahk diff --git a/AhkDll.Ahk/v1/test/type DD.ahk b/Binding.AHK1/test/type DD.ahk similarity index 61% rename from AhkDll.Ahk/v1/test/type DD.ahk rename to Binding.AHK1/test/type DD.ahk index 0c86aaf..d3f0785 100644 --- a/AhkDll.Ahk/v1/test/type DD.ahk +++ b/Binding.AHK1/test/type DD.ahk @@ -1,4 +1,4 @@ #Include %A_ScriptDir% -#Include ..\IbAhkSend.ahk +#Include ..\IbInputSimulator.ahk IbSendInit("DD") ;or IbSendInit("DD", 1, "C:\SomeDir\DD64.dll") -#include mode ahk.ahk \ No newline at end of file +#Include mode ahk.ahk \ No newline at end of file diff --git a/Binding.AHK1/test/type Logitech.ahk b/Binding.AHK1/test/type Logitech.ahk new file mode 100644 index 0000000..9a729a6 --- /dev/null +++ b/Binding.AHK1/test/type Logitech.ahk @@ -0,0 +1,4 @@ +#Include %A_ScriptDir% +#Include ..\IbInputSimulator.ahk +IbSendInit("Logitech") +#Include mode ahk.ahk \ No newline at end of file diff --git a/Binding.AHK1/test/type Razer.ahk b/Binding.AHK1/test/type Razer.ahk new file mode 100644 index 0000000..6f8c7d3 --- /dev/null +++ b/Binding.AHK1/test/type Razer.ahk @@ -0,0 +1,4 @@ +#Include %A_ScriptDir% +#Include ..\IbInputSimulator.ahk +IbSendInit("Razer") +#Include mode ahk.ahk \ No newline at end of file diff --git a/Binding.AHK1/test/type SendInput.ahk b/Binding.AHK1/test/type SendInput.ahk new file mode 100644 index 0000000..a2983af --- /dev/null +++ b/Binding.AHK1/test/type SendInput.ahk @@ -0,0 +1,4 @@ +#Include %A_ScriptDir% +#Include ..\IbInputSimulator.ahk +IbSendInit("SendInput") +#Include mode ahk.ahk \ No newline at end of file diff --git a/AhkDll.Ahk/v2/IbAhkSend.ahk b/Binding.AHK2/IbInputSimulator.ahk similarity index 59% rename from AhkDll.Ahk/v2/IbAhkSend.ahk rename to Binding.AHK2/IbInputSimulator.ahk index 842962e..7db94dd 100644 --- a/AhkDll.Ahk/v2/IbAhkSend.ahk +++ b/Binding.AHK2/IbInputSimulator.ahk @@ -1,16 +1,16 @@ -; IbAhkSendLib +; IbInputSimulator ; Description: Enable AHK to send keystrokes by drivers. ; Author: Chaoses Ib ; Version: 0.3 -; Git: https://github.com/Chaoses-Ib/IbAhkSendLib +; Git: https://github.com/Chaoses-Ib/IbInputSimulator -#DllLoad "*i IbAhkSend.dll" ;DllCall("LoadLibrary") cannot locate DLL correctly +#DllLoad "*i IbInputSimulator.dll" ;DllCall("LoadLibrary") cannot locate DLL correctly IbSendInit(send_type := "AnyDriver", mode := 1, args*){ workding_dir := A_WorkingDir SetWorkingDir(A_ScriptDir) - static hModule := DllCall("GetModuleHandle", "Str", "IbAhkSend.dll", "Ptr") + static hModule := DllCall("GetModuleHandle", "Str", "IbInputSimulator.dll", "Ptr") if (hModule == 0){ if (A_PtrSize == 4) throw "SendLibLoadFailed: Please use AutoHotkey x64" @@ -19,18 +19,18 @@ IbSendInit(send_type := "AnyDriver", mode := 1, args*){ } if (send_type == "AnyDriver") - result := DllCall("IbAhkSend\IbSendInit", "Int", 0, "Int", 0, "Ptr", 0, "Int") + result := DllCall("IbInputSimulator\IbSendInit", "Int", 0, "Int", 0, "Ptr", 0, "Int") else if (send_type == "SendInput") - result := DllCall("IbAhkSend\IbSendInit", "Int", 1, "Int", 0, "Ptr", 0, "Int") + result := DllCall("IbInputSimulator\IbSendInit", "Int", 1, "Int", 0, "Ptr", 0, "Int") else if (send_type == "Logitech") - result := DllCall("IbAhkSend\IbSendInit", "Int", 2, "Int", 0, "Ptr", 0, "Int") + result := DllCall("IbInputSimulator\IbSendInit", "Int", 2, "Int", 0, "Ptr", 0, "Int") else if (send_type == "Razer") - result := DllCall("IbAhkSend\IbSendInit", "Int", 3, "Int", 0, "Ptr", 0, "Int") + result := DllCall("IbInputSimulator\IbSendInit", "Int", 3, "Int", 0, "Ptr", 0, "Int") else if (send_type == "DD"){ if (args.Length == 1) - result := DllCall("IbAhkSend\IbSendInit", "Int", 4, "Int", 0, "WStr", args[1], "Int") + result := DllCall("IbInputSimulator\IbSendInit", "Int", 4, "Int", 0, "WStr", args[1], "Int") else - result := DllCall("IbAhkSend\IbSendInit", "Int", 4, "Int", 0, "Ptr", 0, "Int") + result := DllCall("IbInputSimulator\IbSendInit", "Int", 4, "Int", 0, "Ptr", 0, "Int") } else throw "Invalid send type" @@ -57,30 +57,30 @@ IbSendInit(send_type := "AnyDriver", mode := 1, args*){ IbSendMode(mode){ static ahk_mode := "" if (mode == 1){ - DllCall("IbAhkSend\IbSendInputHook", "Int", 1) + DllCall("IbInputSimulator\IbSendInputHook", "Int", 1) ahk_mode := A_SendMode SendMode("Input") } else if (mode == 0){ SendMode(ahk_mode) - DllCall("IbAhkSend\IbSendInputHook", "Int", 0) + DllCall("IbInputSimulator\IbSendInputHook", "Int", 0) } else { throw "Invalid send mode" } } IbSendDestroy(){ - DllCall("IbAhkSend\IbSendDestroy") + DllCall("IbInputSimulator\IbSendDestroy") ;DllCall("FreeLibrary", "Ptr", hModule) } IbSyncKeyStates(){ - DllCall("IbAhkSend\IbSendSyncKeyStates") + DllCall("IbInputSimulator\IbSendSyncKeyStates") } IbSend(keys){ - DllCall("IbAhkSend\IbSendInputHook", "Int", 1) ;or IbSendMode(1) + DllCall("IbInputSimulator\IbSendInputHook", "Int", 1) ;or IbSendMode(1) SendInput(keys) - DllCall("IbAhkSend\IbSendInputHook", "Int", 0) ;or IbSendMode(0) + DllCall("IbInputSimulator\IbSendInputHook", "Int", 0) ;or IbSendMode(0) } IbClick(args*){ diff --git a/AhkDll.Ahk/v2/test/KeyHistory.ahk b/Binding.AHK2/test/KeyHistory.ahk similarity index 100% rename from AhkDll.Ahk/v2/test/KeyHistory.ahk rename to Binding.AHK2/test/KeyHistory.ahk diff --git a/AhkDll.Ahk/v2/test/mode 0.ahk b/Binding.AHK2/test/mode 0.ahk similarity index 89% rename from AhkDll.Ahk/v2/test/mode 0.ahk rename to Binding.AHK2/test/mode 0.ahk index 98f3aa2..69ab367 100644 --- a/AhkDll.Ahk/v2/test/mode 0.ahk +++ b/Binding.AHK2/test/mode 0.ahk @@ -1,7 +1,7 @@ ; Mode 0 ; Run Notepad, type "Hello world!" and then select all text by mouse. -#Include "..\IbAhkSend.ahk" +#Include "..\IbInputSimulator.ahk" IbSendInit("AnyDriver", 0) diff --git a/AhkDll.Ahk/v2/test/mode 1.ahk b/Binding.AHK2/test/mode 1.ahk similarity index 88% rename from AhkDll.Ahk/v2/test/mode 1.ahk rename to Binding.AHK2/test/mode 1.ahk index 50b04c2..0371d57 100644 --- a/AhkDll.Ahk/v2/test/mode 1.ahk +++ b/Binding.AHK2/test/mode 1.ahk @@ -1,7 +1,7 @@ ; Mode 1 ; Run Notepad, type "Hello world!" and then select all text by mouse. -#Include "..\IbAhkSend.ahk" +#Include "..\IbInputSimulator.ahk" IbSendInit() diff --git a/AhkDll.Ahk/v2/test/mode ahk.ahk b/Binding.AHK2/test/mode ahk.ahk similarity index 100% rename from AhkDll.Ahk/v2/test/mode ahk.ahk rename to Binding.AHK2/test/mode ahk.ahk diff --git a/AhkDll.Ahk/v2/test/type DD.ahk b/Binding.AHK2/test/type DD.ahk similarity index 52% rename from AhkDll.Ahk/v2/test/type DD.ahk rename to Binding.AHK2/test/type DD.ahk index b68fe6f..040fdb3 100644 --- a/AhkDll.Ahk/v2/test/type DD.ahk +++ b/Binding.AHK2/test/type DD.ahk @@ -1,3 +1,3 @@ -#Include "..\IbAhkSend.ahk" +#Include "..\IbInputSimulator.ahk" IbSendInit("DD") ;or IbSendInit("DD", 1, "C:\SomeDir\DD64.dll") -#include "mode ahk.ahk" \ No newline at end of file +#Include "mode ahk.ahk" \ No newline at end of file diff --git a/Binding.AHK2/test/type Logitech.ahk b/Binding.AHK2/test/type Logitech.ahk new file mode 100644 index 0000000..e1a275d --- /dev/null +++ b/Binding.AHK2/test/type Logitech.ahk @@ -0,0 +1,3 @@ +#Include "..\IbInputSimulator.ahk" +IbSendInit("Logitech") +#Include "mode ahk.ahk" \ No newline at end of file diff --git a/Binding.AHK2/test/type Razer.ahk b/Binding.AHK2/test/type Razer.ahk new file mode 100644 index 0000000..8bac062 --- /dev/null +++ b/Binding.AHK2/test/type Razer.ahk @@ -0,0 +1,3 @@ +#Include "..\IbInputSimulator.ahk" +IbSendInit("Razer") +#Include "mode ahk.ahk" \ No newline at end of file diff --git a/Binding.AHK2/test/type SendInput.ahk b/Binding.AHK2/test/type SendInput.ahk new file mode 100644 index 0000000..31431b7 --- /dev/null +++ b/Binding.AHK2/test/type SendInput.ahk @@ -0,0 +1,3 @@ +#Include "..\IbInputSimulator.ahk" +IbSendInit("SendInput") +#Include "mode ahk.ahk" \ No newline at end of file diff --git a/IbAhkSendLib.sln b/IbInputSimulator.sln similarity index 87% rename from IbAhkSendLib.sln rename to IbInputSimulator.sln index d40dc90..f11cde8 100644 --- a/IbAhkSendLib.sln +++ b/IbInputSimulator.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.31424.327 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AhkDll", "AhkDll\AhkDll.vcxproj", "{A8CC7E86-6E3F-4C18-BF47-F6AAF0AFEFA9}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simulator", "Simulator\Simulator.vcxproj", "{A8CC7E86-6E3F-4C18-BF47-F6AAF0AFEFA9}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AhkDll.Test", "AhkDll.Test\AhkDll.Test.vcxproj", "{F5AA5311-DD5F-43F8-805A-D0F4BB19D32F}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test\Test.vcxproj", "{F5AA5311-DD5F-43F8-805A-D0F4BB19D32F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/README.md b/README.md index 3586c24..cab935b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# IbAhkSendLib +# IbInputSimulator Languages: [English](README.md), [简体中文](README.zh-Hans.md) An [AutoHotkey](https://www.autohotkey.com/) library that enables AHK to send keystrokes by drivers. @@ -34,7 +34,7 @@ An [AutoHotkey](https://www.autohotkey.com/) library that enables AHK to send ke
; Run Notepad, type "Hello world!"
 ; and then select all text by mouse.
 
-#Include "IbAhkSend.ahk" +#Include "IbInputSimulator.ahk"
IbSendInit() ; IbSendInit("AnyDriver", 1)
@@ -51,7 +51,7 @@ MouseClickDrag("Left", 5, 5, 150, 50)

#Include %A_ScriptDir%
-#Include IbAhkSend.ahk +#Include IbInputSimulator.ahk
IbSendInit() ; IbSendInit("AnyDriver", 1)
diff --git a/README.zh-Hans.md b/README.zh-Hans.md index 25f02eb..0a48190 100644 --- a/README.zh-Hans.md +++ b/README.zh-Hans.md @@ -1,4 +1,4 @@ -# IbAhkSendLib +# IbInputSimulator 语言:[English](README.md),[简体中文](README.zh-Hans.md) [AutoHotkey](https://www.autohotkey.com/) 驱动按键库。 @@ -33,7 +33,7 @@
; 运行记事本,输入“Hello world!”并通过鼠标全选文本。
 
-#Include "IbAhkSend.ahk" +#Include "IbInputSimulator.ahk"
IbSendInit() ; IbSendInit("AnyDriver", 1)
@@ -49,7 +49,7 @@ MouseClickDrag("Left", 5, 5, 150, 50)

#Include %A_ScriptDir%
-#Include IbAhkSend.ahk +#Include IbInputSimulator.ahk
IbSendInit() ; IbSendInit("AnyDriver", 1)
diff --git a/AhkDll/API 2.cpp b/Simulator/API 2.cpp similarity index 96% rename from AhkDll/API 2.cpp rename to Simulator/API 2.cpp index 8ee3732..1122a0c 100644 --- a/AhkDll/API 2.cpp +++ b/Simulator/API 2.cpp @@ -1,6 +1,6 @@ #include "pch.h" #include -#include "IbAhkSend.hpp" +#include "IbInputSimulator.hpp" using namespace Send; diff --git a/AhkDll/API 3.cpp b/Simulator/API 3.cpp similarity index 99% rename from AhkDll/API 3.cpp rename to Simulator/API 3.cpp index 2abd7c4..6a422ee 100644 --- a/AhkDll/API 3.cpp +++ b/Simulator/API 3.cpp @@ -1,7 +1,7 @@ #include "pch.h" #include #include -#include "IbAhkSend.hpp" +#include "IbInputSimulator.hpp" using namespace Send; diff --git a/AhkDll/IbAhkSend.hpp b/Simulator/IbInputSimulator.hpp similarity index 99% rename from AhkDll/IbAhkSend.hpp rename to Simulator/IbInputSimulator.hpp index b5290f3..566e909 100644 --- a/AhkDll/IbAhkSend.hpp +++ b/Simulator/IbInputSimulator.hpp @@ -2,7 +2,7 @@ #include #include -#ifdef IB_AHKSEND_DLLEXPORT +#ifdef IB_INPUT_DLLEXPORT #define DLLAPI extern "C" __declspec(dllexport) #else #define DLLAPI extern "C" __declspec(dllimport) diff --git a/AhkDll/SendTypes/Base.hpp b/Simulator/SendTypes/Base.hpp similarity index 100% rename from AhkDll/SendTypes/Base.hpp rename to Simulator/SendTypes/Base.hpp diff --git a/AhkDll/SendTypes/DD.hpp b/Simulator/SendTypes/DD.hpp similarity index 100% rename from AhkDll/SendTypes/DD.hpp rename to Simulator/SendTypes/DD.hpp diff --git a/AhkDll/SendTypes/Logitech.hpp b/Simulator/SendTypes/Logitech.hpp similarity index 100% rename from AhkDll/SendTypes/Logitech.hpp rename to Simulator/SendTypes/Logitech.hpp diff --git a/AhkDll/SendTypes/Razer.hpp b/Simulator/SendTypes/Razer.hpp similarity index 100% rename from AhkDll/SendTypes/Razer.hpp rename to Simulator/SendTypes/Razer.hpp diff --git a/AhkDll/SendTypes/SendInput.hpp b/Simulator/SendTypes/SendInput.hpp similarity index 100% rename from AhkDll/SendTypes/SendInput.hpp rename to Simulator/SendTypes/SendInput.hpp diff --git a/AhkDll/SendTypes/Types.hpp b/Simulator/SendTypes/Types.hpp similarity index 100% rename from AhkDll/SendTypes/Types.hpp rename to Simulator/SendTypes/Types.hpp diff --git a/AhkDll/SendTypes/Usb.hpp b/Simulator/SendTypes/Usb.hpp similarity index 100% rename from AhkDll/SendTypes/Usb.hpp rename to Simulator/SendTypes/Usb.hpp diff --git a/AhkDll/AhkDll.vcxproj b/Simulator/Simulator.vcxproj similarity index 91% rename from AhkDll/AhkDll.vcxproj rename to Simulator/Simulator.vcxproj index 39fa493..eaf46a0 100644 --- a/AhkDll/AhkDll.vcxproj +++ b/Simulator/Simulator.vcxproj @@ -22,7 +22,7 @@ 16.0 Win32Proj {a8cc7e86-6e3f-4c18-bf47-f6aaf0afefa9} - AhkDll + Simulator 10.0 @@ -72,19 +72,19 @@ true - IbAhkSend + IbInputSimulator false - IbAhkSend + IbInputSimulator true - IbAhkSend + IbInputSimulator false - IbAhkSend + IbInputSimulator x64-windows-static-md @@ -96,7 +96,7 @@ Level3 true - IB_AHKSEND_DLLEXPORT;WIN32;_DEBUG;AHKDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + IB_INPUT_DLLEXPORT;WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true Use pch.h @@ -114,7 +114,7 @@ true true true - IB_AHKSEND_DLLEXPORT;WIN32;NDEBUG;AHKDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + IB_INPUT_DLLEXPORT;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true Use pch.h @@ -132,7 +132,7 @@ Level3 true - IB_AHKSEND_DLLEXPORT;_DEBUG;AHKDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + IB_INPUT_DLLEXPORT;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true Use pch.h @@ -150,7 +150,7 @@ true true true - IB_AHKSEND_DLLEXPORT;NDEBUG;AHKDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + IB_INPUT_DLLEXPORT;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true Use pch.h @@ -167,7 +167,7 @@ - + diff --git a/AhkDll/AhkDll.vcxproj.filters b/Simulator/Simulator.vcxproj.filters similarity index 98% rename from AhkDll/AhkDll.vcxproj.filters rename to Simulator/Simulator.vcxproj.filters index c584ac8..72e7558 100644 --- a/AhkDll/AhkDll.vcxproj.filters +++ b/Simulator/Simulator.vcxproj.filters @@ -27,7 +27,7 @@ Header Files - + Header Files diff --git a/AhkDll/common.hpp b/Simulator/common.hpp similarity index 90% rename from AhkDll/common.hpp rename to Simulator/common.hpp index ab07ffd..97ae47a 100644 --- a/AhkDll/common.hpp +++ b/Simulator/common.hpp @@ -1,5 +1,5 @@ #pragma once -#include "IbAhkSend.hpp" +#include "IbInputSimulator.hpp" using namespace Send; #include @@ -9,7 +9,7 @@ using ib::Byte; constexpr int debug = ib::debug_runtime; ib::DebugOStream<> DebugOStream() { - return { L"IbAhkSendLib: " }; + return { L"IbInputSimulator: " }; } template diff --git a/AhkDll/dllmain.cpp b/Simulator/dllmain.cpp similarity index 99% rename from AhkDll/dllmain.cpp rename to Simulator/dllmain.cpp index d3a2b81..7ea6312 100644 --- a/AhkDll/dllmain.cpp +++ b/Simulator/dllmain.cpp @@ -1,5 +1,5 @@ #include "pch.h" -#include "IbAhkSend.hpp" +#include "IbInputSimulator.hpp" using namespace Send; #include "SendTypes/Types.hpp" diff --git a/AhkDll/framework.h b/Simulator/framework.h similarity index 100% rename from AhkDll/framework.h rename to Simulator/framework.h diff --git a/AhkDll/pch.cpp b/Simulator/pch.cpp similarity index 100% rename from AhkDll/pch.cpp rename to Simulator/pch.cpp diff --git a/AhkDll/pch.h b/Simulator/pch.h similarity index 100% rename from AhkDll/pch.h rename to Simulator/pch.h diff --git a/AhkDll.Test/AhkDll.Test.cpp b/Test/Test.cpp similarity index 99% rename from AhkDll.Test/AhkDll.Test.cpp rename to Test/Test.cpp index 7ac097a..fa7bb51 100644 --- a/AhkDll.Test/AhkDll.Test.cpp +++ b/Test/Test.cpp @@ -1,7 +1,7 @@ -#include "../AhkDll/IbAhkSend.hpp" +#include "../Simulator/IbInputSimulator.hpp" using namespace Send; -#define BOOST_TEST_MODULE AhkDll.Test +#define BOOST_TEST_MODULE Test #include #include diff --git a/AhkDll.Test/AhkDll.Test.vcxproj b/Test/Test.vcxproj similarity index 98% rename from AhkDll.Test/AhkDll.Test.vcxproj rename to Test/Test.vcxproj index 2b46c66..3bb3057 100644 --- a/AhkDll.Test/AhkDll.Test.vcxproj +++ b/Test/Test.vcxproj @@ -22,7 +22,7 @@ 16.0 Win32Proj {f5aa5311-dd5f-43f8-805a-d0f4bb19d32f} - AhkDllTest + Test 10.0 @@ -155,10 +155,10 @@ - + - + {a8cc7e86-6e3f-4c18-bf47-f6aaf0afefa9} diff --git a/AhkDll.Test/AhkDll.Test.vcxproj.filters b/Test/Test.vcxproj.filters similarity index 96% rename from AhkDll.Test/AhkDll.Test.vcxproj.filters rename to Test/Test.vcxproj.filters index b8ccd0f..9c7f6e8 100644 --- a/AhkDll.Test/AhkDll.Test.vcxproj.filters +++ b/Test/Test.vcxproj.filters @@ -15,7 +15,7 @@ - + Source Files diff --git a/AhkDll.Test/Vk.hpp b/Test/Vk.hpp similarity index 100% rename from AhkDll.Test/Vk.hpp rename to Test/Vk.hpp From 173645a759f573e39a6fbc5dd4a6e5657a0ff77e Mon Sep 17 00:00:00 2001 From: Chaoses Ib Date: Fri, 14 Jan 2022 17:17:48 +0800 Subject: [PATCH 04/26] Docs: Update --- README.md | 6 +++--- README.zh-Hans.md | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index cab935b..9e160e1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # IbInputSimulator Languages: [English](README.md), [简体中文](README.zh-Hans.md) -An [AutoHotkey](https://www.autohotkey.com/) library that enables AHK to send keystrokes by drivers. +A library for simulating keyboard, mouse and other inputs. ## Supported Drivers * [Logitech G HUB](https://www.logitechg.com/innovation/g-hub.html) @@ -23,7 +23,8 @@ An [AutoHotkey](https://www.autohotkey.com/) library that enables AHK to send ke IbSendInit("DD", 1, "C:\SomeDir\DD64.dll") ``` -## Example +## Supported Languages +### AHK @@ -50,7 +51,6 @@ MouseClickDrag("Left", 5, 5, 150, 50) ; and then select all text by mouse.
#Include %A_ScriptDir% -
#Include IbInputSimulator.ahk
IbSendInit() ; IbSendInit("AnyDriver", 1) diff --git a/README.zh-Hans.md b/README.zh-Hans.md index 0a48190..bb00585 100644 --- a/README.zh-Hans.md +++ b/README.zh-Hans.md @@ -1,6 +1,6 @@ # IbInputSimulator 语言:[English](README.md),[简体中文](README.zh-Hans.md) -[AutoHotkey](https://www.autohotkey.com/) 驱动按键库。 +一个用于模拟键盘、鼠标和其它输入的库。 ## 支持驱动 * [罗技 G HUB](https://www.logitechg.com.cn/zh-cn/innovation/g-hub.html) @@ -23,7 +23,8 @@ IbSendInit("DD", 1, "C:\SomeDir\DD64.dll") ``` -## 例子 +## 支持语言 +### AHK
AHK v2
@@ -42,13 +43,12 @@ WinWaitActive("ahk_class #32770") Send("notepad`n")
WinWaitActive("ahk_exe notepad.exe") -Send("Hello world+1") +Send("Hello world{!}") Sleep(100) MouseClickDrag("Left", 5, 5, 150, 50) From 2417f5ff12c14a729298cbe12fcfb8e9b01e0aa3 Mon Sep 17 00:00:00 2001 From: Chaoses Ib Date: Tue, 1 Feb 2022 02:29:00 +0800 Subject: [PATCH 05/26] Remove PDB information --- Simulator/Simulator.vcxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Simulator/Simulator.vcxproj b/Simulator/Simulator.vcxproj index eaf46a0..64ac14c 100644 --- a/Simulator/Simulator.vcxproj +++ b/Simulator/Simulator.vcxproj @@ -126,6 +126,7 @@ true true false + /PDBALTPATH:https://github.com/Chaoses-Ib/IbInputSimulator %(AdditionalOptions) @@ -162,6 +163,7 @@ true true false + /PDBALTPATH:https://github.com/Chaoses-Ib/IbInputSimulator %(AdditionalOptions) From 025def47db44eb6d3d06581f7707715138b62497 Mon Sep 17 00:00:00 2001 From: Chaoses Ib Date: Fri, 4 Feb 2022 01:10:33 +0800 Subject: [PATCH 06/26] Remove PCH for simplicity --- Simulator/API 2.cpp | 3 +-- Simulator/API 3.cpp | 3 +-- Simulator/Simulator.vcxproj | 16 ++++----------- Simulator/Simulator.vcxproj.filters | 9 --------- Simulator/dllmain.cpp | 31 +++++++++++++++-------------- Simulator/framework.h | 5 ----- Simulator/pch.cpp | 5 ----- Simulator/pch.h | 13 ------------ 8 files changed, 22 insertions(+), 63 deletions(-) delete mode 100644 Simulator/framework.h delete mode 100644 Simulator/pch.cpp delete mode 100644 Simulator/pch.h diff --git a/Simulator/API 2.cpp b/Simulator/API 2.cpp index 1122a0c..ee732f3 100644 --- a/Simulator/API 2.cpp +++ b/Simulator/API 2.cpp @@ -1,5 +1,4 @@ -#include "pch.h" -#include +#include #include "IbInputSimulator.hpp" using namespace Send; diff --git a/Simulator/API 3.cpp b/Simulator/API 3.cpp index 6a422ee..085d1f3 100644 --- a/Simulator/API 3.cpp +++ b/Simulator/API 3.cpp @@ -1,5 +1,4 @@ -#include "pch.h" -#include +#include #include #include "IbInputSimulator.hpp" using namespace Send; diff --git a/Simulator/Simulator.vcxproj b/Simulator/Simulator.vcxproj index 64ac14c..04d216b 100644 --- a/Simulator/Simulator.vcxproj +++ b/Simulator/Simulator.vcxproj @@ -98,7 +98,7 @@ true IB_INPUT_DLLEXPORT;WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - Use + NotUsing pch.h stdcpplatest @@ -116,7 +116,7 @@ true IB_INPUT_DLLEXPORT;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - Use + NotUsing pch.h stdcpplatest @@ -135,7 +135,7 @@ true IB_INPUT_DLLEXPORT;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - Use + NotUsing pch.h stdcpplatest @@ -153,7 +153,7 @@ true IB_INPUT_DLLEXPORT;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - Use + NotUsing pch.h stdcpplatest @@ -168,9 +168,7 @@ - - @@ -183,12 +181,6 @@ - - Create - Create - Create - Create - diff --git a/Simulator/Simulator.vcxproj.filters b/Simulator/Simulator.vcxproj.filters index 72e7558..ad0fe5a 100644 --- a/Simulator/Simulator.vcxproj.filters +++ b/Simulator/Simulator.vcxproj.filters @@ -18,12 +18,6 @@ - - Header Files - - - Header Files - Header Files @@ -56,9 +50,6 @@ Source Files - - Source Files - Source Files diff --git a/Simulator/dllmain.cpp b/Simulator/dllmain.cpp index 7ea6312..eb00718 100644 --- a/Simulator/dllmain.cpp +++ b/Simulator/dllmain.cpp @@ -1,5 +1,4 @@ -#include "pch.h" -#include "IbInputSimulator.hpp" +#include "IbInputSimulator.hpp" using namespace Send; #include "SendTypes/Types.hpp" @@ -24,7 +23,9 @@ BOOL APIENTRY DllMain( HMODULE hModule, return TRUE; } -static std::unique_ptr send; +namespace main { + static std::unique_ptr send; +} class SendInputHook { public: @@ -33,7 +34,7 @@ class SendInputHook { if (!hook) return SendInput_real(cInputs, pInputs, cbSize); - return send->send_input(pInputs, cInputs); + return main::send->send_input(pInputs, cInputs); } //#TODO: only needed when two or more AHK processes exist? @@ -43,8 +44,8 @@ class SendInputHook { return GetAsyncKeyState_real(vKey); if constexpr (debug) - DebugOStream() << L"GetAsyncKeyState: " << vKey << ", " << send->get_key_state(vKey) << std::endl; - return send->get_key_state(vKey); + DebugOStream() << L"GetAsyncKeyState: " << vKey << ", " << main::send->get_key_state(vKey) << std::endl; + return main::send->get_key_state(vKey); } public: @@ -105,7 +106,7 @@ DLLAPI Send::Error __stdcall IbSendInit(SendType type, InitFlags flags, void* ar Error error = type->create(&SendInputHook::SendInput_real); if (error != Error::Success) return error; - send = std::move(type); + main::send = std::move(type); } break; case SendType::Logitech: @@ -115,7 +116,7 @@ DLLAPI Send::Error __stdcall IbSendInit(SendType type, InitFlags flags, void* ar Error error = type->create(); if (error != Error::Success) return error; - send = std::move(type); + main::send = std::move(type); } break; case SendType::Razer: @@ -125,7 +126,7 @@ DLLAPI Send::Error __stdcall IbSendInit(SendType type, InitFlags flags, void* ar Error error = type->create(); if (error != Error::Success) return error; - send = std::move(type); + main::send = std::move(type); } break; case SendType::DD: @@ -135,7 +136,7 @@ DLLAPI Send::Error __stdcall IbSendInit(SendType type, InitFlags flags, void* ar Error error = type->create(ib::Addr(argument)); if (error != Error::Success) return error; - send = std::move(type); + main::send = std::move(type); } break; default: @@ -148,14 +149,14 @@ DLLAPI Send::Error __stdcall IbSendInit(SendType type, InitFlags flags, void* ar DLLAPI void __stdcall IbSendDestroy() { IbSendInputHook(HookCode::Destroy); - if (!send) + if (!main::send) return; - send->destroy(); - send.release(); + main::send->destroy(); + main::send.release(); } DLLAPI void __stdcall IbSendSyncKeyStates() { - send->sync_key_states(); + main::send->sync_key_states(); } DLLAPI UINT WINAPI IbSendInput( @@ -163,5 +164,5 @@ DLLAPI UINT WINAPI IbSendInput( _In_reads_(cInputs) LPINPUT pInputs, _In_ int cbSize ) { - return send->send_input(pInputs, cInputs); + return main::send->send_input(pInputs, cInputs); } \ No newline at end of file diff --git a/Simulator/framework.h b/Simulator/framework.h deleted file mode 100644 index f80ad8f..0000000 --- a/Simulator/framework.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files -#include diff --git a/Simulator/pch.cpp b/Simulator/pch.cpp deleted file mode 100644 index 64b7eef..0000000 --- a/Simulator/pch.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// pch.cpp: source file corresponding to the pre-compiled header - -#include "pch.h" - -// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/Simulator/pch.h b/Simulator/pch.h deleted file mode 100644 index 885d5d6..0000000 --- a/Simulator/pch.h +++ /dev/null @@ -1,13 +0,0 @@ -// pch.h: This is a precompiled header file. -// Files listed below are compiled only once, improving build performance for future builds. -// This also affects IntelliSense performance, including code completion and many code browsing features. -// However, files listed here are ALL re-compiled if any one of them is updated between builds. -// Do not add files here that you will be updating frequently as this negates the performance advantage. - -#ifndef PCH_H -#define PCH_H - -// add headers that you want to pre-compile here -#include "framework.h" - -#endif //PCH_H From fe1a459784faf9393bd0afe40295c4c5229d0948 Mon Sep 17 00:00:00 2001 From: Chaoses Ib Date: Sat, 2 Apr 2022 19:36:09 +0800 Subject: [PATCH 07/26] Organize the project using CMake --- .gitattributes | 63 --- .gitignore | 367 +----------------- CMakeLists.txt | 5 + IbInputSimulator.sln | 41 -- README.md | 29 +- README.zh-Hans.md | 12 +- Simulator/CMakeLists.txt | 62 +++ Simulator/Simulator.vcxproj | 191 --------- Simulator/Simulator.vcxproj.filters | 60 --- .../IbInputSimulator/InputSimulator.hpp} | 2 +- .../IbInputSimulator}/SendTypes/DD.hpp | 4 +- .../IbInputSimulator}/SendTypes/Logitech.hpp | 4 +- .../IbInputSimulator}/SendTypes/Razer.hpp | 4 +- .../IbInputSimulator}/SendTypes/SendInput.hpp | 2 +- .../IbInputSimulator/SendTypes/base.hpp} | 4 +- .../IbInputSimulator/SendTypes/types.hpp} | 2 +- .../IbInputSimulator/SendTypes/usb.hpp} | 8 +- .../{ => include/IbInputSimulator}/common.hpp | 4 +- Simulator/{ => source}/API 2.cpp | 2 +- Simulator/{ => source}/API 3.cpp | 2 +- Simulator/{ => source}/dllmain.cpp | 6 +- Test/Test.cpp => Simulator/test/test.cpp | 4 +- Test/Vk.hpp => Simulator/test/vk.hpp | 0 Test/Test.vcxproj | 174 --------- Test/Test.vcxproj.filters | 27 -- 25 files changed, 114 insertions(+), 965 deletions(-) delete mode 100644 .gitattributes create mode 100644 CMakeLists.txt delete mode 100644 IbInputSimulator.sln create mode 100644 Simulator/CMakeLists.txt delete mode 100644 Simulator/Simulator.vcxproj delete mode 100644 Simulator/Simulator.vcxproj.filters rename Simulator/{IbInputSimulator.hpp => include/IbInputSimulator/InputSimulator.hpp} (99%) rename Simulator/{ => include/IbInputSimulator}/SendTypes/DD.hpp (99%) rename Simulator/{ => include/IbInputSimulator}/SendTypes/Logitech.hpp (99%) rename Simulator/{ => include/IbInputSimulator}/SendTypes/Razer.hpp (99%) rename Simulator/{ => include/IbInputSimulator}/SendTypes/SendInput.hpp (98%) rename Simulator/{SendTypes/Base.hpp => include/IbInputSimulator/SendTypes/base.hpp} (97%) rename Simulator/{SendTypes/Types.hpp => include/IbInputSimulator/SendTypes/types.hpp} (93%) rename Simulator/{SendTypes/Usb.hpp => include/IbInputSimulator/SendTypes/usb.hpp} (97%) rename Simulator/{ => include/IbInputSimulator}/common.hpp (90%) rename Simulator/{ => source}/API 2.cpp (95%) rename Simulator/{ => source}/API 3.cpp (99%) rename Simulator/{ => source}/dllmain.cpp (97%) rename Test/Test.cpp => Simulator/test/test.cpp (98%) rename Test/Vk.hpp => Simulator/test/vk.hpp (100%) delete mode 100644 Test/Test.vcxproj delete mode 100644 Test/Test.vcxproj.filters diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1ff0c42..0000000 --- a/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 52cba31..6856362 100644 --- a/.gitignore +++ b/.gitignore @@ -1,365 +1,6 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +build/ +IbInputSimulator.dll -*.dll - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Oo]ut/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory .vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +out/ +CMakeSettings.json \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..dbbc004 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.14) + +project(IbInputSimulator) + +add_subdirectory(Simulator) \ No newline at end of file diff --git a/IbInputSimulator.sln b/IbInputSimulator.sln deleted file mode 100644 index f11cde8..0000000 --- a/IbInputSimulator.sln +++ /dev/null @@ -1,41 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31424.327 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simulator", "Simulator\Simulator.vcxproj", "{A8CC7E86-6E3F-4C18-BF47-F6AAF0AFEFA9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test\Test.vcxproj", "{F5AA5311-DD5F-43F8-805A-D0F4BB19D32F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A8CC7E86-6E3F-4C18-BF47-F6AAF0AFEFA9}.Debug|x64.ActiveCfg = Debug|x64 - {A8CC7E86-6E3F-4C18-BF47-F6AAF0AFEFA9}.Debug|x64.Build.0 = Debug|x64 - {A8CC7E86-6E3F-4C18-BF47-F6AAF0AFEFA9}.Debug|x86.ActiveCfg = Debug|Win32 - {A8CC7E86-6E3F-4C18-BF47-F6AAF0AFEFA9}.Debug|x86.Build.0 = Debug|Win32 - {A8CC7E86-6E3F-4C18-BF47-F6AAF0AFEFA9}.Release|x64.ActiveCfg = Release|x64 - {A8CC7E86-6E3F-4C18-BF47-F6AAF0AFEFA9}.Release|x64.Build.0 = Release|x64 - {A8CC7E86-6E3F-4C18-BF47-F6AAF0AFEFA9}.Release|x86.ActiveCfg = Release|Win32 - {A8CC7E86-6E3F-4C18-BF47-F6AAF0AFEFA9}.Release|x86.Build.0 = Release|Win32 - {F5AA5311-DD5F-43F8-805A-D0F4BB19D32F}.Debug|x64.ActiveCfg = Debug|x64 - {F5AA5311-DD5F-43F8-805A-D0F4BB19D32F}.Debug|x64.Build.0 = Debug|x64 - {F5AA5311-DD5F-43F8-805A-D0F4BB19D32F}.Debug|x86.ActiveCfg = Debug|Win32 - {F5AA5311-DD5F-43F8-805A-D0F4BB19D32F}.Debug|x86.Build.0 = Debug|Win32 - {F5AA5311-DD5F-43F8-805A-D0F4BB19D32F}.Release|x64.ActiveCfg = Release|x64 - {F5AA5311-DD5F-43F8-805A-D0F4BB19D32F}.Release|x64.Build.0 = Release|x64 - {F5AA5311-DD5F-43F8-805A-D0F4BB19D32F}.Release|x86.ActiveCfg = Release|Win32 - {F5AA5311-DD5F-43F8-805A-D0F4BB19D32F}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {DFCAC607-BB86-42CE-8EE7-54D7FE8BAA13} - EndGlobalSection -EndGlobal diff --git a/README.md b/README.md index 9e160e1..3a09156 100644 --- a/README.md +++ b/README.md @@ -72,17 +72,24 @@ MouseClickDrag, Left, 5, 5, 150, 50 [Releases](../../releases) ## Building -1. Put [IbWinCppLib](https://github.com/Chaoses-Ib/IbWinCppLib/tree/master/WinCppLib/IbWinCppLib) in `C:\L\C++\packages` (in other locations you need to modify the .vcxproj files). -1. [vcpkg](https://github.com/microsoft/vcpkg) - ``` - set VCPKG_DEFAULT_TRIPLET=x64-windows-static-md - vcpkg install detours rapidjson - ``` - For Test project you also need: - ``` - vcpkg install boost-test fmt - ``` - Change VCPKG_DEFAULT_TRIPLET to x86-windows-static-md if you need x86 version. +[vcpkg](https://github.com/microsoft/vcpkg): +``` +set VCPKG_DEFAULT_TRIPLET=x64-windows-static-md +vcpkg install detours rapidjson +``` +CMake: +``` +mkdir build +cd build +cmake .. -DCMAKE_TOOLCHAIN_FILE="C:\...\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows-static-md +cmake --build . --config Release +``` + +For the test you also need: +``` +vcpkg install boost-test fmt +``` +And add `-DBUILD_TESTING=ON` when calling `cmake ..` . ## See Also * [IbLogiSoftExt](https://github.com/Chaoses-Ib/IbLogiSoftExt) diff --git a/README.zh-Hans.md b/README.zh-Hans.md index bb00585..bf2e755 100644 --- a/README.zh-Hans.md +++ b/README.zh-Hans.md @@ -70,17 +70,7 @@ MouseClickDrag, Left, 5, 5, 150, 50 [Releases](../../releases) ## 构建 -1. 将 [IbWinCppLib](https://github.com/Chaoses-Ib/IbWinCppLib/tree/master/WinCppLib/IbWinCppLib) 放入 `C:\L\C++\packages`(其它位置需要修改 .vcxproj 文件)。 -1. [vcpkg](https://github.com/microsoft/vcpkg) - ``` - set VCPKG_DEFAULT_TRIPLET=x64-windows-static-md - vcpkg install detours rapidjson - ``` - Test 项目还需要: - ``` - vcpkg install boost-test fmt - ``` - 如果需要 x86 版本就把 VCPKG_DEFAULT_TRIPLET 改为 x86-windows-static-md。 +[Building](README.md#Building) ## 相关推荐 * [IbLogiSoftExt](https://github.com/Chaoses-Ib/IbLogiSoftExt) diff --git a/Simulator/CMakeLists.txt b/Simulator/CMakeLists.txt new file mode 100644 index 0000000..dae624e --- /dev/null +++ b/Simulator/CMakeLists.txt @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 3.14) + +project(IbInputSimulator) + +# IbWinCppLib +include(FetchContent) +FetchContent_Declare(IbWinCpp + GIT_REPOSITORY https://github.com/Chaoses-Ib/IbWinCppLib.git + GIT_TAG a29ac95537f403ac5ae221cb744d3e82076efbf7 +) +FetchContent_MakeAvailable(IbWinCpp) + +# Detours +find_path(DETOURS_INCLUDE_DIR detours/detours.h) +find_library(DETOURS_LIBRARY detours) + +# RapidJSON +find_package(RapidJSON CONFIG REQUIRED) + + +set(sourceFiles + dllmain.cpp + "API 2.cpp" + "API 3.cpp" +) +list(TRANSFORM sourceFiles PREPEND source/) +add_library(IbInputSimulator SHARED ${sourceFiles}) +target_compile_features(IbInputSimulator PUBLIC cxx_std_20) +target_compile_definitions(IbInputSimulator PRIVATE IB_INPUT_DLLEXPORT) + +target_include_directories(IbInputSimulator + PUBLIC include + PRIVATE ${DETOURS_INCLUDE_DIR} +) +target_link_libraries(IbInputSimulator + PRIVATE IbWinCpp + PRIVATE ${DETOURS_LIBRARY} + PRIVATE rapidjson +) + +# Test +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + option(BUILD_TESTING "Build the testing tree." OFF) + include(CTest) + if(BUILD_TESTING) + find_package(Boost REQUIRED COMPONENTS unit_test_framework) + find_package(fmt CONFIG REQUIRED) + + set(testFiles + test.cpp + ) + list(TRANSFORM testFiles PREPEND test/) + + add_executable(IbInputSimulator_Test ${testFiles}) + target_link_libraries(IbInputSimulator_Test + PRIVATE IbInputSimulator + PRIVATE Boost::unit_test_framework + PRIVATE IbWinCpp + PRIVATE fmt::fmt + ) + endif() +endif() \ No newline at end of file diff --git a/Simulator/Simulator.vcxproj b/Simulator/Simulator.vcxproj deleted file mode 100644 index 04d216b..0000000 --- a/Simulator/Simulator.vcxproj +++ /dev/null @@ -1,191 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {a8cc7e86-6e3f-4c18-bf47-f6aaf0afefa9} - Simulator - 10.0 - - - - DynamicLibrary - true - v142 - Unicode - - - DynamicLibrary - false - v142 - true - Unicode - - - DynamicLibrary - true - v142 - Unicode - - - DynamicLibrary - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - IbInputSimulator - - - false - IbInputSimulator - - - true - IbInputSimulator - - - false - IbInputSimulator - - - x64-windows-static-md - - - x64-windows-static-md - - - - Level3 - true - IB_INPUT_DLLEXPORT;WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - NotUsing - pch.h - stdcpplatest - - - Windows - true - false - - - - - Level3 - true - true - true - IB_INPUT_DLLEXPORT;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - NotUsing - pch.h - stdcpplatest - - - Windows - true - true - true - false - /PDBALTPATH:https://github.com/Chaoses-Ib/IbInputSimulator %(AdditionalOptions) - - - - - Level3 - true - IB_INPUT_DLLEXPORT;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - NotUsing - pch.h - stdcpplatest - - - Windows - true - false - - - - - Level3 - true - true - true - IB_INPUT_DLLEXPORT;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - NotUsing - pch.h - stdcpplatest - - - Windows - true - true - true - false - /PDBALTPATH:https://github.com/Chaoses-Ib/IbInputSimulator %(AdditionalOptions) - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Simulator/Simulator.vcxproj.filters b/Simulator/Simulator.vcxproj.filters deleted file mode 100644 index ad0fe5a..0000000 --- a/Simulator/Simulator.vcxproj.filters +++ /dev/null @@ -1,60 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {229d1540-5c12-4cc0-b2c5-98a5630b8472} - - - - - Header Files - - - Header Files - - - Header Files\SendTypes - - - Header Files\SendTypes - - - Header Files\SendTypes - - - Header Files\SendTypes - - - Header Files\SendTypes - - - Header Files\SendTypes - - - Header Files\SendTypes - - - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/Simulator/IbInputSimulator.hpp b/Simulator/include/IbInputSimulator/InputSimulator.hpp similarity index 99% rename from Simulator/IbInputSimulator.hpp rename to Simulator/include/IbInputSimulator/InputSimulator.hpp index 566e909..d6817ba 100644 --- a/Simulator/IbInputSimulator.hpp +++ b/Simulator/include/IbInputSimulator/InputSimulator.hpp @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/Simulator/SendTypes/DD.hpp b/Simulator/include/IbInputSimulator/SendTypes/DD.hpp similarity index 99% rename from Simulator/SendTypes/DD.hpp rename to Simulator/include/IbInputSimulator/SendTypes/DD.hpp index 355e3d8..15ec146 100644 --- a/Simulator/SendTypes/DD.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/DD.hpp @@ -1,7 +1,7 @@ #pragma once -#include +#include -#include "Base.hpp" +#include "base.hpp" namespace Send::Type::Internal { class DD final : virtual public Base, public VirtualKeyStates { diff --git a/Simulator/SendTypes/Logitech.hpp b/Simulator/include/IbInputSimulator/SendTypes/Logitech.hpp similarity index 99% rename from Simulator/SendTypes/Logitech.hpp rename to Simulator/include/IbInputSimulator/SendTypes/Logitech.hpp index 6c3a458..e492b34 100644 --- a/Simulator/SendTypes/Logitech.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/Logitech.hpp @@ -3,8 +3,8 @@ #include #include #include "../common.hpp" -#include "Base.hpp" -#include "Usb.hpp" +#include "base.hpp" +#include "usb.hpp" namespace Send::Type::Internal { class LogitechDriver { diff --git a/Simulator/SendTypes/Razer.hpp b/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp similarity index 99% rename from Simulator/SendTypes/Razer.hpp rename to Simulator/include/IbInputSimulator/SendTypes/Razer.hpp index 7ae3ad6..4da7aa8 100644 --- a/Simulator/SendTypes/Razer.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp @@ -1,6 +1,6 @@ #pragma once -#include "Base.hpp" -#include "Usb.hpp" +#include "base.hpp" +#include "usb.hpp" namespace Send::Type::Internal { class Razer final : virtual public Base, public VirtualKeyStates { diff --git a/Simulator/SendTypes/SendInput.hpp b/Simulator/include/IbInputSimulator/SendTypes/SendInput.hpp similarity index 98% rename from Simulator/SendTypes/SendInput.hpp rename to Simulator/include/IbInputSimulator/SendTypes/SendInput.hpp index 4309b96..dfaf406 100644 --- a/Simulator/SendTypes/SendInput.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/SendInput.hpp @@ -1,5 +1,5 @@ #pragma once -#include "Base.hpp" +#include "base.hpp" namespace Send::Type::Internal { class SendInput final : virtual public Base { diff --git a/Simulator/SendTypes/Base.hpp b/Simulator/include/IbInputSimulator/SendTypes/base.hpp similarity index 97% rename from Simulator/SendTypes/Base.hpp rename to Simulator/include/IbInputSimulator/SendTypes/base.hpp index 14e9a0d..116d410 100644 --- a/Simulator/SendTypes/Base.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/base.hpp @@ -1,7 +1,7 @@ #pragma once #include "../common.hpp" #include -#include +#include #include #pragma comment(lib, "ntdll.lib") @@ -66,7 +66,7 @@ namespace Send::Type::Internal { POINT point; GetCursorPos(&point); if constexpr (debug) - ib::DebugOStream() << L"mouse_screen_to_relative: cursor (" << point.x << L", " << point.y << L") to point (" << screen_point.x << L", " << screen_point.y << L")\n"; + DebugOStream() << L"mouse_screen_to_relative: cursor (" << point.x << L", " << point.y << L") to point (" << screen_point.x << L", " << screen_point.y << L")\n"; screen_point.x -= point.x; screen_point.y -= point.y; } diff --git a/Simulator/SendTypes/Types.hpp b/Simulator/include/IbInputSimulator/SendTypes/types.hpp similarity index 93% rename from Simulator/SendTypes/Types.hpp rename to Simulator/include/IbInputSimulator/SendTypes/types.hpp index 83861c1..657e1f3 100644 --- a/Simulator/SendTypes/Types.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/types.hpp @@ -1,5 +1,5 @@ #pragma once -#include "Base.hpp" +#include "base.hpp" #include "SendInput.hpp" #include "Logitech.hpp" #include "Razer.hpp" diff --git a/Simulator/SendTypes/Usb.hpp b/Simulator/include/IbInputSimulator/SendTypes/usb.hpp similarity index 97% rename from Simulator/SendTypes/Usb.hpp rename to Simulator/include/IbInputSimulator/SendTypes/usb.hpp index 02300ae..32fbca5 100644 --- a/Simulator/SendTypes/Usb.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/usb.hpp @@ -198,13 +198,13 @@ namespace Send::Type::Internal { case 0xFE: return 0x0000; //VK_OEM_CLEAR case 0xFF: return 0x0000; default: - if ('A' <= vkCode and vkCode <= 'Z') + if ('A' <= vkCode && vkCode <= 'Z') return 0x04 + vkCode - 'A'; - else if ('0' <= vkCode and vkCode <= '9') + else if ('0' <= vkCode && vkCode <= '9') return vkCode == '0' ? 0x27 : 0x1E + vkCode - '1'; - else if (VK_NUMPAD0 <= vkCode and vkCode <= VK_NUMPAD9) + else if (VK_NUMPAD0 <= vkCode && vkCode <= VK_NUMPAD9) return vkCode == VK_NUMPAD0 ? 0x62 : 0x59 + vkCode - VK_NUMPAD1; - else if (VK_F1 <= vkCode and vkCode <= VK_F24) + else if (VK_F1 <= vkCode && vkCode <= VK_F24) return vkCode <= VK_F12 ? 0x3A + vkCode - VK_F1 : 0x68 + vkCode - VK_F13; diff --git a/Simulator/common.hpp b/Simulator/include/IbInputSimulator/common.hpp similarity index 90% rename from Simulator/common.hpp rename to Simulator/include/IbInputSimulator/common.hpp index 97ae47a..25cff88 100644 --- a/Simulator/common.hpp +++ b/Simulator/include/IbInputSimulator/common.hpp @@ -1,9 +1,9 @@ #pragma once -#include "IbInputSimulator.hpp" +#include "InputSimulator.hpp" using namespace Send; #include -#include +#include using ib::Byte; constexpr int debug = ib::debug_runtime; diff --git a/Simulator/API 2.cpp b/Simulator/source/API 2.cpp similarity index 95% rename from Simulator/API 2.cpp rename to Simulator/source/API 2.cpp index ee732f3..04926f8 100644 --- a/Simulator/API 2.cpp +++ b/Simulator/source/API 2.cpp @@ -1,5 +1,5 @@ #include -#include "IbInputSimulator.hpp" +#include using namespace Send; diff --git a/Simulator/API 3.cpp b/Simulator/source/API 3.cpp similarity index 99% rename from Simulator/API 3.cpp rename to Simulator/source/API 3.cpp index 085d1f3..da42f4d 100644 --- a/Simulator/API 3.cpp +++ b/Simulator/source/API 3.cpp @@ -1,6 +1,6 @@ #include #include -#include "IbInputSimulator.hpp" +#include using namespace Send; diff --git a/Simulator/dllmain.cpp b/Simulator/source/dllmain.cpp similarity index 97% rename from Simulator/dllmain.cpp rename to Simulator/source/dllmain.cpp index eb00718..f0c5a6e 100644 --- a/Simulator/dllmain.cpp +++ b/Simulator/source/dllmain.cpp @@ -1,7 +1,7 @@ -#include "IbInputSimulator.hpp" +#include using namespace Send; -#include "SendTypes/Types.hpp" +#include BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, @@ -73,7 +73,7 @@ DLLAPI void __stdcall IbSendInputHook(HookCode code) { sendinput_hook.destroy(); break; case HookCode::On: - if (!sendinput_hook.has_created()) + if (!sendinput_hook.created()) sendinput_hook.create(); sendinput_hook->hook = true; break; diff --git a/Test/Test.cpp b/Simulator/test/test.cpp similarity index 98% rename from Test/Test.cpp rename to Simulator/test/test.cpp index fa7bb51..c325f0b 100644 --- a/Test/Test.cpp +++ b/Simulator/test/test.cpp @@ -1,4 +1,4 @@ -#include "../Simulator/IbInputSimulator.hpp" +#include using namespace Send; #define BOOST_TEST_MODULE Test @@ -9,7 +9,7 @@ using namespace Send; #include #include #include -#include +#include #include "Vk.hpp" diff --git a/Test/Vk.hpp b/Simulator/test/vk.hpp similarity index 100% rename from Test/Vk.hpp rename to Simulator/test/vk.hpp diff --git a/Test/Test.vcxproj b/Test/Test.vcxproj deleted file mode 100644 index 3bb3057..0000000 --- a/Test/Test.vcxproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {f5aa5311-dd5f-43f8-805a-d0f4bb19d32f} - Test - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - x64-windows-static-md - - - x64-windows-static-md - - - x86-windows-static-md - - - x86-windows-static-md - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpplatest - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpplatest - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpplatest - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpplatest - - - Console - true - true - true - - - - - - - - {a8cc7e86-6e3f-4c18-bf47-f6aaf0afefa9} - - - - - - - - - - - - \ No newline at end of file diff --git a/Test/Test.vcxproj.filters b/Test/Test.vcxproj.filters deleted file mode 100644 index 9c7f6e8..0000000 --- a/Test/Test.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Header Files - - - \ No newline at end of file From b12b23db75351bd0b3894e9b4579c50fec05d055 Mon Sep 17 00:00:00 2001 From: Chaoses Ib Date: Sun, 3 Jul 2022 18:11:31 +0800 Subject: [PATCH 08/26] Add support for MouClassInputInjection --- Binding.AHK1/IbInputSimulator.ahk | 4 + .../test/type MouClassInputInjection.ahk | 7 + Binding.AHK2/IbInputSimulator.ahk | 4 + .../test/type MouClassInputInjection.ahk | 4 + README.md | 7 +- README.zh-Hans.md | 2 + Simulator/CMakeLists.txt | 5 +- .../IbInputSimulator/InputSimulator.hpp | 3 +- .../SendTypes/MouClassInputInjection.hpp | 144 ++++++++++++++++++ .../SendTypes/MouClassInputInjection/ioctl.h | 113 ++++++++++++++ .../IbInputSimulator/SendTypes/types.hpp | 2 + Simulator/source/dllmain.cpp | 13 ++ 12 files changed, 303 insertions(+), 5 deletions(-) create mode 100644 Binding.AHK1/test/type MouClassInputInjection.ahk create mode 100644 Binding.AHK2/test/type MouClassInputInjection.ahk create mode 100644 Simulator/include/IbInputSimulator/SendTypes/MouClassInputInjection.hpp create mode 100644 Simulator/include/IbInputSimulator/SendTypes/MouClassInputInjection/ioctl.h diff --git a/Binding.AHK1/IbInputSimulator.ahk b/Binding.AHK1/IbInputSimulator.ahk index f3d5602..ba7cdbb 100644 --- a/Binding.AHK1/IbInputSimulator.ahk +++ b/Binding.AHK1/IbInputSimulator.ahk @@ -31,6 +31,10 @@ IbSendInit(send_type := "AnyDriver", mode := 1, args*){ result := DllCall("IbInputSimulator\IbSendInit", "Int", 4, "Int", 0, "WStr", args[1], "Int") else result := DllCall("IbInputSimulator\IbSendInit", "Int", 4, "Int", 0, "Ptr", 0, "Int") + } else if (send_type == "MouClassInputInjection"){ + if (args.MaxIndex() != 1) + throw "MouClassInputInjection: Please specify the process ID of the target process" + result := DllCall("IbInputSimulator\IbSendInit", "Int", 5, "Int", 0, "UInt64", args[1], "Int") } else throw "Invalid send type" diff --git a/Binding.AHK1/test/type MouClassInputInjection.ahk b/Binding.AHK1/test/type MouClassInputInjection.ahk new file mode 100644 index 0000000..7532086 --- /dev/null +++ b/Binding.AHK1/test/type MouClassInputInjection.ahk @@ -0,0 +1,7 @@ +#Include %A_ScriptDir% +#Include ..\IbInputSimulator.ahk +InputBox, pid, , Please specify the process ID of the target process +IbSendInit("MouClassInputInjection", 1, pid) + +;MouseClickDrag, Left, 5, 5, 150, 50, 0, R +SendInput {Click 100 100} \ No newline at end of file diff --git a/Binding.AHK2/IbInputSimulator.ahk b/Binding.AHK2/IbInputSimulator.ahk index 7db94dd..99996ff 100644 --- a/Binding.AHK2/IbInputSimulator.ahk +++ b/Binding.AHK2/IbInputSimulator.ahk @@ -31,6 +31,10 @@ IbSendInit(send_type := "AnyDriver", mode := 1, args*){ result := DllCall("IbInputSimulator\IbSendInit", "Int", 4, "Int", 0, "WStr", args[1], "Int") else result := DllCall("IbInputSimulator\IbSendInit", "Int", 4, "Int", 0, "Ptr", 0, "Int") + } else if (send_type == "MouClassInputInjection"){ + if (args.Length != 1) + throw "MouClassInputInjection: Please specify the process ID of the target process" + result := DllCall("IbInputSimulator\IbSendInit", "Int", 5, "Int", 0, "UInt64", args[1], "Int") } else throw "Invalid send type" diff --git a/Binding.AHK2/test/type MouClassInputInjection.ahk b/Binding.AHK2/test/type MouClassInputInjection.ahk new file mode 100644 index 0000000..9ea3647 --- /dev/null +++ b/Binding.AHK2/test/type MouClassInputInjection.ahk @@ -0,0 +1,4 @@ +#Include "..\IbInputSimulator.ahk" +pid := InputBox("Please specify the process ID of the target process") +IbSendInit("MouClassInputInjection", 1, pid) +#Include "mode ahk.ahk" \ No newline at end of file diff --git a/README.md b/README.md index 3a09156..b97506b 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ A library for simulating keyboard, mouse and other inputs. * [Razer Synapse 3](https://www.razer.com/synapse-3) No Razer hardware required, but it will be safer if you have one. e.g. `IbSendInit("Razer")` +* [MouClassInputInjection](https://github.com/Chaoses-Ib/MouClassInputInjection) + e.g. `IbSendInit("MouClassInputInjection", 1, process_id)` * [DD Virtual Mouse & Virtual Keyboard](https://github.com/ddxoft/master) May cause a blue screen; difficult to uninstall cleanly; need network. To use it, put the DLL (`DD94687.64.dll`/`DD64.dll`/`DDHID64.dll`) with your script file, and then: @@ -74,14 +76,13 @@ MouseClickDrag, Left, 5, 5, 150, 50 ## Building [vcpkg](https://github.com/microsoft/vcpkg): ``` -set VCPKG_DEFAULT_TRIPLET=x64-windows-static-md -vcpkg install detours rapidjson +vcpkg install detours rapidjson --triplet==x64-windows-static ``` CMake: ``` mkdir build cd build -cmake .. -DCMAKE_TOOLCHAIN_FILE="C:\...\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows-static-md +cmake .. -DCMAKE_TOOLCHAIN_FILE="C:\...\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows-static cmake --build . --config Release ``` diff --git a/README.zh-Hans.md b/README.zh-Hans.md index bf2e755..ee120a2 100644 --- a/README.zh-Hans.md +++ b/README.zh-Hans.md @@ -12,6 +12,8 @@ * [雷蛇雷云3](http://cn.razerzone.com/synapse-3) 不需要雷蛇硬件,不过如果有的话会更安全。 用例:`IbSendInit("Razer")` +* [MouClassInputInjection](https://github.com/Chaoses-Ib/MouClassInputInjection) + 用例:`IbSendInit("MouClassInputInjection", 1, process_id)` * [DD 虚拟鼠标 & 虚拟键盘](https://github.com/ddxoft/master) 可能会导致蓝屏;难以卸载干净;需要联网。 使用时需要把 DLL 文件(`DD94687.64.dll`/`DD64.dll`/`DDHID64.dll`)与你的脚本文件放到一起,然后: diff --git a/Simulator/CMakeLists.txt b/Simulator/CMakeLists.txt index dae624e..97ba3db 100644 --- a/Simulator/CMakeLists.txt +++ b/Simulator/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.15) project(IbInputSimulator) @@ -25,6 +25,9 @@ set(sourceFiles ) list(TRANSFORM sourceFiles PREPEND source/) add_library(IbInputSimulator SHARED ${sourceFiles}) +set_property(TARGET IbInputSimulator PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" +) target_compile_features(IbInputSimulator PUBLIC cxx_std_20) target_compile_definitions(IbInputSimulator PRIVATE IB_INPUT_DLLEXPORT) diff --git a/Simulator/include/IbInputSimulator/InputSimulator.hpp b/Simulator/include/IbInputSimulator/InputSimulator.hpp index d6817ba..6e96d83 100644 --- a/Simulator/include/IbInputSimulator/InputSimulator.hpp +++ b/Simulator/include/IbInputSimulator/InputSimulator.hpp @@ -25,7 +25,8 @@ namespace Send { SendInput, Logitech, Razer, - DD + DD, + MouClassInputInjection }; using InitFlags = const uint32_t; diff --git a/Simulator/include/IbInputSimulator/SendTypes/MouClassInputInjection.hpp b/Simulator/include/IbInputSimulator/SendTypes/MouClassInputInjection.hpp new file mode 100644 index 0000000..c473e38 --- /dev/null +++ b/Simulator/include/IbInputSimulator/SendTypes/MouClassInputInjection.hpp @@ -0,0 +1,144 @@ +#pragma once +#include "base.hpp" +#include "MouClassInputInjection/ioctl.h" + +namespace Send::Type::Internal { + class MouClassInputInjection final : virtual public Base { + public: + MouClassInputInjection() {} + + Error create(ULONG_PTR pid) { + device = CreateFileW( + LOCAL_DEVICE_PATH_U, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + nullptr, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + nullptr + ); + if (device == INVALID_HANDLE_VALUE) + return Error::DeviceNotFound; + + DWORD bytes_returned; + if (!DeviceIoControl( + device, + IOCTL_INITIALIZE_MOUSE_DEVICE_STACK_CONTEXT, + nullptr, 0, + &device_info, sizeof(device_info), + &bytes_returned, + nullptr + )) { + CloseHandle(device); + return Error::DeviceOpenFailed; + } + + this->pid = pid; + + return Error::Success; + } + + void destroy() override { + CloseHandle(device); + } + + bool send_mouse_input(const MOUSEINPUT& mi) override { + if (mi.dwFlags & MOUSEEVENTF_MOVE) { + USHORT flags = 0; + POINT move{ mi.dx, mi.dy }; + + // MOUSE_MOVE_RELATIVE: 0 + if (device_info.MovementDevice.AbsoluteMovement) { + flags |= MOUSE_MOVE_ABSOLUTE; + if (!(mi.dwFlags & MOUSEEVENTF_ABSOLUTE)) { + POINT cursor; + GetCursorPos(&cursor); + move.x += cursor.x; + move.y += cursor.y; + } + else { + //@todo mouse_absolute_to_screen(move); + } + } + else { + if (mi.dwFlags & MOUSEEVENTF_ABSOLUTE) { + mouse_absolute_to_screen(move); + mouse_screen_to_relative(move); + } + } + + //@todo mi.dwFlags & MOUSEEVENTF_VIRTUALDESK + if (device_info.MovementDevice.VirtualDesktop) + flags |= MOUSE_VIRTUAL_DESKTOP; + + // MOUSE_ATTRIBUTES_CHANGED + + if (mi.dwFlags & MOUSEEVENTF_MOVE_NOCOALESCE) + flags |= MOUSE_MOVE_NOCOALESCE; + + // MOUSE_TERMSRV_SRC_SHADOW: unknown + + INJECT_MOUSE_MOVEMENT_INPUT_REQUEST request{ + .ProcessId = pid, + .IndicatorFlags = flags, + .MovementX = move.x, + .MovementY = move.y + }; + DWORD bytes_returned; + DeviceIoControl( + device, + IOCTL_INJECT_MOUSE_MOVEMENT_INPUT, + &request, sizeof(request), + nullptr, 0, + &bytes_returned, + nullptr + ); + } + + if (mi.dwFlags & 0x7E) { + DWORD keys[] = { MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP, MOUSEEVENTF_MIDDLEDOWN, MOUSEEVENTF_MIDDLEUP }; + for (DWORD key : keys) + if (mi.dwFlags & key) + inject_button(key >> 1); + } + if (mi.dwFlags & (MOUSEEVENTF_XDOWN | MOUSEEVENTF_XUP)) { + bool down = mi.dwFlags & MOUSEEVENTF_XDOWN; + switch (mi.mouseData) { + case XBUTTON1: inject_button(down ? MOUSE_BUTTON_4_DOWN : MOUSE_BUTTON_4_UP); break; + case XBUTTON2: inject_button(down ? MOUSE_BUTTON_5_DOWN : MOUSE_BUTTON_5_UP); break; + } + } + else if (mi.dwFlags & MOUSEEVENTF_WHEEL) + return false; + + //@todo + return true; + } + + bool send_keyboard_input(const KEYBDINPUT& ki) override { + return false; + } + + private: + HANDLE device; + MOUSE_DEVICE_STACK_INFORMATION device_info; + ULONG_PTR pid; + + bool inject_button(USHORT button) { + INJECT_MOUSE_BUTTON_INPUT_REQUEST request{ + .ProcessId = pid, + .ButtonFlags = button, + .ButtonData = 0 + }; + DWORD bytes_returned; + return DeviceIoControl( + device, + IOCTL_INJECT_MOUSE_BUTTON_INPUT, + &request, sizeof(request), + nullptr, 0, + &bytes_returned, + nullptr + ); + } + }; +} \ No newline at end of file diff --git a/Simulator/include/IbInputSimulator/SendTypes/MouClassInputInjection/ioctl.h b/Simulator/include/IbInputSimulator/SendTypes/MouClassInputInjection/ioctl.h new file mode 100644 index 0000000..9a5a010 --- /dev/null +++ b/Simulator/include/IbInputSimulator/SendTypes/MouClassInputInjection/ioctl.h @@ -0,0 +1,113 @@ +/*++ + +Copyright (c) 2019 changeofpace. All rights reserved. + +Use of this source code is governed by the MIT license. See the 'LICENSE' file +for more information. + +--*/ + +#pragma once + +#if defined(_KERNEL_MODE) +#include +#else +#include +#endif + +#include +#include + +//============================================================================= +// Names +//============================================================================= +#define DRIVER_NAME_U L"MouClassInputInjection" +#define LOCAL_DEVICE_PATH_U (L"\\\\.\\" DRIVER_NAME_U) +#define NT_DEVICE_NAME_U (L"\\Device\\" DRIVER_NAME_U) +#define SYMBOLIC_LINK_NAME_U (L"\\DosDevices\\" DRIVER_NAME_U) + +//============================================================================= +// Ioctls +//============================================================================= +#define FILE_DEVICE_MOUCLASS_INPUT_INJECTION 48781ul + +#define IOCTL_INITIALIZE_MOUSE_DEVICE_STACK_CONTEXT \ + CTL_CODE( \ + FILE_DEVICE_MOUCLASS_INPUT_INJECTION, \ + 2600, \ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) + +#define IOCTL_INJECT_MOUSE_BUTTON_INPUT \ + CTL_CODE( \ + FILE_DEVICE_MOUCLASS_INPUT_INJECTION, \ + 2850, \ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) + +#define IOCTL_INJECT_MOUSE_MOVEMENT_INPUT \ + CTL_CODE( \ + FILE_DEVICE_MOUCLASS_INPUT_INJECTION, \ + 2851, \ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) + +#define IOCTL_INJECT_MOUSE_INPUT_PACKET \ + CTL_CODE( \ + FILE_DEVICE_MOUCLASS_INPUT_INJECTION, \ + 2870, \ + METHOD_BUFFERED, \ + FILE_ANY_ACCESS) + +//============================================================================= +// IOCTL_INITIALIZE_MOUSE_DEVICE_STACK_CONTEXT +//============================================================================= +typedef struct _MOUSE_CLASS_BUTTON_DEVICE_INFORMATION { + USHORT UnitId; +} MOUSE_CLASS_BUTTON_DEVICE_INFORMATION, +*PMOUSE_CLASS_BUTTON_DEVICE_INFORMATION; + +typedef struct _MOUSE_CLASS_MOVEMENT_DEVICE_INFORMATION { + USHORT UnitId; + BOOLEAN AbsoluteMovement; + BOOLEAN VirtualDesktop; +} MOUSE_CLASS_MOVEMENT_DEVICE_INFORMATION, +*PMOUSE_CLASS_MOVEMENT_DEVICE_INFORMATION; + +typedef struct _MOUSE_DEVICE_STACK_INFORMATION { + MOUSE_CLASS_BUTTON_DEVICE_INFORMATION ButtonDevice; + MOUSE_CLASS_MOVEMENT_DEVICE_INFORMATION MovementDevice; +} MOUSE_DEVICE_STACK_INFORMATION, *PMOUSE_DEVICE_STACK_INFORMATION; + +typedef struct _INITIALIZE_MOUSE_DEVICE_STACK_CONTEXT_REPLY { + MOUSE_DEVICE_STACK_INFORMATION DeviceStackInformation; +} INITIALIZE_MOUSE_DEVICE_STACK_CONTEXT_REPLY, +*PINITIALIZE_MOUSE_DEVICE_STACK_CONTEXT_REPLY; + +//============================================================================= +// IOCTL_INJECT_MOUSE_BUTTON_INPUT +//============================================================================= +typedef struct _INJECT_MOUSE_BUTTON_INPUT_REQUEST { + ULONG_PTR ProcessId; + USHORT ButtonFlags; + USHORT ButtonData; +} INJECT_MOUSE_BUTTON_INPUT_REQUEST, *PINJECT_MOUSE_BUTTON_INPUT_REQUEST; + +//============================================================================= +// IOCTL_INJECT_MOUSE_MOVEMENT_INPUT +//============================================================================= +typedef struct _INJECT_MOUSE_MOVEMENT_INPUT_REQUEST { + ULONG_PTR ProcessId; + USHORT IndicatorFlags; + LONG MovementX; + LONG MovementY; +} INJECT_MOUSE_MOVEMENT_INPUT_REQUEST, *PINJECT_MOUSE_MOVEMENT_INPUT_REQUEST; + +//============================================================================= +// IOCTL_INJECT_MOUSE_INPUT_PACKET +//============================================================================= +typedef struct _INJECT_MOUSE_INPUT_PACKET_REQUEST { + ULONG_PTR ProcessId; + BOOLEAN UseButtonDevice; + MOUSE_INPUT_DATA InputPacket; +} INJECT_MOUSE_INPUT_PACKET_REQUEST, *PINJECT_MOUSE_INPUT_PACKET_REQUEST; diff --git a/Simulator/include/IbInputSimulator/SendTypes/types.hpp b/Simulator/include/IbInputSimulator/SendTypes/types.hpp index 657e1f3..b641435 100644 --- a/Simulator/include/IbInputSimulator/SendTypes/types.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/types.hpp @@ -4,6 +4,7 @@ #include "Logitech.hpp" #include "Razer.hpp" #include "DD.hpp" +#include "MouClassInputInjection.hpp" namespace Send { @@ -14,5 +15,6 @@ namespace Send using Internal::Logitech; using Internal::Razer; using Internal::DD; + using Internal::MouClassInputInjection; } } \ No newline at end of file diff --git a/Simulator/source/dllmain.cpp b/Simulator/source/dllmain.cpp index f0c5a6e..95dded0 100644 --- a/Simulator/source/dllmain.cpp +++ b/Simulator/source/dllmain.cpp @@ -95,6 +95,9 @@ DLLAPI Send::Error __stdcall IbSendInit(SendType type, InitFlags flags, void* ar error = IbSendInit(SendType::DD, flags, nullptr); if (error == Error::Success) return Error::Success; + error = IbSendInit(SendType::MouClassInputInjection, flags, nullptr); + if (error == Error::Success) return Error::Success; + return Error::DeviceNotFound; } else { @@ -139,6 +142,16 @@ DLLAPI Send::Error __stdcall IbSendInit(SendType type, InitFlags flags, void* ar main::send = std::move(type); } break; + case SendType::MouClassInputInjection: + { + auto type = std::make_unique(); + type->create_base(&SendInputHook::GetAsyncKeyState_real); + Error error = type->create((ULONG_PTR)argument); + if (error != Error::Success) + return error; + main::send = std::move(type); + } + break; default: return Error::InvalidArgument; } From 006e0b1d5b0e1244ee4e355769c32e4c3ab42525 Mon Sep 17 00:00:00 2001 From: Chaoses Ib Date: Sun, 3 Jul 2022 18:12:53 +0800 Subject: [PATCH 09/26] Fix the comment of MoveMode --- Simulator/include/IbInputSimulator/InputSimulator.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Simulator/include/IbInputSimulator/InputSimulator.hpp b/Simulator/include/IbInputSimulator/InputSimulator.hpp index 6e96d83..1cb443b 100644 --- a/Simulator/include/IbInputSimulator/InputSimulator.hpp +++ b/Simulator/include/IbInputSimulator/InputSimulator.hpp @@ -84,8 +84,8 @@ DLLAPI VOID WINAPI IbSend_keybd_event( namespace Send { enum class MoveMode : uint32_t { - Absolute, //1 - Relative //2 + Absolute, //0 + Relative //1 }; enum class MouseButton : uint32_t { From afa61899328f4842514ef4053ddda41dadf4217e Mon Sep 17 00:00:00 2001 From: Chaoses Ib Date: Sun, 3 Jul 2022 19:45:42 +0800 Subject: [PATCH 10/26] Docs: Fix building --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b97506b..c9c9b35 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ MouseClickDrag, Left, 5, 5, 150, 50 ## Building [vcpkg](https://github.com/microsoft/vcpkg): ``` -vcpkg install detours rapidjson --triplet==x64-windows-static +vcpkg install detours rapidjson --triplet=x64-windows-static ``` CMake: ``` From d98cbcba50dddacb335b1f924ec277eaa2bbba93 Mon Sep 17 00:00:00 2001 From: Chaoses Ib Date: Mon, 4 Jul 2022 01:03:53 +0800 Subject: [PATCH 11/26] Docs: Add "Software Compatibility" --- README.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c9c9b35..f874bc3 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ Languages: [English](README.md), [简体中文](README.zh-Hans.md) A library for simulating keyboard, mouse and other inputs. +## Download +[Releases](https://github.com/Chaoses-Ib/IbInputSimulator/releases) + ## Supported Drivers * [Logitech G HUB](https://www.logitechg.com/innovation/g-hub.html) No Logitech hardware required. @@ -24,13 +27,19 @@ A library for simulating keyboard, mouse and other inputs. ```ahk IbSendInit("DD", 1, "C:\SomeDir\DD64.dll") ``` +* [EDI](https://t.me/Chaoses_Ib) (paid) + +## Software Compatibility +Software | SendInput | Logitech | Razer | MCII | DD | EDI | DM | Other +--- | --- | --- | --- | --- | --- | --- | --- | --- +Blade & Soul (Korean) | | ✔️ | | | ❗ | ✔️ | ✔️ | ❌ SendInput hook ## Supported Languages -### AHK +### AutoHotkey
AHK v2
; 运行记事本,输入“Hello world!”并通过鼠标全选文本。
 
#Include %A_ScriptDir% -
#Include IbInputSimulator.ahk
IbSendInit() ; IbSendInit("AnyDriver", 1) @@ -58,7 +58,7 @@ WinWaitActive, ahk_class #32770 Send notepad`n
WinWaitActive, ahk_exe notepad.exe -Send Hello world+1 +Send Hello world{!} Sleep 100 CoordMode, Mouse, Client MouseClickDrag, Left, 5, 5, 150, 50
- - + + @@ -70,10 +79,7 @@ MouseClickDrag, Left, 5, 5, 150, 50
AHK v2AHK v1AutoHotkey v2AutoHotkey v1
-## Downloading -[Releases](../../releases) - -## Building +## Build [vcpkg](https://github.com/microsoft/vcpkg): ``` vcpkg install detours rapidjson --triplet=x64-windows-static From 3f1ea858628d14077e40bc518bdd5915a664c5e4 Mon Sep 17 00:00:00 2001 From: Chaoses Ib Date: Mon, 4 Jul 2022 01:07:34 +0800 Subject: [PATCH 12/26] Docs: Remove Chinese translation --- README.md | 1 - README.zh-Hans.md | 87 ----------------------------------------------- 2 files changed, 88 deletions(-) delete mode 100644 README.zh-Hans.md diff --git a/README.md b/README.md index f874bc3..8615831 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # IbInputSimulator -Languages: [English](README.md), [简体中文](README.zh-Hans.md) A library for simulating keyboard, mouse and other inputs. ## Download diff --git a/README.zh-Hans.md b/README.zh-Hans.md deleted file mode 100644 index ee120a2..0000000 --- a/README.zh-Hans.md +++ /dev/null @@ -1,87 +0,0 @@ -# IbInputSimulator -语言:[English](README.md),[简体中文](README.zh-Hans.md) -一个用于模拟键盘、鼠标和其它输入的库。 - -## 支持驱动 -* [罗技 G HUB](https://www.logitechg.com.cn/zh-cn/innovation/g-hub.html) - 不需要罗技硬件。 - 用例:`IbSendInit("Logitech")` -* [罗技游戏软件](https://support.logi.com/hc/zh-cn/articles/360025298053) - 不需要罗技硬件。 - 用例:`IbSendInit("Logitech")` -* [雷蛇雷云3](http://cn.razerzone.com/synapse-3) - 不需要雷蛇硬件,不过如果有的话会更安全。 - 用例:`IbSendInit("Razer")` -* [MouClassInputInjection](https://github.com/Chaoses-Ib/MouClassInputInjection) - 用例:`IbSendInit("MouClassInputInjection", 1, process_id)` -* [DD 虚拟鼠标 & 虚拟键盘](https://github.com/ddxoft/master) - 可能会导致蓝屏;难以卸载干净;需要联网。 - 使用时需要把 DLL 文件(`DD94687.64.dll`/`DD64.dll`/`DDHID64.dll`)与你的脚本文件放到一起,然后: - ```ahk - IbSendInit("DD") - ``` - 或者在调用 IbSendInit 时指定 DLL 路径: - ```ahk - IbSendInit("DD", 1, "C:\SomeDir\DD64.dll") - ``` - -## 支持语言 -### AHK - - - - - - - - - - - -
AHK v2AHK v1
; 运行记事本,输入“Hello world!”并通过鼠标全选文本。
-
-#Include "IbInputSimulator.ahk" -
-IbSendInit() ; IbSendInit("AnyDriver", 1) -
-Send("#r") -WinWaitActive("ahk_class #32770") -Send("notepad`n") -
-WinWaitActive("ahk_exe notepad.exe") -Send("Hello world{!}") -Sleep(100) -MouseClickDrag("Left", 5, 5, 150, 50)
; 运行记事本,输入“Hello world!”并通过鼠标全选文本。
-
-#Include %A_ScriptDir% -#Include IbInputSimulator.ahk -
-IbSendInit() ; IbSendInit("AnyDriver", 1) -
-Send #r -WinWaitActive, ahk_class #32770 -Send notepad`n -
-WinWaitActive, ahk_exe notepad.exe -Send Hello world{!} -Sleep 100 -CoordMode, Mouse, Client -MouseClickDrag, Left, 5, 5, 150, 50
- -## 下载 -[Releases](../../releases) - -## 构建 -[Building](README.md#Building) - -## 相关推荐 -* [IbLogiSoftExt](https://github.com/Chaoses-Ib/IbLogiSoftExt) - -## 鸣谢 -* 罗技 - * @The-BigEagle - * [ekknod/logitech-cve](https://github.com/ekknod/logitech-cve):了解到罗技设备可以被直接打开 -* 雷蛇 - * [Sadmeme/rzctl](https://github.com/Sadmeme/rzctl) - * @任性:提供测试环境 -* @任性:提供反馈和赞助 \ No newline at end of file From be7c83022298d14031eb5752fa014eba7315a014 Mon Sep 17 00:00:00 2001 From: Chaoses Ib Date: Sat, 13 Aug 2022 01:22:23 +0800 Subject: [PATCH 13/26] Update information about Razer Synapse 3 --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8615831..97304a3 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A library for simulating keyboard, mouse and other inputs. ## Download [Releases](https://github.com/Chaoses-Ib/IbInputSimulator/releases) -## Supported Drivers +## Supported drivers * [Logitech G HUB](https://www.logitechg.com/innovation/g-hub.html) No Logitech hardware required. e.g. `IbSendInit("Logitech")` @@ -12,7 +12,7 @@ A library for simulating keyboard, mouse and other inputs. No Logitech hardware required. e.g. `IbSendInit("Logitech")` * [Razer Synapse 3](https://www.razer.com/synapse-3) - No Razer hardware required, but it will be safer if you have one. + Require Razer hardware. (Note that the old versions do not require Razer hardware, however, Razer Synapse 3 only provides an online installer and there is no way to install an old version) e.g. `IbSendInit("Razer")` * [MouClassInputInjection](https://github.com/Chaoses-Ib/MouClassInputInjection) e.g. `IbSendInit("MouClassInputInjection", 1, process_id)` @@ -28,12 +28,12 @@ A library for simulating keyboard, mouse and other inputs. ``` * [EDI](https://t.me/Chaoses_Ib) (paid) -## Software Compatibility +## Software compatibility Software | SendInput | Logitech | Razer | MCII | DD | EDI | DM | Other --- | --- | --- | --- | --- | --- | --- | --- | --- Blade & Soul (Korean) | | ✔️ | | | ❗ | ✔️ | ✔️ | ❌ SendInput hook -## Supported Languages +## Supported languages ### AutoHotkey @@ -97,7 +97,7 @@ vcpkg install boost-test fmt ``` And add `-DBUILD_TESTING=ON` when calling `cmake ..` . -## See Also +## See also * [IbLogiSoftExt](https://github.com/Chaoses-Ib/IbLogiSoftExt) ## Credits From ebe68ad703a057f0d6974e10bacf72000ec012e0 Mon Sep 17 00:00:00 2001 From: Chaoses-Ib Date: Wed, 1 Mar 2023 00:00:38 +0800 Subject: [PATCH 14/26] Docs: Add sponsors --- README.md | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 97304a3..d1fa9e8 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,18 @@ A library for simulating keyboard, mouse and other inputs. [Releases](https://github.com/Chaoses-Ib/IbInputSimulator/releases) ## Supported drivers -* [Logitech G HUB](https://www.logitechg.com/innovation/g-hub.html) +- [Logitech G HUB](https://www.logitechg.com/innovation/g-hub.html) No Logitech hardware required. e.g. `IbSendInit("Logitech")` -* [Logitech Gaming Software](https://support.logi.com/hc/en-gb/articles/360025298053-Logitech-Gaming-Software) +- [Logitech Gaming Software](https://support.logi.com/hc/en-gb/articles/360025298053-Logitech-Gaming-Software) No Logitech hardware required. e.g. `IbSendInit("Logitech")` -* [Razer Synapse 3](https://www.razer.com/synapse-3) +- [Razer Synapse 3](https://www.razer.com/synapse-3) Require Razer hardware. (Note that the old versions do not require Razer hardware, however, Razer Synapse 3 only provides an online installer and there is no way to install an old version) e.g. `IbSendInit("Razer")` -* [MouClassInputInjection](https://github.com/Chaoses-Ib/MouClassInputInjection) +- [MouClassInputInjection](https://github.com/Chaoses-Ib/MouClassInputInjection) e.g. `IbSendInit("MouClassInputInjection", 1, process_id)` -* [DD Virtual Mouse & Virtual Keyboard](https://github.com/ddxoft/master) +- [DD Virtual Mouse & Virtual Keyboard](https://github.com/ddxoft/master) May cause a blue screen; difficult to uninstall cleanly; need network. To use it, put the DLL (`DD94687.64.dll`/`DD64.dll`/`DDHID64.dll`) with your script file, and then: ```ahk @@ -26,7 +26,7 @@ A library for simulating keyboard, mouse and other inputs. ```ahk IbSendInit("DD", 1, "C:\SomeDir\DD64.dll") ``` -* [EDI](https://t.me/Chaoses_Ib) (paid) +- [EDI](https://t.me/Chaoses_Ib) (paid) ## Software compatibility Software | SendInput | Logitech | Razer | MCII | DD | EDI | DM | Other @@ -98,13 +98,19 @@ vcpkg install boost-test fmt And add `-DBUILD_TESTING=ON` when calling `cmake ..` . ## See also -* [IbLogiSoftExt](https://github.com/Chaoses-Ib/IbLogiSoftExt) +- [IbLogiSoftExt](https://github.com/Chaoses-Ib/IbLogiSoftExt) ## Credits -* Logitech - * @The-BigEagle - * [ekknod/logitech-cve](https://github.com/ekknod/logitech-cve) for learning that Logitech devices can be opened directly -* Razer - * [Sadmeme/rzctl](https://github.com/Sadmeme/rzctl) - * @任性 for providing test environment -* @任性 for providing feedback and sponsorship \ No newline at end of file +- Logitech + - @Eagle1020 + - [ekknod/logitech-cve](https://github.com/ekknod/logitech-cve) for learning that Logitech devices can be opened directly +- Razer + - [Sadmeme/rzctl](https://github.com/Sadmeme/rzctl) + - @任性 for providing test environment + +Sponsors: + +Date | Sponsor +--- | --- +2023-02-28 | - +2021-08-28 | 任性 \ No newline at end of file From 8fb1fa9dea83c2917d71087d5389c321a0d38292 Mon Sep 17 00:00:00 2001 From: Chaoses-Ib Date: Sat, 22 Apr 2023 15:26:18 +0800 Subject: [PATCH 15/26] Docs: Update sponsors --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d1fa9e8..3c70e09 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,9 @@ And add `-DBUILD_TESTING=ON` when calling `cmake ..` . Sponsors: -Date | Sponsor ---- | --- -2023-02-28 | - -2021-08-28 | 任性 \ No newline at end of file +Date | Sponsor | Comment +--- | --- | --- +2022-04-03 | 任性 | MouClassInputInjection +2023-04-22 | 任性 | Logitech +2023-02-28 | - | +2021-08-28 | 任性 | Razer \ No newline at end of file From b353eb130bcaaa048b6002f5f9096b61e909ab2a Mon Sep 17 00:00:00 2001 From: Chaoses-Ib Date: Sat, 24 Jun 2023 04:15:45 +0800 Subject: [PATCH 16/26] Docs: Test: Add Genshin --- README.md | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3c70e09..bf57543 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,32 @@ A library for simulating keyboard, mouse and other inputs. [Releases](https://github.com/Chaoses-Ib/IbInputSimulator/releases) ## Supported drivers -- [Logitech G HUB](https://www.logitechg.com/innovation/g-hub.html) - No Logitech hardware required. +- [Logitech G HUB](https://www.logitechg.com/innovation/g-hub.html) + + No Logitech hardware required. + e.g. `IbSendInit("Logitech")` -- [Logitech Gaming Software](https://support.logi.com/hc/en-gb/articles/360025298053-Logitech-Gaming-Software) - No Logitech hardware required. + +- [Logitech Gaming Software](https://support.logi.com/hc/en-gb/articles/360025298053-Logitech-Gaming-Software) + + No Logitech hardware required. + e.g. `IbSendInit("Logitech")` -- [Razer Synapse 3](https://www.razer.com/synapse-3) - Require Razer hardware. (Note that the old versions do not require Razer hardware, however, Razer Synapse 3 only provides an online installer and there is no way to install an old version) + +- [Razer Synapse 3](https://www.razer.com/synapse-3) + + Require Razer hardware. (Note that the old versions do not require Razer hardware, however, Razer Synapse 3 only provides an online installer and there is no way to install an old version) + e.g. `IbSendInit("Razer")` -- [MouClassInputInjection](https://github.com/Chaoses-Ib/MouClassInputInjection) + +- [MouClassInputInjection](https://github.com/Chaoses-Ib/MouClassInputInjection) + e.g. `IbSendInit("MouClassInputInjection", 1, process_id)` -- [DD Virtual Mouse & Virtual Keyboard](https://github.com/ddxoft/master) - May cause a blue screen; difficult to uninstall cleanly; need network. + +- [DD Virtual Mouse & Virtual Keyboard](https://github.com/ddxoft/master) + + May cause a blue screen; difficult to uninstall cleanly; need network. + To use it, put the DLL (`DD94687.64.dll`/`DD64.dll`/`DDHID64.dll`) with your script file, and then: ```ahk IbSendInit("DD") @@ -26,12 +39,16 @@ A library for simulating keyboard, mouse and other inputs. ```ahk IbSendInit("DD", 1, "C:\SomeDir\DD64.dll") ``` + - [EDI](https://t.me/Chaoses_Ib) (paid) ## Software compatibility Software | SendInput | Logitech | Razer | MCII | DD | EDI | DM | Other --- | --- | --- | --- | --- | --- | --- | --- | --- Blade & Soul (Korean) | | ✔️ | | | ❗ | ✔️ | ✔️ | ❌ SendInput hook +Genshin | [High](https://meta.appinn.net/t/topic/44865/10?u=chaoses_ib) + +For SendInput, software with `High` indicates that the target process usually has a high integrity level, which may block SendInput due to UIPI. To put it simply, this means that you need to run the input simulator with administrator privileges. ## Supported languages ### AutoHotkey From e6cc9cfc1ddcf5b051d09e4b3c91225fc5683339 Mon Sep 17 00:00:00 2001 From: Chaoses-Ib Date: Tue, 22 Aug 2023 15:30:03 +0800 Subject: [PATCH 17/26] Docs: Update EDI information --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bf57543..40761a3 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ A library for simulating keyboard, mouse and other inputs. IbSendInit("DD", 1, "C:\SomeDir\DD64.dll") ``` -- [EDI](https://t.me/Chaoses_Ib) (paid) +- [EDI](https://t.me/Chaoses_Ib) (private, not for sale) ## Software compatibility Software | SendInput | Logitech | Razer | MCII | DD | EDI | DM | Other From 0dcf6f0b638b0682bd7742b3e4c886546c41f8b8 Mon Sep 17 00:00:00 2001 From: Chaoses-Ib Date: Wed, 10 Jan 2024 16:14:14 +0800 Subject: [PATCH 18/26] docs: update drivers --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 40761a3..f9a9304 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,25 @@ # IbInputSimulator -A library for simulating keyboard, mouse and other inputs. +A library for simulating keyboard and mouse input with drivers. ## Download [Releases](https://github.com/Chaoses-Ib/IbInputSimulator/releases) ## Supported drivers -- [Logitech G HUB](https://www.logitechg.com/innovation/g-hub.html) +- [Logitech Gaming Software](https://support.logi.com/hc/en-gb/articles/360025298053-Logitech-Gaming-Software) - No Logitech hardware required. + No Logitech hardware required. However, in the new versions of LGS, the mouse driver has been removed ([#8](https://github.com/Chaoses-Ib/IbInputSimulator/issues/8)). You can install [v9.02.65](https://github.com/Chaoses-Ib/IbLogiSoftExt/releases/download/v0.1/LGS.v9.02.65_x64.exe) to make the mouse driver available. e.g. `IbSendInit("Logitech")` -- [Logitech Gaming Software](https://support.logi.com/hc/en-gb/articles/360025298053-Logitech-Gaming-Software) +- [Logitech G HUB](https://www.logitechg.com/innovation/g-hub.html) - No Logitech hardware required. + No Logitech hardware required. However, in the new versions of G HUB, the mouse driver has been removed ([#8](https://github.com/Chaoses-Ib/IbInputSimulator/issues/8)). Unfortunately, there is currently no known way to install an old version. e.g. `IbSendInit("Logitech")` - [Razer Synapse 3](https://www.razer.com/synapse-3) - Require Razer hardware. (Note that the old versions do not require Razer hardware, however, Razer Synapse 3 only provides an online installer and there is no way to install an old version) + In the new versions of Razer Synapse, Razer hardware is required to make the driver available. The old versions do not require Razer hardware, but the online installer of Razer Synapse can only install the newest version. To install an old version manually, see [#7](https://github.com/Chaoses-Ib/IbInputSimulator/issues/7) for details. e.g. `IbSendInit("Razer")` From 42999bb63515b1e680a34fd8f84791b4fc649303 Mon Sep 17 00:00:00 2001 From: Pennywise007 Date: Sat, 4 May 2024 02:03:12 +0200 Subject: [PATCH 19/26] Fixing memory leak and removing extra virtual inheritance --- Simulator/include/IbInputSimulator/SendTypes/Logitech.hpp | 2 +- Simulator/include/IbInputSimulator/SendTypes/Razer.hpp | 2 +- Simulator/include/IbInputSimulator/SendTypes/base.hpp | 3 ++- Simulator/source/dllmain.cpp | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Simulator/include/IbInputSimulator/SendTypes/Logitech.hpp b/Simulator/include/IbInputSimulator/SendTypes/Logitech.hpp index e492b34..43401b1 100644 --- a/Simulator/include/IbInputSimulator/SendTypes/Logitech.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/Logitech.hpp @@ -229,7 +229,7 @@ namespace Send::Type::Internal { } }; - class Logitech final : virtual public Base, public VirtualKeyStates { + class Logitech final : public VirtualKeyStates { LogitechDriver driver; public: Logitech() : VirtualKeyStates(keyboard_report.modifiers, keyboard_mutex) {} diff --git a/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp b/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp index 4da7aa8..8841d12 100644 --- a/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp @@ -3,7 +3,7 @@ #include "usb.hpp" namespace Send::Type::Internal { - class Razer final : virtual public Base, public VirtualKeyStates { + class Razer final : public VirtualKeyStates { HANDLE device; KeyboardModifiers modifiers; diff --git a/Simulator/include/IbInputSimulator/SendTypes/base.hpp b/Simulator/include/IbInputSimulator/SendTypes/base.hpp index 116d410..1e631aa 100644 --- a/Simulator/include/IbInputSimulator/SendTypes/base.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/base.hpp @@ -76,6 +76,7 @@ namespace Send::Type::Internal { this->get_key_state_fallback = get_key_state_fallback; } + virtual ~Base() = default; virtual void destroy() = 0; virtual uint32_t send_input(const INPUT inputs[], uint32_t n) { @@ -139,7 +140,7 @@ namespace Send::Type::Internal { bool RGui : 1; }; - class VirtualKeyStates : virtual public Base { + class VirtualKeyStates : public Base { KeyboardModifiers& modifiers; std::mutex& mutex; diff --git a/Simulator/source/dllmain.cpp b/Simulator/source/dllmain.cpp index 95dded0..053b797 100644 --- a/Simulator/source/dllmain.cpp +++ b/Simulator/source/dllmain.cpp @@ -165,7 +165,7 @@ DLLAPI void __stdcall IbSendDestroy() { if (!main::send) return; main::send->destroy(); - main::send.release(); + main::send.reset(); } DLLAPI void __stdcall IbSendSyncKeyStates() { From 8f9078bd7aace576c49c97b0c06377a762f90398 Mon Sep 17 00:00:00 2001 From: Pennywise007 Date: Sun, 5 May 2024 01:24:12 +0200 Subject: [PATCH 20/26] Fixing virtual inheritance for DD and fixing build --- Simulator/include/IbInputSimulator/SendTypes/DD.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simulator/include/IbInputSimulator/SendTypes/DD.hpp b/Simulator/include/IbInputSimulator/SendTypes/DD.hpp index 15ec146..269eddd 100644 --- a/Simulator/include/IbInputSimulator/SendTypes/DD.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/DD.hpp @@ -4,7 +4,7 @@ #include "base.hpp" namespace Send::Type::Internal { - class DD final : virtual public Base, public VirtualKeyStates { + class DD final : public VirtualKeyStates { KeyboardModifiers modifiers; std::mutex keyboard_mutex; From b6e3406193eede13c4d4a649fd1c4e101e1e4e4f Mon Sep 17 00:00:00 2001 From: Pennywise007 Date: Sun, 5 May 2024 16:29:23 +0200 Subject: [PATCH 21/26] Adding support of the extending keys in razer driver --- .../IbInputSimulator/SendTypes/Razer.hpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp b/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp index 8841d12..74bd59f 100644 --- a/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp @@ -144,10 +144,27 @@ namespace Send::Type::Internal { if (is_modifier(ki.wVk)) set_modifier_state(ki.wVk, keydown); - if (ki.wVk == VK_LWIN || ki.wVk == VK_RWIN) //#TODO: Any other keys? + switch (ki.wVk) + { + case VK_SNAPSHOT: + case VK_INSERT: + case VK_HOME: + case VK_PRIOR: + case VK_DELETE: + case VK_END: + case VK_NEXT: + case VK_RIGHT: + case VK_LEFT: + case VK_DOWN: + case VK_UP: + case VK_LWIN: + case VK_RWIN: control.ki.action = keydown ? 2 : 3; - else + break; + default: control.ki.action = keydown ? 0 : 1; + break; + } if constexpr (debug) DebugOStream() << L"send_keyboard_input: " << control.ki.key << ", " << control.ki.action << std::endl; From b5a162a2ea1577c68193ca6224b45142234624f4 Mon Sep 17 00:00:00 2001 From: Chaoses-Ib Date: Mon, 6 May 2024 00:41:05 +0800 Subject: [PATCH 22/26] fix: `MSVC_RUNTIME_LIBRARY` is ignored if using top-level `CMakeLists.txt` --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dbbc004..1a6d253 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.15) project(IbInputSimulator) From 964e8947564a0182dc8a432eef110ddc646461db Mon Sep 17 00:00:00 2001 From: Chaoses-Ib Date: Mon, 6 May 2024 02:14:40 +0800 Subject: [PATCH 23/26] fix: `MSVC_RUNTIME_LIBRARY` may not work for `FetchContent` dependencies --- README.md | 2 +- Simulator/CMakeLists.txt | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f9a9304..79a9146 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ MouseClickDrag, Left, 5, 5, 150, 50 ``` vcpkg install detours rapidjson --triplet=x64-windows-static ``` -CMake: +CMake (or open the directory with Visual Studio and config it manually): ``` mkdir build cd build diff --git a/Simulator/CMakeLists.txt b/Simulator/CMakeLists.txt index 97ba3db..ab1e24d 100644 --- a/Simulator/CMakeLists.txt +++ b/Simulator/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.15) project(IbInputSimulator) +set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + # IbWinCppLib include(FetchContent) FetchContent_Declare(IbWinCpp @@ -25,9 +27,6 @@ set(sourceFiles ) list(TRANSFORM sourceFiles PREPEND source/) add_library(IbInputSimulator SHARED ${sourceFiles}) -set_property(TARGET IbInputSimulator PROPERTY - MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" -) target_compile_features(IbInputSimulator PUBLIC cxx_std_20) target_compile_definitions(IbInputSimulator PRIVATE IB_INPUT_DLLEXPORT) From af1ff07a238779f1e2470e3997e4f3b00d058757 Mon Sep 17 00:00:00 2001 From: Chaoses-Ib Date: Mon, 6 May 2024 02:25:44 +0800 Subject: [PATCH 24/26] refactor(razer): use official input data struct Co-Authored-By: Stanislav Shvets <35340783+Pennywise007@users.noreply.github.com> --- .../IbInputSimulator/SendTypes/Razer.hpp | 152 +++++++++++------- 1 file changed, 90 insertions(+), 62 deletions(-) diff --git a/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp b/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp index 74bd59f..0c800ad 100644 --- a/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp +++ b/Simulator/include/IbInputSimulator/SendTypes/Razer.hpp @@ -1,4 +1,6 @@ #pragma once +#include +#include #include "base.hpp" #include "usb.hpp" @@ -43,43 +45,49 @@ namespace Send::Type::Internal { Mouse = 2 } type; union { - struct { - uint32_t absolute_coord; - struct { - bool LButtonDown : 1; - bool LButtonUp : 1; - bool RButtonDown : 1; - bool RButtonUp : 1; - bool MButtonDown : 1; - bool MButtonUp : 1; - bool XButton1Down : 1; - bool XButton1Up : 1; - bool XButton2Down : 1; - bool XButton2Up : 1; - bool Wheel : 1; - bool HWheel : 1; - uint8_t unk : 4; - private: - void assert_size() { - static_assert(sizeof(*this) == 2); - } - } btn; - int16_t movement; - uint32_t unk1; - int32_t x; - int32_t y; - uint32_t unk2; - } mi; - struct { - uint16_t unk1; - int16_t key; - uint16_t action; - uint16_t unk2; - uint32_t unk3; - uint32_t unk4; - uint32_t unk5; - uint32_t unk6; - } ki; + //struct { + // uint32_t absolute_coord; + // struct { + // bool LButtonDown : 1; + // bool LButtonUp : 1; + // bool RButtonDown : 1; + // bool RButtonUp : 1; + // bool MButtonDown : 1; + // bool MButtonUp : 1; + // bool XButton1Down : 1; + // bool XButton1Up : 1; + // bool XButton2Down : 1; + // bool XButton2Up : 1; + // bool Wheel : 1; + // bool HWheel : 1; + // uint8_t unk : 4; + // private: + // void assert_size() { + // static_assert(sizeof(*this) == 2); + // } + // } btn; + // int16_t movement; + // uint32_t unk1; + // int32_t x; + // int32_t y; + // uint32_t unk2; + //} mi; + + MOUSE_INPUT_DATA mi; + + //struct { + // uint16_t unk1; + // int16_t key; + // uint16_t action; + // uint16_t unk2; + // uint32_t unk3; + // uint32_t unk4; + // uint32_t unk5; + // uint32_t unk6; + //} ki; + + /// The high byte of MakeCode has no effect, extended keys are supported by Flags + KEYBOARD_INPUT_DATA ki; }; private: void assert_size() { @@ -93,40 +101,48 @@ namespace Send::Type::Internal { if (mi.dwFlags & MOUSEEVENTF_MOVE) { POINT move{ mi.dx, mi.dy }; if (mi.dwFlags & MOUSEEVENTF_ABSOLUTE) { - control.mi.absolute_coord = 0x10000; + control.mi.Flags = MOUSE_MOVE_ABSOLUTE; } - control.mi.x = mi.dx; - control.mi.y = mi.dy; + control.mi.LastX = mi.dx; + control.mi.LastY = mi.dy; } -#define CODE_GENERATE(down, up, member) \ - control.mi.btn.##member##Down = mi.dwFlags & down; \ - control.mi.btn.##member##Up = mi.dwFlags & up; + if (mi.dwFlags & MOUSEEVENTF_LEFTDOWN) + control.mi.ButtonFlags |= MOUSE_LEFT_BUTTON_DOWN; + if (mi.dwFlags & MOUSEEVENTF_LEFTUP) + control.mi.ButtonFlags |= MOUSE_LEFT_BUTTON_UP; + if (mi.dwFlags & MOUSEEVENTF_RIGHTDOWN) + control.mi.ButtonFlags |= MOUSE_RIGHT_BUTTON_DOWN; + if (mi.dwFlags & MOUSEEVENTF_RIGHTUP) + control.mi.ButtonFlags |= MOUSE_RIGHT_BUTTON_UP; + if (mi.dwFlags & MOUSEEVENTF_MIDDLEDOWN) + control.mi.ButtonFlags |= MOUSE_MIDDLE_BUTTON_DOWN; + if (mi.dwFlags & MOUSEEVENTF_MIDDLEUP) + control.mi.ButtonFlags |= MOUSE_MIDDLE_BUTTON_UP; - CODE_GENERATE(MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP, LButton) //#TODO: may be switched? - CODE_GENERATE(MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP, RButton) - CODE_GENERATE(MOUSEEVENTF_MIDDLEDOWN, MOUSEEVENTF_MIDDLEUP, MButton) -#undef CODE_GENERATE if (mi.dwFlags & MOUSEEVENTF_XDOWN) { switch (mi.mouseData) { - case XBUTTON1: control.mi.btn.XButton1Down = 1; break; - case XBUTTON2: control.mi.btn.XButton2Down = 1; break; + case XBUTTON1: control.mi.ButtonFlags |= MOUSE_BUTTON_4_DOWN; break; + case XBUTTON2: control.mi.ButtonFlags |= MOUSE_BUTTON_5_DOWN; break; } - } else if (mi.dwFlags & MOUSEEVENTF_XUP) { + } + if (mi.dwFlags & MOUSEEVENTF_XUP) { switch (mi.mouseData) { - case XBUTTON1: control.mi.btn.XButton1Up = 1; break; - case XBUTTON2: control.mi.btn.XButton2Up = 1; break; + case XBUTTON1: control.mi.ButtonFlags |= MOUSE_BUTTON_4_UP; break; + case XBUTTON2: control.mi.ButtonFlags |= MOUSE_BUTTON_5_UP; break; } - } else if (mi.dwFlags & MOUSEEVENTF_WHEEL || mi.dwFlags & MOUSEEVENTF_HWHEEL) { + } + + if (mi.dwFlags & MOUSEEVENTF_WHEEL || mi.dwFlags & MOUSEEVENTF_HWHEEL) { if (mi.dwFlags & MOUSEEVENTF_WHEEL) - control.mi.btn.Wheel = 1; + control.mi.ButtonFlags |= MOUSE_WHEEL; else - control.mi.btn.HWheel = 1; - control.mi.movement = 120 * std::bit_cast(mi.mouseData); //#TODO + control.mi.ButtonFlags |= MOUSE_HWHEEL; + control.mi.ButtonData = 120 * std::bit_cast(mi.mouseData); //#TODO } if constexpr (debug) - DebugOStream() << L"send_mouse_input: " << *(uint16_t*)&control.mi.btn << L", (" << control.mi.x << L", " << control.mi.y << L") " << control.mi.absolute_coord << std::endl; + DebugOStream() << L"send_mouse_input: " << *(uint16_t*)&control.mi.ButtonFlags << L", (" << control.mi.LastX << L", " << control.mi.LastY << L") " << control.mi.Flags << std::endl; DWORD bytes_returned; return DeviceIoControl(device, 0x88883020, &control, sizeof control, nullptr, 0, &bytes_returned, nullptr); @@ -135,7 +151,7 @@ namespace Send::Type::Internal { bool send_keyboard_input(const KEYBDINPUT& ki) override { RzControl control{ .type = RzControl::Type::Keyboard }; - if ((control.ki.key = keyboard_vk_to_key(ki.wVk)) < 0) + if ((control.ki.MakeCode = keyboard_vk_to_key(ki.wVk)) < 0) return false; std::lock_guard lock(keyboard_mutex); @@ -144,6 +160,10 @@ namespace Send::Type::Internal { if (is_modifier(ki.wVk)) set_modifier_state(ki.wVk, keydown); + control.ki.Flags = keydown ? KEY_MAKE : KEY_BREAK; + + // Extended keys + // TODO: E1 switch (ki.wVk) { case VK_SNAPSHOT: @@ -159,15 +179,14 @@ namespace Send::Type::Internal { case VK_UP: case VK_LWIN: case VK_RWIN: - control.ki.action = keydown ? 2 : 3; + control.ki.Flags |= KEY_E0; break; default: - control.ki.action = keydown ? 0 : 1; break; } if constexpr (debug) - DebugOStream() << L"send_keyboard_input: " << control.ki.key << ", " << control.ki.action << std::endl; + DebugOStream() << L"send_keyboard_input: " << control.ki.MakeCode << ", " << control.ki.Flags << std::endl; DWORD bytes_returned; return DeviceIoControl(device, 0x88883020, &control, sizeof control, nullptr, 0, &bytes_returned, nullptr); @@ -179,8 +198,17 @@ namespace Send::Type::Internal { return keyboard_usage_to_key(Usb::keyboard_vk_to_usage(vk)); } - // RCtrl and RAlt will be treated as left ones. + /// - For extended keys, only the lowest byte is returned. + /// - RCtrl and RAlt will be treated as left ones. constexpr int16_t keyboard_usage_to_key(uint16_t usage_id) { + // Extracted from kbddef.dat in Razer Synapse + // + // Differences from HidP_TranslateUsagesToI8042ScanCodes() and MapVirtualKey(): + // vk | razer | HidP_TranslateUsagesToI8042ScanCodes | MapVirtualKey + // --- | --- | --- | --- + // VK_PAUSE (0x13) | 0x1D | 0x1D | MAPVK_VK_TO_VSC: 0 / MAPVK_VK_TO_VSC_EX: 0x1D + // VK_SNAPSHOT (0x2C) | 0x37 | 0x2A / 0x37 | 0x54 + if (usage_id <= 115) { constexpr uint16_t table[] = { -1, 255, 252, -3, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26, 27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 87, 88, 55, 70, 29, 82, 71, 73, 83, 79, 81, 77, 75, 80, 72, 69, 53, 55, 74, 78, 28, 79, 80, 81, 75, 76, 77, 71, 72, 73, 82, 83, 86, 93, 94, 89, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 118, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, 94, 95, 99, -3, 126, -3, 115, 112, 125, 121, 123, 92, -3, -3, -3, 242, 241, 120, 119, 118 }; return table[usage_id]; From e029e42d14f051a1e79dac594bc67c809a820863 Mon Sep 17 00:00:00 2001 From: Chaoses-Ib Date: Mon, 6 May 2024 02:28:20 +0800 Subject: [PATCH 25/26] feat(ahk): show last error when failed to load --- Binding.AHK1/IbInputSimulator.ahk | 4 ++-- Binding.AHK2/IbInputSimulator.ahk | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Binding.AHK1/IbInputSimulator.ahk b/Binding.AHK1/IbInputSimulator.ahk index ba7cdbb..5d6ef8f 100644 --- a/Binding.AHK1/IbInputSimulator.ahk +++ b/Binding.AHK1/IbInputSimulator.ahk @@ -1,7 +1,7 @@ ; IbInputSimulator (v1) ; Description: Enable AHK to send keystrokes by drivers. ; Author: Chaoses Ib -; Version: 0.3 +; Version: 0.4 ; Git: https://github.com/Chaoses-Ib/IbInputSimulator IbSendInit(send_type := "AnyDriver", mode := 1, args*){ @@ -15,7 +15,7 @@ IbSendInit(send_type := "AnyDriver", mode := 1, args*){ else if (!FileExist("IbInputSimulator.dll")) throw "SendLibLoadFailed: Please put IbInputSimulator.dll with your script file (or use AHK v2 instead, which can locate those DLLs that are put with the library files)" else - throw "SendLibLoadFailed" + throw "SendLibLoadFailed: " A_LastError } if (send_type == "AnyDriver") diff --git a/Binding.AHK2/IbInputSimulator.ahk b/Binding.AHK2/IbInputSimulator.ahk index 99996ff..c82da4a 100644 --- a/Binding.AHK2/IbInputSimulator.ahk +++ b/Binding.AHK2/IbInputSimulator.ahk @@ -1,7 +1,7 @@ ; IbInputSimulator ; Description: Enable AHK to send keystrokes by drivers. ; Author: Chaoses Ib -; Version: 0.3 +; Version: 0.4 ; Git: https://github.com/Chaoses-Ib/IbInputSimulator #DllLoad "*i IbInputSimulator.dll" ;DllCall("LoadLibrary") cannot locate DLL correctly @@ -15,7 +15,7 @@ IbSendInit(send_type := "AnyDriver", mode := 1, args*){ if (A_PtrSize == 4) throw "SendLibLoadFailed: Please use AutoHotkey x64" else - throw "SendLibLoadFailed" + throw "SendLibLoadFailed: " A_LastError } if (send_type == "AnyDriver") From 6b93fc71a595dcc368995752af583bbce5e98655 Mon Sep 17 00:00:00 2001 From: Chaoses-Ib Date: Mon, 6 May 2024 02:37:48 +0800 Subject: [PATCH 26/26] feat(ahk2): add version requirement --- Binding.AHK2/IbInputSimulator.ahk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Binding.AHK2/IbInputSimulator.ahk b/Binding.AHK2/IbInputSimulator.ahk index c82da4a..012eb6e 100644 --- a/Binding.AHK2/IbInputSimulator.ahk +++ b/Binding.AHK2/IbInputSimulator.ahk @@ -4,6 +4,8 @@ ; Version: 0.4 ; Git: https://github.com/Chaoses-Ib/IbInputSimulator +#Requires AutoHotkey v2.0 64-bit + #DllLoad "*i IbInputSimulator.dll" ;DllCall("LoadLibrary") cannot locate DLL correctly IbSendInit(send_type := "AnyDriver", mode := 1, args*){