├── .gitignore ├── .gitmodules ├── LICENSE ├── README-en.md ├── README-oid.md ├── README.md ├── bin ├── HMC@Beta_x64.node ├── HMC@Beta_x86.node ├── HMC_x64.node └── HMC_x86.node ├── chcpList.d.ts ├── document └── zh-自动化 │ ├── HOOK (低级键鼠变化检测).md │ ├── hmc_automation_util (c++) .md │ └── 虚拟键代码 (VK).md ├── hmc.d.ts ├── hmc2.d.ts ├── index.js ├── package-lock.json ├── package.json ├── source ├── HMC1.0源代码 [停止维护] 逐步升级到2.0.zip ├── hmc-autoIt │ ├── API.md │ ├── AutoItX.chm │ ├── AutoItX.chw │ ├── AutoItX3.hpp │ ├── AutoItX3.hpp.json │ ├── AutoItX3 │ │ ├── AutoItX3_DLL.h │ │ ├── AutoItX3_DLL.lib │ │ └── AutoItX3_x64_DLL.lib │ ├── LICENSE │ ├── Main.cpp │ ├── Main.cpp_aaa │ ├── Main.h │ ├── README.md │ ├── bin │ │ ├── AutoItX3.dll │ │ ├── AutoItX3_x64.dll │ │ ├── AutoItX_x64.node │ │ └── AutoItX_x86.node │ ├── binding.gyp │ ├── build.cmd │ ├── copyright.txt │ ├── index.d.ts │ ├── index.js │ ├── license-AutoItX.md │ ├── package.json │ ├── tsconfig.json │ └── util │ │ ├── Main.cpp │ │ ├── api_name.json │ │ ├── fmt11.hpp │ │ ├── hmc_string_util.cpp.back │ │ ├── hmc_string_util.hpp.back │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── index.ts │ │ ├── napi_cpp-function-export-table.d.ts │ │ ├── napi_cpp-function-export-table.js │ │ ├── napi_cpp-function-export-table.ts │ │ ├── napi_value_util.hpp │ │ ├── out.d.ts │ │ ├── out.js │ │ ├── out.ts │ │ ├── ts-function-export.d.ts │ │ ├── ts-function-export.js │ │ └── ts-function-export.ts ├── hmc-win32@2.0 │ ├── LICENSE │ ├── README-zh.md │ ├── README.md │ ├── bin │ │ ├── HMC@Beta_x64.node │ │ ├── HMC@Beta_x86.node │ │ ├── HMC@v1.0_x64.node │ │ └── HMC@v1.0_x86.node │ ├── hmc-esm.mjs │ ├── index.cjs │ ├── package.json │ ├── source │ │ ├── .gitmodules │ │ ├── cpp │ │ │ ├── bin │ │ │ │ ├── HMC@Beta_x64.node │ │ │ │ └── HMC@Beta_x86.node │ │ │ ├── binding.gyp │ │ │ ├── export │ │ │ │ ├── Promise.cpp │ │ │ │ ├── Sock.cpp │ │ │ │ ├── auto.cpp │ │ │ │ ├── clip.cpp │ │ │ │ ├── export.h │ │ │ │ ├── process.cpp │ │ │ │ ├── promise_template.txt │ │ │ │ ├── registr.cpp │ │ │ │ ├── screen.cpp │ │ │ │ ├── shell.cpp │ │ │ │ └── window.cpp │ │ │ ├── main.cpp │ │ │ ├── main.h │ │ │ ├── msvc │ │ │ │ ├── binding.sln │ │ │ │ ├── cheese.log │ │ │ │ ├── config.gypi │ │ │ │ ├── hmc_debug.aps │ │ │ │ ├── hmc_debug.rc │ │ │ │ ├── hmc_debug.vcxproj │ │ │ │ ├── hmc_debug.vcxproj.filters │ │ │ │ ├── hmc_debug.vcxproj.user │ │ │ │ └── resource.h │ │ │ └── win_delay_load_hook.cc │ │ ├── main │ │ │ ├── HMC.ts │ │ │ ├── Native.ts │ │ │ ├── Process.ts │ │ │ ├── ShellPromiseEval.ts │ │ │ ├── Sock.ts │ │ │ ├── Usb.ts │ │ │ ├── auto.ts │ │ │ ├── bin │ │ │ │ ├── HMC@Beta_x64.node │ │ │ │ ├── HMC@Beta_x86.node │ │ │ │ ├── HMC@v1.0_x64.node │ │ │ │ └── HMC@v1.0_x86.node │ │ │ ├── clip.ts │ │ │ ├── index.ts │ │ │ ├── promiseEval.ts │ │ │ ├── registr.ts │ │ │ ├── shell.ts │ │ │ ├── util.ts │ │ │ └── vkKey.ts │ │ ├── package-lock.json │ │ ├── package.json │ │ └── tsconfig.json │ └── type │ │ ├── Process.d.ts │ │ ├── ShellPromiseEval.d.ts │ │ ├── Sock.d.ts │ │ ├── Usb.d.ts │ │ ├── auto.d.ts │ │ ├── clip.d.ts │ │ ├── index.d.ts │ │ ├── promiseEval.d.ts │ │ ├── registr.d.ts │ │ ├── shell.d.ts │ │ └── util.d.ts ├── lib_temp │ ├── console.hpp │ ├── example │ │ ├── hmc_console.cpp │ │ ├── hmc_env.cpp │ │ ├── hmc_registr.cpp │ │ └── hmc_tray.cpp │ ├── process.hpp │ ├── tray.hpp │ └── window.hpp ├── mian │ ├── chcpList.d.ts │ ├── chcpList.ts │ ├── hmc.ts │ ├── hmc2.d.ts │ ├── hmc2.js │ ├── hmc2.ts │ ├── trash │ │ ├── chcpList.d.ts │ │ ├── chcpList.js │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── index.js.map │ │ ├── index.ts │ │ ├── native.js │ │ └── native.ts │ ├── vkKey.d.ts │ ├── vkKey.js │ └── vkKey.ts ├── src │ ├── NAPI异步任务.png │ ├── NAPI异步任务.xmind │ ├── NAPI异步任务设计.png │ ├── us_en.png │ ├── us_en_max.png │ ├── zh_cn.png │ └── zh_cn_max.png └── 测试 │ ├── GetProcessCommandLineByPid.cpp │ ├── PromiseFunctionEx 2.0.cpp │ ├── async_callback.cc │ ├── async_work_promise.cc │ ├── async_work_promise_namespace.cc │ ├── async_work_thread_safe_function.cc │ ├── enumAllProcess.js │ ├── find_win.js │ ├── main.d.ts │ ├── main.js │ ├── main.ts │ ├── new-fun-promise.cc │ ├── new-fun-promise2.cc │ ├── package-lock.json │ ├── package.json │ ├── tsconfig.json │ ├── 不冲突的异步函数 Promise.cc │ └── 不冲突的异步函数.cc ├── tsconfig.json ├── vkKey.d.ts └── 二次开发指南.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | source/CPP/build/ 3 | .DS_Store 4 | .vs/ 5 | .vscode/ 6 | .lh/ 7 | build/ 8 | npm-debug.log 9 | dist/ 10 | source/mian/hmc.d.ts 11 | source/mian/index.d.ts 12 | source/mian/index.d.ts 13 | native.d.ts 14 | source/mian/chcpList.js 15 | source/mian/hmc.js 16 | source/CPP_Reconfig/util/dll/ConsoleApplication1/Debug 17 | source/CPP_Reconfig/util/dll/ConsoleApplication1/x64 18 | source/CPP_Reconfig/util/dll/ConsoleApplication1/Release 19 | source/CPP_Reconfig/util/dll/ConsoleApplication1/.vs 20 | source/CPP_Reconfig/util/dll/hmc_win32_gui_lib/Debug 21 | source/CPP_Reconfig/util/dll/hmc_win32_gui_lib/x64 22 | source/CPP_Reconfig/util/dll/hmc_win32_gui_lib/Release 23 | source/CPP_Reconfig/util/dll/hmc_win32_gui_lib/.vs 24 | source/CPP_Reconfig/build/ 25 | Debug/ 26 | Release/ 27 | x64_Release/ 28 | x86_Release/ 29 | x64_Debug/ 30 | x86_Debug/ 31 | source/hmc-module-static/_Temp 32 | source/hmc-module-static/SharedLibrary/hmc-module-static_DEBUG_X64.idb 33 | source/hmc-module-static/SharedLibrary/hmc-module-static_DEBUG_X64.pdb 34 | source/hmc-module-static/SharedLibrary/hmc-module-static_DEBUG_X86.lib 35 | source/hmc-module-static/SharedLibrary/hmc-module-static_RELEASE_X64.lib 36 | source/hmc-module-static/SharedLibrary/hmc-module-static_DEBUG_X86.idb 37 | source/hmc-module-static/SharedLibrary/hmc-module-static_DEBUG_X64.lib 38 | source/hmc-module-static/SharedLibrary/hmc-module-static_RELEASE_X64.pdb 39 | source/hmc-module-static/SharedLibrary/hmc-module-static_DEBUG_X86.pdb 40 | source/hmc-module-static/SharedLibrary/hmc-module-static_RELEASE_X86.lib 41 | source/hmc-module-static/SharedLibrary/hmc-module-static_RELEASE_X86.pdb 42 | source/hmc-module-static/example/example_sock/hmc-module -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "source/hmc-module"] 2 | path = source/hmc-module 3 | url = https://github.com/kihlh/hmc-module.git 4 | [submodule "hmc-module-static"] 5 | path = hmc-module-static 6 | url = https://github.com/kihlh/hmc-module.git 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Joshua Wise 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bin/HMC@Beta_x64.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/bin/HMC@Beta_x64.node -------------------------------------------------------------------------------- /bin/HMC@Beta_x86.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/bin/HMC@Beta_x86.node -------------------------------------------------------------------------------- /bin/HMC_x64.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/bin/HMC_x64.node -------------------------------------------------------------------------------- /bin/HMC_x86.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/bin/HMC_x86.node -------------------------------------------------------------------------------- /chcpList.d.ts: -------------------------------------------------------------------------------- 1 | import { HMC } from "./hmc"; 2 | export declare let chcpList: { 3 | [key: string | number]: HMC.SystemDecoder; 4 | }; 5 | -------------------------------------------------------------------------------- /document/zh-自动化/hmc_automation_util (c++) .md: -------------------------------------------------------------------------------- 1 | # 自动化键鼠相关 hmc_automation_util 2 | 3 | 自动化键鼠相关 4 | 5 | - include : `hmc-module\include\hmc_automation_util.h` 6 | - cpp : `hmc-module\src\hmc_automation_util.cpp` 7 | - c++ version :`C++17` 8 | 9 | 10 | 11 | ## hmc_Keyboard 是个键盘操作功能合集 12 | 13 | #### 结构体 14 | 15 | - **chHasKeysBasic** 键盘四大功能键的状态数据体 16 | - shift `bool` 17 | - alt `bool` 18 | - ctrl `bool` 19 | - win `bool` 20 | 21 | - **chKeyboardHookEvent** 低级hook事件数据体 22 | - `long long` id; // 事件id 23 | - `long` keyCode; // 键码 24 | - `DWORD` time; // 事件时间 25 | - `bool` down; // 按键是否被按下 26 | - `DWORD` scanCode; // 执行的设备id 27 | - `DWORD` flags; // 扩展键标志 28 | - `bool` is_valid(); // 判断内容是否有效 29 | - `std::string` to_json(); // 转为json 30 | 31 | ### keyboardHook 键盘低级监听函数 32 | 33 | - 方法1允许返回一个布尔值用于控制此事件是否拦截 34 | 35 | ##### 方法1 36 | 37 | ```c++ 38 | #include 39 | #include "hmc_automation_util.h" 40 | 41 | 42 | bool keyCallBack(hmc_Keyboard::chKeyboardHookEvent event) 43 | { 44 | 45 | std::cout << "Keyboard-> " << event.to_mpKey() <<" down: " << std::boolalpha << event.down << "\n"; 46 | 47 | if (event.keyCode == VK_ESCAPE && event.down) 48 | { 49 | hmc_Keyboard::keyboardHook::stopHookKeyboard(); 50 | } 51 | 52 | return true; 53 | } 54 | 55 | 56 | 57 | int main() 58 | { 59 | 60 | hmc_Keyboard::keyboardHook::initKeyboardEventHook(keyCallBack); 61 | 62 | do 63 | { 64 | ::Sleep(1500); 65 | } while (hmc_Keyboard::keyboardHook::isValidHookKeyboard()); 66 | 67 | } 68 | 69 | ``` 70 | 71 | ##### 方法2 72 | 73 | ```c++ 74 | #include 75 | #include "hmc_automation_util.h" 76 | 77 | int main() 78 | { 79 | 80 | hmc_Keyboard::keyboardHook::initKeyboardEventHook(); 81 | 82 | do 83 | { 84 | 85 | auto KeyboardEvent = hmc_Keyboard::keyboardHook::getAllKeyboardEvent(); 86 | 87 | for (auto&& event : KeyboardEvent) 88 | { 89 | std::cout << " [ " << event.to_mpKey() << " ] " << event.to_json() << std::endl; 90 | 91 | if (event.keyCode == VK_ESCAPE && event.down) 92 | { 93 | hmc_Keyboard::keyboardHook::stopHookKeyboard(); 94 | } 95 | } 96 | 97 | ::Sleep(50); 98 | 99 | } while (hmc_Keyboard::keyboardHook::isValidHookKeyboard()); 100 | } 101 | 102 | ``` 103 | 104 | 105 | 106 | ## hmc_mouse 是个鼠标操作功能合集 107 | 108 | #### 结构体 109 | 110 | - **chMouseHookEvent** 低级hook事件数据体 111 | - `long long` id; // 事件id 112 | - `long` button; // 按钮是哪个 113 | - `long` wheelDelta; // 滚轮数据 如果向上则为正值 向下则为负值 114 | - `bool` buttonDown; // 按钮是否按下状态的 如果滚轮则为向上 115 | - `DWORD` time; // 事件时间 116 | - `long` x; // 坐标 左到右边 117 | - `long` y; // 坐标 顶部到底部 118 | - `MouseEvent();` // 开辟内存 119 | - `bool is_valid();` // 判断内容是否有效 120 | - `std::string to_json();` // 转到json 121 | 122 | - **chMouseBasic** 123 | - `bool` middle; // 鼠标中键被按下 124 | - `bool` right; // 鼠标右键被按下 125 | - `bool` left; // 鼠标左键被按下 126 | 127 | 128 | 129 | ### MouseHook鼠标低级监听函数 130 | 131 | - 方法1允许返回一个布尔值用于控制此事件是否拦截 132 | 133 | ##### 方法1 134 | 135 | ```c++ 136 | #include 137 | #include "hmc_automation_util.h" 138 | 139 | 140 | bool mouseCallBack(hmc_mouse::chMouseHookEvent event) { 141 | 142 | std::cout << " [ chMouseHookEvent ] " << event.to_json() << std::endl; 143 | 144 | 145 | if (event.id > 500) { 146 | 147 | hmc_mouse::MouseHook::stopHookMouse(); 148 | 149 | } 150 | 151 | return true; 152 | } 153 | 154 | int main() 155 | { 156 | 157 | hmc_mouse::MouseHook::initMouseEventHook(mouseCallBack); 158 | 159 | do 160 | { 161 | ::Sleep(1500); 162 | } while (hmc_mouse::MouseHook::isValidHookMouse()); 163 | 164 | } 165 | 166 | ``` 167 | 168 | ##### 方法2 169 | 170 | ```c++ 171 | #include 172 | #include "hmc_automation_util.h" 173 | 174 | int main() 175 | { 176 | 177 | hmc_mouse::MouseHook::initMouseEventHook(); 178 | 179 | do 180 | { 181 | auto mousePoints = hmc_mouse::MouseHook::getMouseEvent(); 182 | 183 | for (auto&& event : mousePoints) { 184 | 185 | std::cout << " [ chMouseHookEvent ] " << event.to_json() << std::endl; 186 | 187 | 188 | if (event.id > 500) { 189 | 190 | hmc_mouse::MouseHook::stopHookMouse(); 191 | 192 | } 193 | 194 | } 195 | 196 | ::Sleep(30); 197 | } while (hmc_mouse::MouseHook::isValidHookMouse()); 198 | 199 | } 200 | 201 | ``` 202 | 203 | ## 限制鼠标移动位置 204 | 205 | setLimitMouseRange API 是一个限制鼠标可移动范围的函数,他可以为鼠标划定一个屏幕上的指定矩形,划定为鼠标可移动的范围 206 | 207 | ps: 208 | 209 | - 可以调用 **stopLimitMouseRangeWorker** 提前结束 210 | - 最高不允许超过30000ms (30秒) 最低不允许低于31ms 211 | - 范围为正方形 如果没有设置right与bottom的值则将限制为1x1的正方形 (不可动) 212 | 213 | ```javascript 214 | #include 215 | #include "hmc_automation_util.h" 216 | 217 | int main() 218 | { 219 | 220 | if (!hmc_mouse::LimitMouseRange::hasLimitMouseRange_worker()) { 221 | 222 | // 划分一个 从1,1 开始 的50x50矩形限制位置 223 | hmc_mouse::LimitMouseRange::setLimitMouseRange(5000, 1, 50, 50, 50); 224 | 225 | // 提前结束 226 | hmc_mouse::LimitMouseRange::stopLimitMouseRange_worker(); 227 | 228 | } 229 | } 230 | 231 | ``` 232 | 233 | ![image-20240404132340084](https://s2.loli.net/2024/04/04/KaoEypRqPlfzOLj.png) 234 | 235 | ### hmc_automation_util 是个相关操作功能合集 236 | 237 | #### 类型定义 238 | 239 | - **GpMouseEventList** 事件名称对应表 240 | - 241 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hmc-win32", 3 | "version": "1.4.9", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "hmc-win32", 9 | "version": "1.4.9", 10 | "license": "MIT License", 11 | "devDependencies": { 12 | "@types/node": "^16.18.76" 13 | }, 14 | "engines": { 15 | "node": ">= 6.14.2" 16 | } 17 | }, 18 | "node_modules/@types/node": { 19 | "version": "16.18.76", 20 | "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.76.tgz", 21 | "integrity": "sha512-/GsO2uv1Z6R42lBr59dtem56gVF/yHKQaScggwU+gLU6DXE25sDmOar4c4IfWb3h+X/7OYZznPOFk7oGF3jQSA==", 22 | "dev": true 23 | } 24 | }, 25 | "dependencies": { 26 | "@types/node": { 27 | "version": "16.18.76", 28 | "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.76.tgz", 29 | "integrity": "sha512-/GsO2uv1Z6R42lBr59dtem56gVF/yHKQaScggwU+gLU6DXE25sDmOar4c4IfWb3h+X/7OYZznPOFk7oGF3jQSA==", 30 | "dev": true 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hmc-win32", 3 | "version": "1.4.92", 4 | "description": "Connect to the system api in the easiest way (win-api)", 5 | "license": "MIT License", 6 | "main": "./index.js", 7 | "types": "hmc.d.ts", 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/kihlh/hmc-win32.git" 11 | }, 12 | "files": [ 13 | "hmc.d.ts", 14 | "hmc2.d.ts", 15 | "vkKey.d.ts", 16 | "chcpList.d.ts", 17 | "bin/HMC_x64.node", 18 | "bin/HMC_x86.node", 19 | "bin/HMC@Beta_x64.node", 20 | "bin/HMC@Beta_x86.node", 21 | "index.js" 22 | ], 23 | "homepage": "https://kihlh.gitbook.io/hmc/", 24 | "scripts": { 25 | "build": "cd CPP&&node-gyp rebuild", 26 | "ts": "tsc -d -w", 27 | "publish": "npm publish", 28 | "pull": "git push origin master -f", 29 | "esbuild-cjs": "esbuild ./source/mian/hmc.ts --charset=utf8 --bundle --external:./HMC.node --external:../HMC.node --platform=node --format=iife --target=node8 --watch --format=cjs --outfile=index.js", 30 | "esbuild-cjs-Beta": "esbuild ./source/hmc-win32@2.0/source/main/index.ts --charset=utf8 --bundle --external:./bin/HMC@v1.0_x64.node --external:./bin/HMC@v1.0_x86.node --external:./bin/HMC@Beta_x86.node --external:./bin/HMC@Beta_x64.node --platform=node --format=iife --target=node16 --watch --format=cjs --outfile=./source/hmc-win32@2.0/index.cjs", 31 | "esbuild-mjs-Beta": "esbuild ./source/hmc-win32@2.0/source/main/index.ts --banner:js=process.env.HMC___CREATE__REQUIRE___URL__ESM_MODE_PATH=import.meta.url; --charset=utf8 --bundle --external:./bin/HMC@v1.0_x64.node --external:./bin/HMC@v1.0_x86.node --external:./bin/HMC@Beta_x86.node --external:./bin/HMC@Beta_x64.node --platform=node --format=iife --target=node11 --watch --format=esm --outfile=./source/hmc-win32@2.0/hmc-esm.mjs" 32 | }, 33 | "engines": { 34 | "node": ">= 6.14.2" 35 | }, 36 | "devDependencies": { 37 | "@types/node": "^16.18.76" 38 | }, 39 | "keywords": [ 40 | "electron", 41 | "nw.js", 42 | "mousemove", 43 | "winapi", 44 | "system", 45 | "window", 46 | "clipboard", 47 | "HWND", 48 | "open", 49 | "app", 50 | "admin", 51 | "napi", 52 | "power", 53 | "process", 54 | "sleep", 55 | "message", 56 | "alert", 57 | "confirm", 58 | "LOOK", 59 | "USB", 60 | "Keyboard", 61 | "freezeKeyboard", 62 | "Taskbar", 63 | "regedit", 64 | "files", 65 | "file", 66 | "symlink", 67 | "hardlink", 68 | "link", 69 | "open-app", 70 | "open-url", 71 | "open-external", 72 | "hide", 73 | "show", 74 | "hide-console-window", 75 | "self-starting", 76 | "menu", 77 | "tool", 78 | "util", 79 | "mouse", 80 | "kill-process", 81 | "handle", 82 | "set-title", 83 | "visible", 84 | "enum-child-windows", 85 | "process-list", 86 | "win-api", 87 | "clipboard", 88 | "clip", 89 | "usb", 90 | "delete-file", 91 | "trash", 92 | "recycle", 93 | "watch-clipboard", 94 | "watch-usb", 95 | "watch-clip", 96 | "watch-drive", 97 | "watch-process", 98 | "watch-window", 99 | "change-clipboard", 100 | "change-usb", 101 | "change-clip", 102 | "change-drive", 103 | "change-process", 104 | "change-window", 105 | "has-webView2", 106 | "webView2", 107 | "web-view2", 108 | "iohook", 109 | "hook", 110 | "keyboard", 111 | "mouse-hook", 112 | "Mutex", 113 | "environment", 114 | "env", 115 | "escape-env", 116 | "remove-system-variable", 117 | "put-system-variable", 118 | "get-system-variable", 119 | "find-process", 120 | "process-start-time" 121 | ] 122 | } 123 | -------------------------------------------------------------------------------- /source/HMC1.0源代码 [停止维护] 逐步升级到2.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/HMC1.0源代码 [停止维护] 逐步升级到2.0.zip -------------------------------------------------------------------------------- /source/hmc-autoIt/AutoItX.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-autoIt/AutoItX.chm -------------------------------------------------------------------------------- /source/hmc-autoIt/AutoItX.chw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-autoIt/AutoItX.chw -------------------------------------------------------------------------------- /source/hmc-autoIt/AutoItX3/AutoItX3_DLL.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-autoIt/AutoItX3/AutoItX3_DLL.lib -------------------------------------------------------------------------------- /source/hmc-autoIt/AutoItX3/AutoItX3_x64_DLL.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-autoIt/AutoItX3/AutoItX3_x64_DLL.lib -------------------------------------------------------------------------------- /source/hmc-autoIt/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Joshua Wise 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /source/hmc-autoIt/Main.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define NAPI_EXPERIMENTAL // 开启实验性功能 比如异步(多线程) 4 | #include 5 | 6 | using namespace std; 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | // 截屏的存储为文件 14 | #include 15 | 16 | // 小写转换 17 | #include 18 | #include 19 | 20 | #include "./util/hmc_string_util.hpp" 21 | #include "../CPP/util/napi_value_util.hpp" 22 | #include "./AutoItX3.hpp" 23 | 24 | using namespace std; 25 | 26 | #define $napi_get_cb_info(argsLen, args, fnName) \ 27 | if (napi_get_cb_info(env, info, &argsLen, args, NULL, NULL) != napi_ok) \ 28 | { \ 29 | napi_throw_type_error(env, NULL, string(fnName).c_str()); \ 30 | return NULL; \ 31 | } 32 | 33 | // 导出一个其他cpp中的模块 34 | #define DECLARE_NAPI_METHODRM(name, func) \ 35 | { \ 36 | name, 0, (napi_callback) & func, 0, 0, 0, napi_default, 0 \ 37 | } 38 | 39 | // 导出一个模块 40 | #define DECLARE_NAPI_METHOD(name, func) \ 41 | { \ 42 | name, 0, func, 0, 0, 0, napi_default, 0 \ 43 | } 44 | 45 | // 导出一个文本内容 46 | #define DECLARE_NAPI_VALUE(name, value) \ 47 | { \ 48 | name, 0, 0, 0, 0, hmc_napi_util::create_value::String(env, value), napi_default, 0 \ 49 | } 50 | -------------------------------------------------------------------------------- /source/hmc-autoIt/bin/AutoItX3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-autoIt/bin/AutoItX3.dll -------------------------------------------------------------------------------- /source/hmc-autoIt/bin/AutoItX3_x64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-autoIt/bin/AutoItX3_x64.dll -------------------------------------------------------------------------------- /source/hmc-autoIt/bin/AutoItX_x64.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-autoIt/bin/AutoItX_x64.node -------------------------------------------------------------------------------- /source/hmc-autoIt/bin/AutoItX_x86.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-autoIt/bin/AutoItX_x86.node -------------------------------------------------------------------------------- /source/hmc-autoIt/binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": "AutoItX_x64", 5 | "conditions": [ 6 | ['OS=="win"', { 7 | "sources": [ 8 | "./util/hmc_string_util.cpp", 9 | "Main.cpp" 10 | ], 11 | 'msvs_settings': { 12 | 'VCCLCompilerTool': { 13 | 'AdditionalOptions': [ 14 | '/W3', 15 | '/Qspectre', 16 | '/guard:cf', 17 | "/wd4819", 18 | "/wd4067", 19 | "/wd4101", 20 | "/wd4312", 21 | "/wd4311", 22 | "/wd4302", 23 | "/wd4060", 24 | "/wd4700", 25 | "/wd4081", 26 | "/wd4530", 27 | "/wd4715", 28 | "/wd4018" 29 | ] 30 | }, 31 | "libraries": [ 32 | "AutoItX3/AutoItX3_DLL.lib", 33 | "AutoItX3/AutoItX3_x64_DLL.lib" 34 | ], 35 | 'VCLinkerTool': { 36 | 'AdditionalOptions': [ 37 | '/guard:cf' 38 | ] 39 | } 40 | }, 41 | }] 42 | ] 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /source/hmc-autoIt/build.cmd: -------------------------------------------------------------------------------- 1 | node-gyp rebuild --msvs_version=2019 2 | 3 | @REM node-gyp rebuild --arch=ia32 --msvs_version=2019 -------------------------------------------------------------------------------- /source/hmc-autoIt/copyright.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | AutoIt是一个免费的脚本语言和工具包,用于Windows系统的自动化和脚本编写。虽然AutoIt是免费提供的,但它并没有明确说明是以哪种具体的开源许可证发布的。如果您需要了解AutoIt的开源许可证信息,建议您查阅AutoIt的官方网站或项目文档,或者联系AutoIt团队以获得更详细的信息。 4 | 5 | 根据提供的End-User License Agreement (EULA),AutoIt可以用于商业用途。EULA中明确表示,您可以使用AutoIt软件进行商业目的,包括出售脚本或编译后的脚本,并可以自由分发使用AutoIt创建的脚本。 6 | 7 | 以下是EULA中相关条款的摘录: 8 | 9 | "Installation and Use. You may install and use an unlimited number of copies of the SOFTWARE PRODUCT." 10 | "Reproduction and Distribution. You may reproduce and distribute an unlimited number of copies of the SOFTWARE PRODUCT either in whole or in part; each copy should include all copyright and trademark notices, and shall be accompanied by a copy of this EULA. Copies of the SOFTWARE PRODUCT may be distributed as a standalone product or included with your own product." 11 | "Commercial Use. You may use the SOFTWARE PRODUCT for commercial purposes. You may sell for profit and freely distribute scripts and/or compiled scripts that were created with the SOFTWARE PRODUCT." 12 | 13 | 因此,根据AutoIt的EULA,您可以在商业项目中使用AutoIt软件及其相关脚本,包括出售商业产品或将AutoIt脚本集成到商业产品中。但是,为确保遵守所有使用条款,请务必仔细阅读EULA,并遵循其中的规定。如果您对商业用途的具体限制有任何疑问,建议您与AutoIt的官方团队联系,以获得更准确的解释和指导。 14 | 15 | 16 | Software License 17 | AutoIt 18 | 19 | Author : Jonathan Bennett and the AutoIt Team 20 | WWW : https://www.autoitscript.com/site/autoit/ 21 | Email : support at autoitscript dot com 22 | ________________________________________________________ 23 | 24 | END-USER LICENSE AGREEMENT FOR THIS SOFTWARE 25 | 26 | This End-User License Agreement ("EULA") is a legal agreement between you (either an individual or a single entity) and the mentioned author of this Software for the software product identified above, which includes computer software and may include associated media, printed materials, and "online" or electronic documentation ("SOFTWARE PRODUCT"). By installing, copying, or otherwise using the SOFTWARE PRODUCT, you agree to be bound by the terms of this EULA. If you do not agree to the terms of this EULA, do not install or use the SOFTWARE PRODUCT. 27 | 28 | 29 | 30 | SOFTWARE PRODUCT LICENSE 31 | 32 | The SOFTWARE PRODUCT is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. The SOFTWARE PRODUCT is licensed, not sold. 33 | 34 | The definition of SOFTWARE PRODUCT does not includes any files generated by the SOFTWARE PRODUCT, such as compiled script files in the form of standalone executables. 35 | 36 | 1. GRANT OF LICENSE 37 | 38 | This EULA grants you the following rights: 39 | 40 | Installation and Use. You may install and use an unlimited number of copies of the SOFTWARE PRODUCT. 41 | 42 | Reproduction and Distribution. You may reproduce and distribute an unlimited number of copies of the SOFTWARE PRODUCT either in whole or in part; each copy should include all copyright and trademark notices, and shall be accompanied by a copy of this EULA. Copies of the SOFTWARE PRODUCT may be distributed as a standalone product or included with your own product. 43 | 44 | Commercial Use. You may use the SOFTWARE PRODUCT for commercial purposes. You may sell for profit and freely distribute scripts and/or compiled scripts that were created with the SOFTWARE PRODUCT. 45 | 46 | Reverse engineering. You may not reverse engineer or disassemble the SOFTWARE PRODUCT. 47 | 48 | 2. COPYRIGHT 49 | 50 | All title and copyrights in and to the SOFTWARE PRODUCT (including but not limited to any images, photographs, animations, video, audio, music, text, and "applets" incorporated into the SOFTWARE PRODUCT), the accompanying printed materials, and any copies of the SOFTWARE PRODUCT are owned by the Author of this Software. The SOFTWARE PRODUCT is protected by copyright laws and international treaty provisions. Therefore, you must treat the SOFTWARE PRODUCT like any other copyrighted material. 51 | 52 | 53 | 54 | MISCELLANEOUS 55 | 56 | If you acquired this product in the United Kingdom, this EULA is governed by the laws of the United Kingdom. If this product was acquired outside the United Kingdom, then local law may apply. 57 | 58 | Should you have any questions concerning this EULA, or if you desire to contact the author of this Software for any reason, please contact him/her at the email address mentioned at the top of this EULA. 59 | 60 | 61 | 62 | LIMITED WARRANTY 63 | 64 | 1. NO WARRANTIES 65 | 66 | The Author of this Software expressly disclaims any warranty for the SOFTWARE PRODUCT. The SOFTWARE PRODUCT and any related documentation is provided "as is" without warranty of any kind, either express or implied, including, without limitation, the implied warranties or merchantability, fitness for a particular purpose, or non-infringement. The entire risk arising out of use or performance of the SOFTWARE PRODUCT remains with you. 67 | 68 | 2. NO LIABILITY FOR DAMAGES 69 | 70 | In no event shall the author of this Software be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of or inability to use this product, even if the Author of this Software has been advised of the possibility of such damages. Because some states/jurisdictions do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you. 71 | 72 | 73 | 74 | [END OF LICENSE] -------------------------------------------------------------------------------- /source/hmc-autoIt/license-AutoItX.md: -------------------------------------------------------------------------------- 1 | # Software License 2 | 3 | **AutoIt** 4 | 5 | **Author** : Jonathan Bennett and the AutoIt Team 6 | **WWW** : https://www.autoitscript.com/site/autoit/ 7 | **Email** : support at autoitscript dot com 8 | ________________________________________________________ 9 | 10 | **END-USER LICENSE AGREEMENT FOR THIS SOFTWARE** 11 | 12 | This End-User License Agreement ("EULA") is a legal agreement between you (either an individual or a single entity) and the mentioned author of this Software for the software product identified above, which includes computer software and may include associated media, printed materials, and "online" or electronic documentation ("SOFTWARE PRODUCT"). By installing, copying, or otherwise using the SOFTWARE PRODUCT, you agree to be bound by the terms of this EULA. If you do not agree to the terms of this EULA, do not install or use the SOFTWARE PRODUCT. 13 | 14 | 15 | 16 | **SOFTWARE PRODUCT LICENSE** 17 | 18 | The SOFTWARE PRODUCT is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. The SOFTWARE PRODUCT is licensed, not sold. 19 | 20 | The definition of SOFTWARE PRODUCT does not includes any files generated by the SOFTWARE PRODUCT, such as compiled script files in the form of standalone executables. 21 | 22 | **1. GRANT OF LICENSE** 23 | 24 | This EULA grants you the following rights: 25 | 26 | Installation and Use. You may install and use an unlimited number of copies of the SOFTWARE PRODUCT. 27 | 28 | Reproduction and Distribution. You may reproduce and distribute an unlimited number of copies of the SOFTWARE PRODUCT either in whole or in part; each copy should include all copyright and trademark notices, and shall be accompanied by a copy of this EULA. Copies of the SOFTWARE PRODUCT may be distributed as a standalone product or included with your own product. 29 | 30 | Commercial Use. You may use the SOFTWARE PRODUCT for commercial purposes. You may sell for profit and freely distribute scripts and/or compiled scripts that were created with the SOFTWARE PRODUCT. 31 | 32 | Reverse engineering. You may not reverse engineer or disassemble the SOFTWARE PRODUCT. 33 | 34 | **2. COPYRIGHT** 35 | 36 | All title and copyrights in and to the SOFTWARE PRODUCT (including but not limited to any images, photographs, animations, video, audio, music, text, and "applets" incorporated into the SOFTWARE PRODUCT), the accompanying printed materials, and any copies of the SOFTWARE PRODUCT are owned by the Author of this Software. The SOFTWARE PRODUCT is protected by copyright laws and international treaty provisions. Therefore, you must treat the SOFTWARE PRODUCT like any other copyrighted material. 37 | 38 | 39 | 40 | **MISCELLANEOUS** 41 | 42 | If you acquired this product in the United Kingdom, this EULA is governed by the laws of the United Kingdom. If this product was acquired outside the United Kingdom, then local law may apply. 43 | 44 | Should you have any questions concerning this EULA, or if you desire to contact the author of this Software for any reason, please contact him/her at the email address mentioned at the top of this EULA. 45 | 46 | 47 | 48 | **LIMITED WARRANTY** 49 | 50 | **1. NO WARRANTIES** 51 | 52 | The Author of this Software expressly disclaims any warranty for the SOFTWARE PRODUCT. The SOFTWARE PRODUCT and any related documentation is provided "as is" without warranty of any kind, either express or implied, including, without limitation, the implied warranties or merchantability, fitness for a particular purpose, or non-infringement. The entire risk arising out of use or performance of the SOFTWARE PRODUCT remains with you. 53 | 54 | **2. NO LIABILITY FOR DAMAGES** 55 | 56 | In no event shall the author of this Software be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of or inability to use this product, even if the Author of this Software has been advised of the possibility of such damages. Because some states/jurisdictions do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you. 57 | 58 | 59 | 60 | [END OF LICENSE] -------------------------------------------------------------------------------- /source/hmc-autoIt/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hmc-autoit", 3 | "version": "1.0.1", 4 | "description": "An API forwarding module based on the combination of autoItX and NAPI (Node-API, C) provides a seamless solution without the need for recompilation or the use of \"ffi\" magic. It ensures high security and efficiency.", 5 | "license": "MIT License", 6 | "main": "./index.js", 7 | "types": "index.d.ts", 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/kihlh/hmc-win32.git" 11 | }, 12 | "files": [ 13 | "index.d.ts", 14 | "bin/AutoItX_x64.node", 15 | "bin/AutoItX_x86.node", 16 | "bin/AutoItX3.dll", 17 | "bin/AutoItX3_x64.dll", 18 | "index.js" 19 | ], 20 | "homepage": "https://documentation.help/AutoItX/introduction.htm", 21 | "keywords": [ 22 | "win32", 23 | "AutoItX", 24 | "AutoIt", 25 | "Windows", 26 | "Auto", 27 | "NAPI", 28 | "c++", 29 | "c", 30 | "ffi" 31 | ], 32 | "scripts": { 33 | "build": "cd CPP&&node-gyp rebuild", 34 | "ts": "tsc -d -w", 35 | "publish": "npm publish", 36 | "pull": "git push origin master -f" 37 | }, 38 | "engines": { 39 | "node": ">= 6.14.2" 40 | }, 41 | "devDependencies": { 42 | "@types/node": "^16.18.66" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /source/hmc-autoIt/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "skipLibCheck": true, 4 | /* Basic Options */ 5 | // "moduleResolution": "node", 6 | // "importHelpers": true, 7 | // "skipLibCheck": true, 8 | // "resolveJsonModule": true, 9 | // "noImplicitAny": false, 10 | "target": "ES2017" /* target用于指定编译之后的版本目标: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, 11 | "module": "commonjs" /* 用来指定要使用的模块标准: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, 12 | // "lib": [ "ES2021"] /* lib用于指定要包含在编译中的库文件 */, 13 | // "allowJs": true, /* allowJs设置的值为true或false,用来指定是否允许编译js文件,默认是false,即不编译js文件 */ 14 | // "checkJs": true, /* checkJs的值为true或false,用来指定是否检查和报告js文件中的错误,默认是false */ 15 | // "jsx": "preserve", /* 指定jsx代码用于的开发环境: 'preserve', 'react-native', or 'react'. */ 16 | // "declaration": true, /* declaration的值为true或false,用来指定是否在编译的时候生成相应的".d.ts"声明文件。如果设为true,编译每个ts文件之后会生成一个js文件和一个声明文件。但是declaration和allowJs不能同时设为true */ 17 | // "declarationMap": true, /* 值为true或false,指定是否为声明文件.d.ts生成map文件 */ 18 | "sourceMap": false /* sourceMap的值为true或false,用来指定编译时是否生成.map文件 */, 19 | // "outFile": "./", /* outFile用于指定将输出文件合并为一个文件,它的值为一个文件路径名。比如设置为"./dist/main.js",则输出的文件为一个main.js文件。但是要注意,只有设置module的值为amd和system模块时才支持这个配置 */ 20 | // "outDir": "", 21 | /* outDir用来指定输出文件夹,值为一个文件夹路径字符串,输出的文件都将放置在这个文件夹 */ 22 | // "rootDir": "./", /* 用来指定编译文件的根目录,编译器会在根目录查找入口文件,如果编译器发现以rootDir的值作为根目录查找入口文件并不会把所有文件加载进去的话会报错,但是不会停止编译 */ 23 | // "composite": true, /* 是否编译构建引用项目 */ 24 | // "incremental": true, /* 是否启用增量编译*/ 25 | //"tsBuildInfoFile": "./builds/Tsc-BuildInfoFile" /* 指定文件用来存储增量编译信息 */, 26 | "removeComments": false /* removeComments的值为true或false,用于指定是否将编译后的文件中的注释删掉,设为true的话即删掉注释,默认为false */, 27 | // "noEmit": true, /* 不生成编译文件,这个一般比较少用 */ 28 | // "importHelpers": true, /* importHelpers的值为true或false,指定是否引入tslib里的辅助工具函数,默认为false */ 29 | // "downlevelIteration": true, /* 当target为'ES5' or 'ES3'时,为'for-of', spread, and destructuring'中的迭代器提供完全支持 */ 30 | // "isolatedModules": true, /* isolatedModules的值为true或false,指定是否将每个文件作为单独的模块,默认为true,它不可以和declaration同时设定 */ 31 | 32 | // /* Strict Type-Checking Options */ 33 | "strict": true, 34 | /* strict的值为true或false,用于指定是否启动所有类型检查,如果设为true则会同时开启下面这几个严格类型检查,默认为false */ 35 | // "noImplicitAny": false, /* noImplicitAny的值为true或false,如果我们没有为一些值设置明确的类型,编译器会默认认为这个值为any,如果noImplicitAny的值为true的话。则没有明确的类型会报错。默认值为false */ 36 | // "strictNullChecks": true, /* strictNullChecks为true时,null和undefined值不能赋给非这两种类型的值,别的类型也不能赋给他们,除了any类型。还有个例外就是undefined可以赋值给void类型 */ 37 | // "strictFunctionTypes": true, /* strictFunctionTypes的值为true或false,用于指定是否使用函数参数双向协变检查 */ 38 | // "strictBindCallApply": true, /* 设为true后会对bind、call和apply绑定的方法的参数的检测是严格检测的 */ 39 | // "strictPropertyInitialization": true, /* 设为true后会检查类的非undefined属性是否已经在构造函数里初始化,如果要开启这项,需要同时开启strictNullChecks,默认为false */ 40 | // "noImplicitThis": true, /* 当this表达式的值为any类型的时候,生成一个错误 */ 41 | // "alwaysStrict": true, /* alwaysStrict的值为true或false,指定始终以严格模式检查每个模块,并且在编译之后的js文件中加入"use strict"字符串,用来告诉浏览器该js为严格模式 */ 42 | 43 | // /* Additional Checks */ 44 | // "noUnusedLocals": true, /* 用于检查是否有定义了但是没有使用的变量,对于这一点的检测,使用eslint可以在你书写代码的时候做提示,你可以配合使用。它的默认值为false */ 45 | // "noUnusedParameters": true, /* 用于检查是否有在函数体中没有使用的参数,这个也可以配合eslint来做检查,默认为false */ 46 | // "noImplicitReturns": true, /* 用于检查函数是否有返回值,设为true后,如果函数没有返回值则会提示,默认为false */ 47 | "noFallthroughCasesInSwitch": true /* 用于检查switch中是否有case没有使用break跳出switch,默认为false */, 48 | 49 | // /* Module Resolution Options */ 50 | // "moduleResolution": "node", /* 用于选择模块解析策略,有'node'和'classic'两种类型' */ 51 | // "baseUrl": "./", /* baseUrl用于设置解析非相对模块名称的基本目录,相对模块不会受baseUrl的影响 */ 52 | // "paths": {}, 53 | /* 用于设置模块名称到基于baseUrl的路径映射 */ 54 | // "rootDirs": [], 55 | /* rootDirs可以指定一个路径列表,在构建时编译器会将这个路径列表中的路径的内容都放到一个文件夹中 */ 56 | "typeRoots": ["./node_modules/@types", "@types"], 57 | /* typeRoots用来指定声明文件或文件夹的路径列表,如果指定了此项,则只有在这里列出的声明文件才会被加载 */ 58 | // "types": [], /* types用来指定需要包含的模块,只有在这里列出的模块的声明文件才会被加载进来 */ 59 | "allowSyntheticDefaultImports": true, 60 | /* 用来指定允许从没有默认导出的模块中默认导入 */ 61 | "esModuleInterop": true /* 通过为导入内容创建命名空间,实现CommonJS和ES模块之间的互操作性 */, 62 | "preserveSymlinks": true /* 不把符号链接解析为其真实路径,具体可以了解下webpack和nodejs的symlink相关知识 */, 63 | // /* Source Map Options */ 64 | // "sourceRoot": "", /* sourceRoot用于指定调试器应该找到TypeScript文件而不是源文件位置,这个值会被写进.map文件里 */ 65 | // "mapRoot": "", /* mapRoot用于指定调试器找到映射文件而非生成文件的位置,指定map文件的根路径,该选项会影响.map文件中的sources属性 */ 66 | "inlineSourceMap": false /* 指定是否将map文件的内容和js文件编译在同一个js文件中,如果设为true,则map的内容会以//# sourceMappingURL=然后拼接base64字符串的形式插入在js文件底部 */, 67 | "inlineSources": false /* 用于指定是否进一步将.ts文件的内容也包含到输入文件中 */ 68 | 69 | // /* Experimental Options */ 70 | // "experimentalDecorators": true, /* 用于指定是否启用实验性的装饰器特性 */ 71 | // "emitDecoratorMetadata": true, /* 用于指定是否为装饰器提供元数据支持,关于元数据,也是ES6的新标准,可以通过Reflect提供的静态方法获取元数据,如果需要使用Reflect的一些方法,需要引入ES2015.Reflect这个库 */ 72 | }, 73 | // "files": [], // files可以配置一个数组列表,里面包含指定文件的相对或绝对路径,编译器在编译的时候只会编译包含在files中列出的文件,如果不指定,则取决于有没有设置include选项,如果没有include选项,则默认会编译根目录以及所有子目录中的文件。这里列出的路径必须是指定文件,而不是某个文件夹,而且不能使用* ? **/ 等通配符 74 | "include": ["./"], // include也可以指定要编译的路径列表,但是和files的区别在于,这里的路径可以是文件夹,也可以是文件,可以使用相对和绝对路径,而且可以使用通配符,比如"./src"即表示要编译src文件夹下的所有文件以及子文件夹的文件 75 | "exclude": ["*node_modules/*"] // exclude表示要排除的、不编译的文件,它也可以指定一个列表,规则和include一样,可以是文件或文件夹,可以是相对路径或绝对路径,可以使用通配符 76 | // "extends": "", // extends可以通过指定一个其他的tsconfig.json文件路径,来继承这个配置文件里的配置,继承来的文件的配置会覆盖当前文件定义的配置。TS在3.2版本开始,支持继承一个来自Node.js包的tsconfig.json配置文件 77 | // "compileOnSave": true, // compileOnSave的值是true或false,如果设为true,在我们编辑了项目中的文件保存的时候,编辑器会根据tsconfig.json中的配置重新生成文件,不过这个要编辑器支持 78 | // "references": [], // 一个对象数组,指定要引用的项目 79 | } 80 | -------------------------------------------------------------------------------- /source/hmc-autoIt/util/napi_cpp-function-export-table.d.ts: -------------------------------------------------------------------------------- 1 | export type cpp_type = "int" | "wstring" | "string" | "bool" | "void" | "long long" | "HWND" | "RECT" | "POINT" | "unsigned int" | "any" | "LPRECT" | "int64_t"; 2 | export type js_type = "undefined" | "string" | "boolean" | "number" | "bigint" | "null" | "{x:number, y:number}" | "{left:number, top:number,right:number, bottom:number}"; 3 | -------------------------------------------------------------------------------- /source/hmc-autoIt/util/ts-function-export.d.ts: -------------------------------------------------------------------------------- 1 | export type cpp_type = "int" | "wstring" | "string" | "bool" | "void" | "long long" | "HWND" | "RECT" | "POINT" | "unsigned int" | "any" | "LPRECT" | "int64_t"; 2 | export type js_type = "undefined" | "string" | "boolean" | "number" | "bigint" | "null" | "{x:number, y:number}" | "{left:number, top:number,right:number, bottom:number}"; 3 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Joshua Wise 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/bin/HMC@Beta_x64.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-win32@2.0/bin/HMC@Beta_x64.node -------------------------------------------------------------------------------- /source/hmc-win32@2.0/bin/HMC@Beta_x86.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-win32@2.0/bin/HMC@Beta_x86.node -------------------------------------------------------------------------------- /source/hmc-win32@2.0/bin/HMC@v1.0_x64.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-win32@2.0/bin/HMC@v1.0_x64.node -------------------------------------------------------------------------------- /source/hmc-win32@2.0/bin/HMC@v1.0_x86.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-win32@2.0/bin/HMC@v1.0_x86.node -------------------------------------------------------------------------------- /source/hmc-win32@2.0/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hmc-win32", 3 | "version": "2.0.0", 4 | "description": "Connect to the system api in the easiest way (win-api)", 5 | "license": "MIT License", 6 | "main": "./index.cjs", 7 | "types": "./type/index.d.ts", 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/kihlh/hmc-win32.git" 11 | }, 12 | "exports": { 13 | ".": { 14 | "types": "./type/index.d.ts", 15 | "import": "./hmc-esm.mjs", 16 | "require": "./index.cjs" 17 | }, 18 | "./esm":{ 19 | "types": "./type/index.d.ts", 20 | "import": "./hmc-esm.mjs", 21 | "require": "./hmc-esm.mjs" 22 | } 23 | }, 24 | "files": [ 25 | "type/index.d.ts", 26 | "type/auto.d.ts", 27 | "type/clip.d.ts", 28 | "type/Process.d.ts", 29 | "type/promiseEval.d.ts", 30 | "type/registr.d.ts", 31 | "type/shell.d.ts", 32 | "type/ShellPromiseEval.d.ts", 33 | "type/Sock.d.ts", 34 | "type/Usb.d.ts", 35 | "type/util.d.ts", 36 | "bin/HMC@Beta_x64.node", 37 | "bin/HMC@Beta_x86.node", 38 | "index.cjs", 39 | "hmc-esm.mjs" 40 | ], 41 | "homepage": "https://kihlh.gitbook.io/hmc/", 42 | "scripts": { 43 | "build": "cd CPP&&node-gyp rebuild", 44 | "ts": "tsc -d -w", 45 | "publish": "npm publish", 46 | "pull": "git push origin master -f" 47 | }, 48 | "engines": { 49 | "node": ">= 6.14.2" 50 | }, 51 | "devDependencies": { 52 | "@types/node": "^16.18.76" 53 | }, 54 | "keywords": [ 55 | "electron", 56 | "nw.js", 57 | "mousemove", 58 | "winapi", 59 | "system", 60 | "window", 61 | "clipboard", 62 | "HWND", 63 | "open", 64 | "app", 65 | "admin", 66 | "napi", 67 | "power", 68 | "process", 69 | "sleep", 70 | "message", 71 | "alert", 72 | "confirm", 73 | "LOOK", 74 | "USB", 75 | "Keyboard", 76 | "freezeKeyboard", 77 | "Taskbar", 78 | "regedit", 79 | "files", 80 | "file", 81 | "symlink", 82 | "hardlink", 83 | "link", 84 | "open-app", 85 | "open-url", 86 | "open-external", 87 | "hide", 88 | "show", 89 | "hide-console-window", 90 | "self-starting", 91 | "menu", 92 | "tool", 93 | "util", 94 | "mouse", 95 | "kill-process", 96 | "handle", 97 | "set-title", 98 | "visible", 99 | "enum-child-windows", 100 | "process-list", 101 | "win-api", 102 | "clipboard", 103 | "clip", 104 | "usb", 105 | "delete-file", 106 | "trash", 107 | "recycle", 108 | "watch-clipboard", 109 | "watch-usb", 110 | "watch-clip", 111 | "watch-drive", 112 | "watch-process", 113 | "watch-window", 114 | "change-clipboard", 115 | "change-usb", 116 | "change-clip", 117 | "change-drive", 118 | "change-process", 119 | "change-window", 120 | "has-webView2", 121 | "webView2", 122 | "web-view2", 123 | "iohook", 124 | "hook", 125 | "keyboard", 126 | "mouse-hook", 127 | "Mutex", 128 | "environment", 129 | "env", 130 | "escape-env", 131 | "remove-system-variable", 132 | "put-system-variable", 133 | "get-system-variable", 134 | "find-process", 135 | "process-start-time" 136 | ] 137 | } 138 | 139 | 140 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-win32@2.0/source/.gitmodules -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/bin/HMC@Beta_x64.node: -------------------------------------------------------------------------------- 1 | ../msvc/_Temp/x64_Release/hmc_debug.node -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/bin/HMC@Beta_x86.node: -------------------------------------------------------------------------------- 1 | ../msvc/_Temp/x86_Release/hmc_debug.node -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": "HMC_Beta", 5 | "conditions": [ 6 | ['OS=="win"', { 7 | "sources": [ 8 | "../../../hmc-module-static/src/hmc_napi_value_util.cpp", 9 | # 以下是hmc-module-static的源文件 可以使用hmc-module-static-static 的.lib库替代 10 | "../../../hmc-module-static/src/hmc_automation_util.cpp", 11 | "../../../hmc-module-static/src/hmc_registr_util.cpp", 12 | "../../../hmc-module-static/src/hmc_screen_util.cpp", 13 | "../../../hmc-module-static/src/hmc_shell_util.cpp", 14 | "../../../hmc-module-static/src/hmc_string_util.cpp", 15 | "../../../hmc-module-static/src/hmc_usb_util.cpp", 16 | "../../../hmc-module-static/src/hmc_util.cpp", 17 | "../../../hmc-module-static/src/hmc_windows_util.cpp", 18 | "../../../hmc-module-static/src/hmc_string_util.cpp", 19 | "../../../hmc-module-static/src/hmc_automation_util.cpp", 20 | "../../../hmc-module-static/src/hmc_byte_util.cpp", 21 | "../../../hmc-module-static/src/hmc_clip_util.cpp", 22 | # "../../../hmc-module-static/src/hmc_console_util.cpp", 23 | "../../../hmc-module-static/src/hmc_json_util.cpp", 24 | "./export/shell.cpp", 25 | "./export/screen.cpp", 26 | "./export/clip.cpp", 27 | "./export/window.cpp", 28 | "main.cpp", 29 | ], 30 | "include_dirs": ["../../../hmc-module-static/include/*","./export"], 31 | "libraries": [ 32 | # "<(module_root_dir)/SharedLibrary/hmc-module-static-static_RELEASE_X64.lib>", 33 | # "<(module_root_dir)/SharedLibrary/hmc-module-static-static_RELEASE_X86.lib>", 34 | # "<(module_root_dir)/SharedLibrary/hmc-module-static-static_DEBUG_X64.lib>", 35 | # "<(module_root_dir)/SharedLibrary/hmc-module-static-static_DEBUG_X86.lib>", 36 | ], 37 | 'msvs_settings': { 38 | 'VCCLCompilerTool': { 39 | 'AdditionalOptions': [ 40 | '/W3', 41 | '/Qspectre', 42 | '/guard:cf', 43 | "/wd4819", 44 | "/wd4067", 45 | "/wd4101", 46 | "/wd4312", 47 | "/wd4311", 48 | "/wd4302", 49 | "/wd4060", 50 | "/wd4700", 51 | "/wd4081", 52 | "/wd4530", 53 | "/wd4715", 54 | "/wd4018" 55 | ] 56 | }, 57 | 'VCLinkerTool': { 58 | 'AdditionalOptions': [ 59 | '/guard:cf' 60 | ] 61 | } 62 | }, 63 | }] 64 | ] 65 | } 66 | ] 67 | } 68 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/export/Promise.cpp: -------------------------------------------------------------------------------- 1 | #include "export.h" 2 | #include "hmc_napi_value_util.h" 3 | #include "hmc_process_util.h" 4 | #include "hmc_util.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/export/clip.cpp: -------------------------------------------------------------------------------- 1 | #include "export.h" 2 | #include "hmc_napi_value_util.h" 3 | #include "hmc_clip_util.h" 4 | 5 | napi_value getClipboardFilePaths(napi_env env, napi_callback_info info) 6 | { 7 | std::vector file_list = hmc_clip_util::GetClipboardPathListW(); 8 | std::wstring temp = L""; 9 | const size_t file_size = file_list.size(); 10 | 11 | size_t msize = 0; 12 | 13 | for (size_t i = 0; i < file_size; i++) 14 | { 15 | msize = msize + file_list.at(i).size(); 16 | } 17 | 18 | temp.reserve(msize + file_size * 2); 19 | 20 | for (size_t i = 0; i < file_size; i++) 21 | { 22 | auto &at = file_list.at(i); 23 | temp.append(at); 24 | 25 | if (i < file_size) 26 | { 27 | temp.push_back(L'\0'); 28 | } 29 | } 30 | 31 | return hmc_napi_create_value::String(env, temp, temp.length()); 32 | } 33 | 34 | napi_value setClipboardText(napi_env env, napi_callback_info info) 35 | { 36 | auto input = hmc_NodeArgsValue(env, info); 37 | input.eq({{0, js_string}}); 38 | bool is_html = input.exists(1) ? input.getBool(1, false) : false; 39 | bool result = false; 40 | 41 | if (is_html) 42 | { 43 | std::string text = input.getStringUtf8(0, ""); 44 | std::string url = input.exists(2) ? input.getStringUtf8(2, "") : ""; 45 | result = hmc_clip_util::SetClipboardHtml(text, url); 46 | } 47 | else 48 | { 49 | std::wstring text = input.getStringWide(0, L""); 50 | result = hmc_clip_util::SetClipboardText(text); 51 | } 52 | 53 | return hmc_napi_create_value::Boolean(env, result); 54 | } 55 | 56 | napi_value getClipboardText(napi_env env, napi_callback_info info) 57 | { 58 | return hmc_napi_create_value::String(env, hmc_clip_util::GetClipboardTextW()); 59 | } 60 | 61 | napi_value clearClipboard(napi_env env, napi_callback_info info) 62 | { 63 | return hmc_napi_create_value::Boolean(env, hmc_clip_util::ClearClipboard()); 64 | } 65 | 66 | napi_value setClipboardFilePaths(napi_env env, napi_callback_info info) 67 | { 68 | auto input = hmc_NodeArgsValue(env, info); 69 | if (input.exists(0)) 70 | { 71 | // 是文本而不是 array 72 | if (input.eq(0, js_string, false)) 73 | { 74 | auto ArrayWstring = input.getStringWide(0, {}); 75 | bool res = hmc_clip_util::SetClipboardPathList({ArrayWstring}); 76 | return hmc_napi_create_value::Boolean(env, res); 77 | } 78 | auto ArrayWstring = input.getArrayWstring(0, {}); 79 | bool res = hmc_clip_util::SetClipboardPathList(ArrayWstring); 80 | return hmc_napi_create_value::Boolean(env, res); 81 | } 82 | 83 | return hmc_napi_create_value::Boolean(env, false); 84 | } 85 | 86 | napi_value getClipboardInfo(napi_env env, napi_callback_info info) 87 | { 88 | auto data = hmc_clip_util::GetClipboardInfo(); 89 | auto Results = hmc_napi_create_value::jsObject(env); 90 | 91 | Results.putString("format", hmc_string_util::vec_to_array_json(data.format)); 92 | Results.putValue("formatCount", as_Number(data.formatCount)); 93 | Results.putValue("hwnd", as_Number(data.hwnd)); 94 | Results.putValue("id", as_Number(data.id)); 95 | 96 | return Results.toValue(); 97 | } 98 | 99 | napi_value enumClipboardFormats(napi_env env, napi_callback_info info) 100 | { 101 | auto formats = hmc_clip_util::EnumClipboardFormatList(); 102 | auto count = formats.size(); 103 | std::wstring formatJson = L"["; 104 | 105 | formatJson.reserve(512); 106 | 107 | for (size_t i = 0; i < count; i++) 108 | { 109 | std::wstring obj = LR"({"type":{type},"type_name":"{type_name}"})"; 110 | auto it = formats.at(i); 111 | auto name = hmc_clip_util::GetClipboardFormatNameW((std::uint8_t)it); 112 | hmc_string_util::replace(obj, L"{type_name}", name); 113 | hmc_string_util::replace(obj, L"{type}", std::to_wstring(it)); 114 | if (i + 1 < count) 115 | { 116 | obj.push_back(L','); 117 | } 118 | formatJson.append(obj); 119 | } 120 | 121 | formatJson.push_back(']'); 122 | return hmc_napi_create_value::String(env, formatJson); 123 | } 124 | 125 | napi_value getClipboardHTML(napi_env env, napi_callback_info info) 126 | { 127 | auto ClipboardHtml = hmc_clip_util::GetClipboardHtml(NULL); 128 | auto HtmlItem = ClipboardHtml.getHtmlItem(); 129 | if (HtmlItem.is_valid) 130 | { 131 | 132 | auto Results = hmc_napi_create_value::jsObject(env); 133 | 134 | Results.putString("data", HtmlItem.data); 135 | Results.putValue("EndFragment", as_Number(HtmlItem.EndFragment)); 136 | Results.putValue("EndHTML", as_Number(HtmlItem.EndHTML)); 137 | Results.putValue("is_valid", as_Boolean(HtmlItem.is_valid)); 138 | Results.putString("SourceURL", HtmlItem.SourceURL); 139 | Results.putValue("StartFragment", as_Number(HtmlItem.StartFragment)); 140 | Results.putValue("StartHTML", as_Number(HtmlItem.StartHTML)); 141 | Results.putValue("Version", as_Numberf(HtmlItem.Version)); 142 | 143 | return Results.toValue(); 144 | } 145 | 146 | return hmc_napi_create_value::Null(env); 147 | } 148 | 149 | std::any GetClipboardFilePaths2(napi_env env, size_t TASK_TYPE, std::vector *data_list) 150 | { 151 | std::vector file_list = hmc_clip_util::GetClipboardPathListW(); 152 | std::wstring temp = hmc_string_util::join(file_list, std::wstring(1, '\0')); 153 | return temp; 154 | } 155 | 156 | std::any GetClipboardText2(napi_env env, size_t TASK_TYPE, std::vector *data_list) 157 | { 158 | std::wstring result = hmc_clip_util::GetClipboardTextW(); 159 | 160 | return result; 161 | } 162 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/export/promise_template.txt: -------------------------------------------------------------------------------- 1 | 2 | namespace HMC_GetShellEnvInfo 3 | { 4 | 5 | enum class GET_SHELL_ENV_INFO_ID 6 | { 7 | NONE = 0, 8 | GET_LINK_TARGET = 1, 9 | }; 10 | 11 | const std::map>> GET_SHELL_EQ_TYPE_LIST = { 12 | {GET_SHELL_ENV_INFO_ID::GET_LINK_TARGET, {{0, js_string}}}, 13 | // {GET_SHELL_ENV_INFO_ID::GET_LINK_TARGET, {{0, js_string}}}, 14 | }; 15 | 16 | struct EnvNextWorkData : public HMC_PromiseUtilV2::EnvNextWorkDataTemplate 17 | { 18 | }; 19 | 20 | void GetLinkTarget(EnvNextWorkData *workData); 21 | 22 | const std::map > GET_SHELL_FUNC_LIST = { 23 | {GET_SHELL_ENV_INFO_ID::GET_LINK_TARGET, GetLinkTarget}, 24 | }; 25 | 26 | bool get_arguments(napi_env env, hmc_NodeArgsValue input, EnvNextWorkData *work) 27 | { 28 | if (!input.eq(0, js_number, true)) 29 | { 30 | return false; 31 | } 32 | 33 | work->TAKE_TYPE = (GET_SHELL_ENV_INFO_ID)at_Number32Or(0, 0); 34 | input.removeIndex(0); 35 | for (auto &&EQ_TYPE : GET_SHELL_EQ_TYPE_LIST) 36 | { 37 | if (EQ_TYPE.first == work->TAKE_TYPE) 38 | { 39 | 40 | auto second = EQ_TYPE.second; 41 | if (!input.eq(second, true)) 42 | { 43 | return false; 44 | } 45 | 46 | break; 47 | } 48 | } 49 | 50 | for (size_t index = 0; index < input.size(); index++) 51 | { 52 | if (input.exists(index)) 53 | { 54 | auto temp = input.get_variant(index); 55 | work->arguments->push_back(temp); 56 | } 57 | } 58 | 59 | return true; 60 | } 61 | 62 | void main(EnvNextWorkData *workData) 63 | { 64 | for (auto &&GET_SHELL_FUNC : GET_SHELL_FUNC_LIST){ 65 | 66 | if (GET_SHELL_FUNC.first == workData->TAKE_TYPE) 67 | { 68 | auto fun = GET_SHELL_FUNC.second; 69 | fun(workData); 70 | return; 71 | } 72 | } 73 | 74 | } 75 | 76 | // async 77 | void ExecuteAsyncWork(napi_env env, void *data) 78 | { 79 | EnvNextWorkData *workData = (EnvNextWorkData *)data; 80 | try 81 | { 82 | main(workData); 83 | } 84 | HMC_CATCH_ALL; 85 | } 86 | 87 | napi_value ExecuteSync(napi_env env, napi_callback_info info) 88 | { 89 | napi_value result = as_Null(); 90 | 91 | try 92 | { 93 | auto input = hmc_NodeArgsValue(env, info); 94 | auto *workData = EnvNextWorkData::make(); 95 | 96 | HMC_FreeAnyAuto(EnvNextWorkData::gc(workData);); 97 | 98 | bool is_eq_args = HMC_PromiseUtilV2::get_argumentsTemplate(env, input, workData, GET_SHELL_EQ_TYPE_LIST); 99 | if (workData == NULL || !is_eq_args) 100 | { 101 | return result; 102 | } 103 | 104 | main(workData); 105 | 106 | result = hmc_napi_create_value::Variant(env, *workData->Result); 107 | return result; 108 | } 109 | HMC_CATCH_ALL; 110 | return hmc_napi_create_value::Error(env, "A fatal error occurred unexpectedly.", __FUNCSIG__, "HMC_SHELL_API_CATCH"); 111 | } 112 | 113 | // 异步任务完成后的回调函数 114 | void ResolveWork(napi_env env, napi_status status, void *data) 115 | { 116 | EnvNextWorkData *workData = (EnvNextWorkData *)data; 117 | HMC_FreeAnyAuto(EnvNextWorkData::gc(workData);); 118 | 119 | napi_value result; 120 | napi_get_null(env, &result); 121 | 122 | if (workData == NULL || workData->Result == NULL || workData->Result->index() == 0) 123 | { 124 | if (workData != NULL) 125 | { 126 | napi_resolve_deferred(env, workData->deferred, result); 127 | napi_delete_async_work(env, workData->work); 128 | } 129 | return; 130 | } 131 | 132 | result = hmc_napi_create_value::Variant(env, *workData->Result); 133 | 134 | if (result == NULL) 135 | { 136 | napi_get_null(env, &result); 137 | } 138 | 139 | napi_resolve_deferred(env, workData->deferred, result); 140 | napi_delete_async_work(env, workData->work); 141 | } 142 | 143 | // 启动异步任务的函数 144 | napi_value StartAsyncTask(napi_env env, napi_callback_info info) 145 | { 146 | napi_value promise; 147 | try 148 | { 149 | napi_value resourceName; 150 | napi_create_string_utf8(env, __FUNCSIG__, NAPI_AUTO_LENGTH, &resourceName); 151 | 152 | auto *workData = EnvNextWorkData::make(); 153 | 154 | auto input = hmc_NodeArgsValue(env, info); 155 | bool is_eq_args = HMC_PromiseUtilV2::get_argumentsTemplate(env, input, workData, GET_SHELL_EQ_TYPE_LIST); 156 | if (workData == NULL || !is_eq_args) 157 | { 158 | EnvNextWorkData::gc(workData); 159 | return as_Null(); 160 | } 161 | 162 | napi_create_promise(env, &workData->deferred, &promise); 163 | napi_create_async_work(env, nullptr, resourceName, ExecuteAsyncWork, ResolveWork, workData, &workData->work); 164 | napi_queue_async_work(env, workData->work); 165 | return promise; 166 | } 167 | HMC_CATCH_ALL; 168 | return hmc_napi_create_value::Error(env, "A fatal error occurred unexpectedly.", __FUNCSIG__, "HMC_SHELL_API_CATCH"); 169 | } 170 | 171 | } -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/export/window.cpp: -------------------------------------------------------------------------------- 1 | #include "export.h" 2 | #include "hmc_windows_util.h" 3 | 4 | std::any CloseWindow2::ExecuteWorkFun(napi_env env, size_t TASK_TYPE, std::vector *arguments_list) 5 | { 6 | std::any result = std::any(); 7 | HWND Handle = (HWND)std::any_cast(arguments_list->at(0)); 8 | int grade = std::any_cast(arguments_list->at(1)); 9 | 10 | result = hmc_windows_util::closeWindow(Handle, grade); 11 | 12 | return result; 13 | } 14 | 15 | bool CloseWindow2::FormatArg(napi_env env, napi_callback_info info, hmc_NodeArgsValue input, std::vector *arguments_list) 16 | { 17 | 18 | if (!input.eq(0, {js_number, js_bigint}, true)) 19 | { 20 | return false; 21 | } 22 | 23 | // hwnd:number 24 | int64_t ihwnd = at_Number64Or(0, 0); 25 | int igrade = at_Number64Or(1, 5); 26 | 27 | arguments_list->push_back(ihwnd); 28 | arguments_list->push_back(igrade); 29 | 30 | return true; 31 | } -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | #include "./main.h" 2 | #include "./export/export.h" 3 | #include 4 | #include "hmc_util.h" 5 | 6 | #include "hmc_automation_util.h" 7 | 8 | static void hmc_gc_func() 9 | { 10 | // 防止鼠标被锁定 11 | if (hmc_mouse::LimitMouseRange::hasLimitMouseRange_worker()) 12 | { 13 | hmc_mouse::LimitMouseRange::stopLimitMouseRange_worker(); 14 | } 15 | 16 | // 释放鼠标监听的线程 17 | if (!hmc_mouse::MouseHook::isValidHookMouse()) 18 | { 19 | hmc_mouse::MouseHook::stopHookMouse(); 20 | } 21 | 22 | // 释放键盘监听的线程 23 | if (!hmc_Keyboard::keyboardHook::isValidHookKeyboard()) 24 | { 25 | hmc_Keyboard::keyboardHook::stopHookKeyboard(); 26 | } 27 | } 28 | 29 | static napi_value Init(napi_env env, napi_value exports) 30 | { 31 | 32 | napi_property_descriptor BIND_NAPI_METHOD[] = { 33 | 34 | // screen.cpp 35 | // DECLARE_NAPI_METHODRM("captureBmpToBuff", captureBmpToBuff), 36 | // DECLARE_NAPI_METHODRM("captureBmpToFile", captureBmpToFile), 37 | 38 | // clip.cpp 39 | DECLARE_NAPI_METHODRM("getClipboardFilePaths", getClipboardFilePaths), 40 | DECLARE_NAPI_METHODRM("setClipboardText", setClipboardText), 41 | DECLARE_NAPI_METHODRM("getClipboardText", getClipboardText), 42 | DECLARE_NAPI_METHODRM("clearClipboard", clearClipboard), 43 | DECLARE_NAPI_METHODRM("setClipboardFilePaths", setClipboardFilePaths), 44 | DECLARE_NAPI_METHODRM("getClipboardInfo", getClipboardInfo), 45 | DECLARE_NAPI_METHODRM("enumClipboardFormats", enumClipboardFormats), 46 | DECLARE_NAPI_METHODRM("getClipboardHTML", getClipboardHTML), 47 | 48 | // shell.cpp 49 | // DECLARE_NAPI_METHODRM("getTrayList", HMC_shell::getTrayList), 50 | // DECLARE_NAPI_METHODRM("trashFile", HMC_shell::trashFile), 51 | // DECLARE_NAPI_METHODRM("clearTrash", HMC_shell::clearTrash), 52 | // DECLARE_NAPI_METHODRM("copyFile", HMC_shell::copyFile), 53 | // DECLARE_NAPI_METHODRM("moveFile", HMC_shell::moveFile), 54 | // DECLARE_NAPI_METHODRM("getThumbnailPng", HMC_shell::getThumbnailPng), 55 | // DECLARE_NAPI_METHODRM("getLinkTarget", HMC_shell::getLinkTarget), 56 | // DECLARE_NAPI_METHODRM("setFolderIcon", HMC_shell::setFolderIcon), 57 | // DECLARE_NAPI_METHODRM("isLinkLink", HMC_shell::isLinkLink), 58 | // DECLARE_NAPI_METHODRM("setShortcutLink", HMC_shell::setShortcutLink), 59 | // DECLARE_NAPI_METHODRM("createFsLink", HMC_shell::createFsLink), 60 | // DECLARE_NAPI_METHODRM("getSystemMetrics", HMC_shell::getSystemMetrics), 61 | // DECLARE_NAPI_METHODRM("getShortcutLink", HMC_shell::getShortcutLink), 62 | // DECLARE_NAPI_METHODRM("showContextMenu", HMC_shell::showContextMenu), 63 | // DECLARE_NAPI_METHODRM("setConversionStatus", HMC_shell::setConversionStatus), 64 | DECLARE_NAPI_METHODRM("HMC_SHELL_CLASS", HMC_shell::StartupClassConstructor), 65 | 66 | DECLARE_NAPI_METHODRM("HMC_SHELL_STARTUP_CLASS", HMC_shell_startup::StartupClassConstructor), 67 | // auto.cpp 68 | DECLARE_NAPI_METHODRM("HMC_KEYBOARD_CLASS", HMC_Keyboard::StartupClassConstructor), 69 | DECLARE_NAPI_METHODRM("HMC_MOUSE_CLASS", HMC_mouse::StartupClassConstructor), 70 | }; 71 | 72 | napi_define_properties(env, exports, sizeof(BIND_NAPI_METHOD) / sizeof(BIND_NAPI_METHOD[0]), BIND_NAPI_METHOD); 73 | 74 | //::.......................................................................................................................................................................... 75 | //:: Promise 高性能要求的 76 | 77 | InitAsyncFunction(env, exports, "getProcessName2", HMC_GetProcessName::StartAsyncTask, HMC_GetProcessName::ExecuteSync); 78 | InitAsyncFunction(env, exports, "getProcessFilePath2", HMC_GetProcessFilePath::StartAsyncTask, HMC_GetProcessFilePath::ExecuteSync); 79 | InitAsyncFunction(env, exports, "getProcessEnvInfo2", HMC_GetProcessEnvInfo::StartAsyncTask, HMC_GetProcessEnvInfo::ExecuteSync); 80 | InitAsyncFunction(env, exports, "GetRegistrEnvInfo", HMC_GetRegistrEnvInfo::StartAsyncTask, HMC_GetRegistrEnvInfo::ExecuteSync); 81 | InitAsyncFunction(env, exports, "HMC_PromiseEval", HMC_PromiseEval::StartAsyncTask, HMC_PromiseEval::ExecuteSync); 82 | InitAsyncFunction(env, exports, "HMC_GetShellEnvInfo", HMC_GetShellEnvInfo::StartAsyncTask, HMC_GetShellEnvInfo::ExecuteSync); 83 | InitAsyncFunction(env, exports, "HMC_GetSockEnvInfo", HMC_GetSockEnvInfo::StartAsyncTask, HMC_GetSockEnvInfo::ExecuteSync); 84 | 85 | //::.......................................................................................................................................................................... 86 | //:: Promise 低调用量 低性能要求的 87 | HMC_PromiseEval::append(PROMISEEVAL_TOKEN::getClipboardFilePaths2, std::nullopt, GetClipboardFilePaths2, std::nullopt); 88 | HMC_PromiseEval::append(PROMISEEVAL_TOKEN::getClipboardText2, std::nullopt, GetClipboardText2, std::nullopt); 89 | HMC_PromiseEval::append(PROMISEEVAL_TOKEN::getTrayList, std::nullopt, GetTrayList, std::nullopt); 90 | 91 | CaptureBmp2::initialize(PROMISEEVAL_TOKEN::captureBmp2); 92 | CloseWindow2::initialize(PROMISEEVAL_TOKEN::closeWindow2); 93 | GetThumbnailPng2::initialize(PROMISEEVAL_TOKEN::getThumbnailPng2); 94 | 95 | 96 | ::atexit(hmc_gc_func); 97 | 98 | return exports; 99 | } 100 | 101 | NAPI_MODULE(NODE_GYP_MODULE_NAME, Init); 102 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // 防止重复导入 4 | #ifndef MODE_INTERNAL_INCLUDE_HMC_MAIN_V2_H 5 | #define MODE_INTERNAL_INCLUDE_HMC_MAIN_V2_H 6 | 7 | #include "hmc_napi_value_util.h" 8 | 9 | namespace PROMISEEVAL_TOKEN 10 | { 11 | enum PROMISEEVAL_API_ID 12 | { 13 | getClipboardFilePaths2 = 1, 14 | captureBmp2 = 2, 15 | closeWindow2 = 3, 16 | getClipboardText2 = 5, 17 | getThumbnailPng2 = 6, 18 | getTrayList = 7, 19 | }; 20 | 21 | } 22 | 23 | // 开启实验性功能 比如异步(多线程) 24 | #define NAPI_EXPERIMENTAL 25 | 26 | // 导出一个其他cpp中的模块 27 | #define DECLARE_NAPI_METHODRM(name, func) \ 28 | { \ 29 | name, 0, (napi_callback) & func, 0, 0, 0, napi_default, 0} 30 | 31 | // 导出一个模块 32 | #define DECLARE_NAPI_METHOD(name, func) \ 33 | { \ 34 | name, 0, func, 0, 0, 0, napi_default, 0} 35 | 36 | // 导出一个js支持的内容 37 | #define ADD_NAPI_METHOD_VALUE(name, value) \ 38 | { \ 39 | name, 0, 0, 0, 0, value, napi_default, 0} 40 | 41 | // 导出一个文本内容 42 | #define ADD_NAPI_METHOD_Str_VALUE(name, value) \ 43 | { \ 44 | name, 0, 0, 0, 0, as_String(value), napi_default, 0} 45 | 46 | #endif // MODE_INTERNAL_INCLUDE_HMC_MAIN_V2_H -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/msvc/binding.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Version 16 3 | VisualStudioVersion = 16.0.33529.622 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hmc_debug", "hmc_debug.vcxproj", "{27499468-D287-1FA6-7D54-C1858A201AA4}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Win32 = Debug|Win32 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | Release|x86 = Release|x86 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {27499468-D287-1FA6-7D54-C1858A201AA4}.Debug|Win32.ActiveCfg = Debug|Win32 18 | {27499468-D287-1FA6-7D54-C1858A201AA4}.Debug|Win32.Build.0 = Debug|Win32 19 | {27499468-D287-1FA6-7D54-C1858A201AA4}.Debug|x64.ActiveCfg = Debug|x64 20 | {27499468-D287-1FA6-7D54-C1858A201AA4}.Debug|x64.Build.0 = Debug|x64 21 | {27499468-D287-1FA6-7D54-C1858A201AA4}.Debug|x86.ActiveCfg = Debug|Win32 22 | {27499468-D287-1FA6-7D54-C1858A201AA4}.Debug|x86.Build.0 = Debug|Win32 23 | {27499468-D287-1FA6-7D54-C1858A201AA4}.Release|Win32.ActiveCfg = Release|Win32 24 | {27499468-D287-1FA6-7D54-C1858A201AA4}.Release|Win32.Build.0 = Release|Win32 25 | {27499468-D287-1FA6-7D54-C1858A201AA4}.Release|x64.ActiveCfg = Release|x64 26 | {27499468-D287-1FA6-7D54-C1858A201AA4}.Release|x64.Build.0 = Release|x64 27 | {27499468-D287-1FA6-7D54-C1858A201AA4}.Release|x86.ActiveCfg = Release|Win32 28 | {27499468-D287-1FA6-7D54-C1858A201AA4}.Release|x86.Build.0 = Release|Win32 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | SolutionGuid = {55087B87-2C97-4DC5-98A6-655D2986CCBE} 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/msvc/cheese.log: -------------------------------------------------------------------------------- 1 | [2023-12-14T16:06:38.035] [INFO] cheese - end; 2 | [2023-12-14T16:07:23.791] [INFO] cheese - end; 3 | [2023-12-14T16:10:03.436] [INFO] cheese - end; 4 | [2023-12-14T16:12:50.574] [INFO] cheese - end; 5 | [2023-12-14T16:17:41.450] [INFO] cheese - end; 6 | [2023-12-14T16:17:49.046] [INFO] cheese - end; 7 | [2023-12-14T16:18:58.875] [INFO] cheese - end; 8 | [2023-12-14T16:20:17.974] [INFO] cheese - end; 9 | [2023-12-14T16:21:25.188] [INFO] cheese - end; 10 | [2023-12-14T16:23:46.044] [INFO] cheese - end; 11 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/msvc/hmc_debug.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-win32@2.0/source/cpp/msvc/hmc_debug.aps -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/msvc/hmc_debug.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-win32@2.0/source/cpp/msvc/hmc_debug.rc -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/msvc/hmc_debug.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {739DB09A-CC57-A953-A6CF-F64FA08E4FA7} 6 | 7 | 8 | {739DB09A-CC57-A953-A6CF-F64FA08E4FA7} 9 | 10 | 11 | {5e7a52e2-980e-4cfc-b84f-bb541665af8b} 12 | 13 | 14 | {778d295e-8f8e-43c4-b509-f21c84f2c404} 15 | 16 | 17 | {7B735499-E5DD-1C2B-6C26-70023832A1CF} 18 | 19 | 20 | {95298037-9ae6-4628-b34e-542c52f045c8} 21 | 22 | 23 | {977160dd-7c4b-4896-920b-0dd12255d256} 24 | 25 | 26 | 27 | 28 | 源代码 29 | 30 | 31 | 源代码\export 32 | 33 | 34 | 源代码\export 35 | 36 | 37 | 源代码\export 38 | 39 | 40 | 源代码\export 41 | 42 | 43 | 源代码\export 44 | 45 | 46 | 源代码\export 47 | 48 | 49 | node-gyp 50 | 51 | 52 | 源代码\export 53 | 54 | 55 | 源代码\export 56 | 57 | 58 | 59 | 60 | 61 | 源代码\export 62 | 63 | 64 | hmc-module-static 65 | 66 | 67 | hmc-module-static 68 | 69 | 70 | hmc-module-static 71 | 72 | 73 | hmc-module-static 74 | 75 | 76 | hmc-module-static 77 | 78 | 79 | hmc-module-static 80 | 81 | 82 | hmc-module-static 83 | 84 | 85 | hmc-module-static 86 | 87 | 88 | hmc-module-static 89 | 90 | 91 | hmc-module-static 92 | 93 | 94 | hmc-module-static 95 | 96 | 97 | hmc-module-static 98 | 99 | 100 | hmc-module-static 101 | 102 | 103 | hmc-module-static 104 | 105 | 106 | hmc-module-static 107 | 108 | 109 | hmc-module-static\node 110 | 111 | 112 | hmc-module-static\node 113 | 114 | 115 | hmc-module-static\node 116 | 117 | 118 | hmc-module-static\node 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | node-gyp 127 | 128 | 129 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/msvc/hmc_debug.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | node_x64.exe 5 | --inspect 6 | WindowsLocalDebugger 7 | false 8 | msvc_dir=$(LocalDebuggerWorkingDirectory) 9 | mode=$(TargetPath) 10 | hmc_debug_js=$(LocalDebuggerWorkingDirectory)/../../../source/debug 11 | hmc_source=$(LocalDebuggerWorkingDirectory)/../../../ 12 | $(LocalDebuggerEnvironment) 13 | 14 | 15 | node_x64.exe 16 | --inspect 17 | WindowsLocalDebugger 18 | msvc_dir=$(LocalDebuggerWorkingDirectory) 19 | mode=$(TargetPath) 20 | hmc_debug_js=$(LocalDebuggerWorkingDirectory)/../../../source/debug 21 | hmc_source=$(LocalDebuggerWorkingDirectory)/../../../ 22 | $(LocalDebuggerEnvironment) 23 | 24 | 25 | --inspect 26 | WindowsLocalDebugger 27 | node_x86.exe 28 | false 29 | msvc_dir=$(LocalDebuggerWorkingDirectory) 30 | mode=$(TargetPath) 31 | hmc_debug_js=$(LocalDebuggerWorkingDirectory)/../../../source/debug 32 | hmc_source=$(LocalDebuggerWorkingDirectory)/../../../ 33 | $(LocalDebuggerEnvironment) 34 | 35 | 36 | --inspect 37 | WindowsLocalDebugger 38 | node_x86.exe 39 | msvc_dir=$(LocalDebuggerWorkingDirectory) 40 | mode=$(TargetPath) 41 | hmc_debug_js=$(LocalDebuggerWorkingDirectory)/../../../source/debug 42 | hmc_source=$(LocalDebuggerWorkingDirectory)/../../../ 43 | $(LocalDebuggerEnvironment) 44 | 45 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/msvc/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-win32@2.0/source/cpp/msvc/resource.h -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/cpp/win_delay_load_hook.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * When this file is linked to a DLL, it sets up a delay-load hook that 3 | * intervenes when the DLL is trying to load the host executable 4 | * dynamically. Instead of trying to locate the .exe file it'll just 5 | * return a handle to the process image. 6 | * 7 | * This allows compiled addons to work when the host executable is renamed. 8 | */ 9 | 10 | #ifdef _MSC_VER 11 | 12 | #pragma managed(push, off) 13 | 14 | #ifndef WIN32_LEAN_AND_MEAN 15 | #define WIN32_LEAN_AND_MEAN 16 | #endif 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | static FARPROC WINAPI load_exe_hook(unsigned int event, DelayLoadInfo* info) { 24 | HMODULE m; 25 | if (event != dliNotePreLoadLibrary) 26 | return NULL; 27 | 28 | if (_stricmp(info->szDll, HOST_BINARY) != 0) 29 | return NULL; 30 | 31 | m = GetModuleHandle(NULL); 32 | return (FARPROC) m; 33 | } 34 | 35 | decltype(__pfnDliNotifyHook2) __pfnDliNotifyHook2 = load_exe_hook; 36 | 37 | #pragma managed(pop) 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/main/Usb.ts: -------------------------------------------------------------------------------- 1 | import { isRegExp } from "util/types"; 2 | import { ref } from "./util"; 3 | import { ShellPromiseEval } from "./ShellPromiseEval"; 4 | import { HMC } from "./HMC"; 5 | 6 | 7 | export namespace Usb { 8 | 9 | export type Volume = HMC.Volume; 10 | 11 | /** 12 | * 格式化 Volume路径 13 | * @example 14 | * - volumeid -> "\\\\?\\Volume{68de5ae6-0000-0000-0000-100000000000}\\123456\\1234" 15 | * - nt -> "\\Device\\HarddiskVolume2" 16 | * @param Path 路径 17 | * @returns 18 | */ 19 | export async function formatVolumePath2(Path: string) { 20 | return (await ShellPromiseEval.formatVolumePath2(ref.string(Path))) || ""; 21 | } 22 | 23 | /** 24 | * 格式化 Volume路径 25 | * @example 26 | * - volumeid -> "\\\\?\\Volume{68de5ae6-0000-0000-0000-100000000000}\\123456\\1234" 27 | * - nt -> "\\Device\\HarddiskVolume2" 28 | * @param Path 路径 29 | * @returns 30 | */ 31 | export function formatVolumePath2Sync(Path: string) { 32 | return (ShellPromiseEval.formatVolumePath2Sync(ref.string(Path))) || ""; 33 | } 34 | 35 | /** 36 | * 格式化 Volume路径 37 | * @example "\\\\?\\Volume{68de5ae6-0000-0000-0000-100000000000}\\123456\\1234" 38 | * @param Path 路径 39 | * @returns 40 | */ 41 | export function formatVolumeName2(Path: string) { 42 | return ShellPromiseEval.formatVolumeName2(Path) 43 | } 44 | 45 | /** 46 | * 格式化 Volume路径 47 | * @example "\\\\?\\Volume{68de5ae6-0000-0000-0000-100000000000}\\123456\\1234" 48 | * @param Path 路径 49 | * @returns 50 | */ 51 | export function formatVolumeName2Sync(Path: string) { 52 | return ShellPromiseEval.formatVolumeName2Sync(Path) 53 | } 54 | 55 | /** 56 | * 格式化 Nt路径 57 | * @example "\\Device\\HarddiskVolume2" 58 | * @param Path 路径 59 | * @returns 60 | */ 61 | export function formatVolumeNtName2(Path: string) { 62 | return ShellPromiseEval.formatVolumeNtName2(Path) 63 | } 64 | 65 | /** 66 | * 格式化 Nt路径 67 | * @example "\\Device\\HarddiskVolume2" 68 | * @param Path 路径 69 | * @returns 70 | */ 71 | export function formatVolumeNtName2Sync(Path: string) { 72 | return ShellPromiseEval.formatVolumeNtName2Sync(Path) 73 | } 74 | 75 | /** 76 | * 枚举指定匹配磁盘的Volume信息 77 | * @param search 匹配信息 正则/文本 如: 78 | * - {68de5ae6-0000-0000-0000-100000000000} 79 | * - D: 80 | * - HarddiskVolume2 81 | */ 82 | export function getVolumeList2(search: string | RegExp): Promise; 83 | /** 84 | * 枚举所有的磁盘的Volume信息 85 | * @returns 86 | */ 87 | export function getVolumeList2(): Promise; 88 | export function getVolumeList2(search?: unknown): unknown { 89 | return new Promise(async (resolve, reject) => { 90 | try { 91 | const VolumeList: Volume[] | null | undefined = await ShellPromiseEval.getVolumeList2(); 92 | if ((typeof search == "string" || isRegExp(search)) && VolumeList) { 93 | for (let index = 0; index < VolumeList.length; index++) { 94 | const element: HMC.Volume = VolumeList[index]; 95 | if (element.path) { 96 | const match = element.path.match(search) || element.device.match(search) || element.name.match(search); 97 | if (match) { 98 | resolve(element); 99 | return; 100 | } 101 | } 102 | } 103 | 104 | resolve(null); 105 | return; 106 | } 107 | 108 | resolve(VolumeList || []); 109 | } catch (error) { 110 | reject(error); 111 | } 112 | }); 113 | } 114 | 115 | /** 116 | * 枚举指定匹配磁盘的Volume信息 117 | * @param search 匹配信息 正则/文本 如: 118 | * - {68de5ae6-0000-0000-0000-100000000000} 119 | * - D: 120 | * - HarddiskVolume2 121 | */ 122 | export function getVolumeList2Sync(search: string | RegExp): Volume | null; 123 | /** 124 | * 枚举所有的磁盘的Volume信息 125 | * @returns 126 | */ 127 | export function getVolumeList2Sync(): Volume[]; 128 | export function getVolumeList2Sync(search?: unknown): unknown { 129 | const VolumeList: Volume[] | null | undefined = ShellPromiseEval.getVolumeList2Sync(); 130 | if ((typeof search == "string" || isRegExp(search)) && VolumeList) { 131 | for (let index = 0; index < VolumeList.length; index++) { 132 | const element: HMC.Volume = VolumeList[index]; 133 | if (element.path) { 134 | const match = element.path.match(search) || element.device.match(search) || element.name.match(search); 135 | if (match) { 136 | return element; 137 | } 138 | } 139 | } 140 | return null; 141 | } 142 | 143 | return VolumeList || []; 144 | } 145 | 146 | } 147 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/main/bin/HMC@Beta_x64.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-win32@2.0/source/main/bin/HMC@Beta_x64.node -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/main/bin/HMC@Beta_x86.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-win32@2.0/source/main/bin/HMC@Beta_x86.node -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/main/bin/HMC@v1.0_x64.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-win32@2.0/source/main/bin/HMC@v1.0_x64.node -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/main/bin/HMC@v1.0_x86.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/hmc-win32@2.0/source/main/bin/HMC@v1.0_x86.node -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/main/clip.ts: -------------------------------------------------------------------------------- 1 | import { ref } from "./util"; 2 | import EvalTask = require("./promiseEval"); 3 | import { HMC } from "./HMC"; 4 | import { Native } from "./Native"; 5 | 6 | export namespace Clipboard { 7 | 8 | 9 | /** 10 | * 获取剪贴板文件路径列表 以\0切割 11 | * @returns 12 | */ 13 | export function getClipboardFilePaths() { 14 | const result: Array = []; 15 | if (!Native.native.getClipboardFilePaths) return result; 16 | 17 | const temp = Native.native.getClipboardFilePaths().split("\0"); 18 | if (temp.length && temp.at(-1) == "") temp.pop(); 19 | 20 | return temp; 21 | } 22 | 23 | /** 24 | * 设置剪贴板本文或者html 25 | * @param text 26 | * @param is_html 27 | * @returns 28 | */ 29 | export function setClipboardText(text: string, is_html?: boolean) { 30 | if (!Native.native.setClipboardText) return false; 31 | return Native.native.setClipboardText(ref.string(text), is_html || false); 32 | } 33 | 34 | /** 35 | * 获取剪贴板文本 36 | * @returns 37 | */ 38 | export function getClipboardText() { 39 | if (!Native.native.getClipboardText) return null; 40 | return Native.native.getClipboardText(); 41 | } 42 | 43 | /** 44 | * 清空剪贴板 45 | * @returns 46 | */ 47 | export function clearClipboard() { 48 | if (!Native.native.clearClipboard) return false; 49 | return Native.native.clearClipboard(); 50 | } 51 | 52 | /** 53 | * 设置文件路径列表 54 | * @param paths 支持以 \0 切割的路径或者单文件路径 或者数组 55 | */ 56 | export function setClipboardFilePaths(paths: string | string[]) { 57 | if (!Native.native.setClipboardFilePaths) return false; 58 | return Native.native.setClipboardFilePaths(Array.isArray(paths) ? ref.stringArray(paths) : ref.string(paths)); 59 | } 60 | 61 | /** 62 | * 获取剪贴板文本 `async` 63 | * @returns 64 | */ 65 | export const getClipboardText2 = EvalTask.promiseEvalTask.getClipboardText2; 66 | 67 | /** 68 | * 获取剪贴板文本 `sync` 69 | */ 70 | export const getClipboardText2Sync = getClipboardText2; 71 | 72 | /** 73 | * 获取剪贴板中的文件列表 `async` 74 | * @returns 75 | */ 76 | export const getClipboardFilePaths2 = EvalTask.promiseEvalTask.getClipboardFilePaths2; 77 | 78 | /** 79 | * 获取剪贴板中的文件列表 `sync` 80 | */ 81 | export const getClipboardFilePaths2Sync = getClipboardFilePaths; 82 | 83 | /** 84 | * 获取剪贴板中的html 85 | * @returns 86 | */ 87 | export function getClipboardHTML(): HMC.CLIP_HTML_INFO | null { 88 | if (!Native.native.getClipboardHTML) return null; 89 | return Native.native.getClipboardHTML(); 90 | } 91 | 92 | /** 93 | * 枚举剪贴板包含的格式 94 | * @returns 95 | */ 96 | export function enumClipboardFormats(): Array<{ "type": string, "type_name": string }> { 97 | if (!Native.native.enumClipboardFormats) return []; 98 | try { 99 | return JSON.parse(Native.native.enumClipboardFormats()); 100 | } catch (error) { } 101 | return []; 102 | } 103 | 104 | /** 105 | * 获取剪贴板内容响应 106 | * @returns 107 | */ 108 | export function getClipboardInfo() { 109 | if (!Native.native.getClipboardInfo) return null; 110 | return Native.native.getClipboardInfo(); 111 | } 112 | 113 | }; -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/main/index.ts: -------------------------------------------------------------------------------- 1 | 2 | import { Native } from "./Native"; 3 | import * as ShellPromiseEvalMain from "./ShellPromiseEval"; 4 | import * as RegistrMain from "./registr"; 5 | import * as ProcessMain from "./Process"; 6 | import * as UtilMain from "./util"; 7 | import * as AutoMain from "./auto"; 8 | import * as ShellMain from "./shell"; 9 | import * as PromiseEval from "./promiseEval"; 10 | import * as SokePromiseEvalMain from "./Sock"; 11 | 12 | export const { ref } = UtilMain; 13 | 14 | // 键鼠/自动化相关 15 | export const Auto = AutoMain; 16 | 17 | // 启动项管理 18 | export const Startup = ShellMain.Shell.Startup; 19 | 20 | // win32 shell(壳) api 功能集 21 | export const Shell = ShellMain.Shell; 22 | 23 | // 进程操作功能集 24 | export const Process = ProcessMain.Process; 25 | export const { Sleep, sleep } = Process; 26 | 27 | //注册表编辑合集 28 | export const Registr = RegistrMain.Registr; 29 | 30 | export namespace Window { 31 | 32 | /** 33 | * 将 electron 句柄内存缓冲区转换为标准 窗口数字句柄 34 | * @param handleBuffer 例如 Electron.BrowserWindow.getFocusedWindow().getNativeWindowHandle() 35 | * @returns 36 | */ 37 | export function readElectronHandle(handleBuffer: any) { 38 | let num = 0; 39 | 40 | // Node.js 10.5.0 以上版本 41 | if (typeof BigInt != 'undefined') { 42 | let handleBigInt = handleBuffer.readBigUInt64LE(); 43 | return (Number(handleBigInt)); 44 | } 45 | else { 46 | if (process.platform == 'win32') { 47 | num = handleBuffer.readUInt32LE(); 48 | } 49 | else if (process.platform == 'darwin') { 50 | num = handleBuffer.readUInt32LE(0) + 2 * 32 * handleBuffer.readUInt32LE(4); 51 | } 52 | else { 53 | num = handleBuffer.readUInt32LE(0) + 2 * 32 * handleBuffer.readUInt32LE(4); 54 | } 55 | 56 | return num; 57 | } 58 | return num; 59 | } 60 | 61 | 62 | } 63 | 64 | // 软硬链接相关 65 | export const Symlink = ShellMain.Shell.Symlink; 66 | 67 | export const Network = SokePromiseEvalMain.Network; 68 | 69 | export const { isAdmin2, isAdmin2Sync, isSystemFor64bit2, isSystemFor64bit2Sync } = Network; 70 | 71 | const HMC_MODE = { 72 | Native, 73 | Auto, 74 | Startup, 75 | Shell, 76 | Process, 77 | Registr, 78 | Window, 79 | Symlink, 80 | Network, 81 | Sleep, 82 | sleep, 83 | isAdmin2, 84 | isAdmin2Sync, 85 | isSystemFor64bit2, 86 | isSystemFor64bit2Sync 87 | }; 88 | 89 | export { Native }; 90 | 91 | export default HMC_MODE; 92 | 93 | process.on('exit', function () { 94 | 95 | }); 96 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "source", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": { 6 | "": { 7 | "dependencies": { 8 | "fs-extra": "^11.2.0", 9 | "hmc-shake": "^1.0.2", 10 | "jsonfm": "^1.0.2", 11 | "log4js": "^6.9.1" 12 | }, 13 | "devDependencies": { 14 | "@types/fs-extra": "^11.0.4", 15 | "@types/node": "^16.18.66" 16 | } 17 | }, 18 | "node_modules/@types/fs-extra": { 19 | "version": "11.0.4", 20 | "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.4.tgz", 21 | "integrity": "sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==", 22 | "dev": true, 23 | "dependencies": { 24 | "@types/jsonfile": "*", 25 | "@types/node": "*" 26 | } 27 | }, 28 | "node_modules/@types/jsonfile": { 29 | "version": "6.1.4", 30 | "resolved": "https://registry.npmjs.org/@types/jsonfile/-/jsonfile-6.1.4.tgz", 31 | "integrity": "sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==", 32 | "dev": true, 33 | "dependencies": { 34 | "@types/node": "*" 35 | } 36 | }, 37 | "node_modules/@types/node": { 38 | "version": "16.18.68", 39 | "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.68.tgz", 40 | "integrity": "sha512-sG3hPIQwJLoewrN7cr0dwEy+yF5nD4D/4FxtQpFciRD/xwUzgD+G05uxZHv5mhfXo4F9Jkp13jjn0CC2q325sg==", 41 | "dev": true 42 | }, 43 | "node_modules/date-format": { 44 | "version": "4.0.14", 45 | "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz", 46 | "integrity": "sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg==", 47 | "engines": { 48 | "node": ">=4.0" 49 | } 50 | }, 51 | "node_modules/debug": { 52 | "version": "4.3.4", 53 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 54 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 55 | "dependencies": { 56 | "ms": "2.1.2" 57 | }, 58 | "engines": { 59 | "node": ">=6.0" 60 | }, 61 | "peerDependenciesMeta": { 62 | "supports-color": { 63 | "optional": true 64 | } 65 | } 66 | }, 67 | "node_modules/flatted": { 68 | "version": "3.2.9", 69 | "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.9.tgz", 70 | "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==" 71 | }, 72 | "node_modules/fs-extra": { 73 | "version": "11.2.0", 74 | "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", 75 | "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", 76 | "dependencies": { 77 | "graceful-fs": "^4.2.0", 78 | "jsonfile": "^6.0.1", 79 | "universalify": "^2.0.0" 80 | }, 81 | "engines": { 82 | "node": ">=14.14" 83 | } 84 | }, 85 | "node_modules/graceful-fs": { 86 | "version": "4.2.11", 87 | "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", 88 | "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" 89 | }, 90 | "node_modules/hmc-shake": { 91 | "version": "1.0.2", 92 | "resolved": "https://registry.npmjs.org/hmc-shake/-/hmc-shake-1.0.2.tgz", 93 | "integrity": "sha512-Xz/HeFcI+/zd1cYXGmOn9XfZYz9UgLM5R7GPgiBNIH1i3n/aLyiWAFNtphQmVUqxoangncTmCyfpHfB+EoauxQ==" 94 | }, 95 | "node_modules/jsonfile": { 96 | "version": "6.1.0", 97 | "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", 98 | "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", 99 | "dependencies": { 100 | "universalify": "^2.0.0" 101 | }, 102 | "optionalDependencies": { 103 | "graceful-fs": "^4.1.6" 104 | } 105 | }, 106 | "node_modules/jsonfm": { 107 | "version": "1.0.2", 108 | "resolved": "https://registry.npmjs.org/jsonfm/-/jsonfm-1.0.2.tgz", 109 | "integrity": "sha512-T8rA9AzkiMN7yScv9DP4pAk9y8dWri738/W2djEO9ICForPqrTNKoCuhMslrhj02bQgY+qzoOei0qy29l4qzVA==" 110 | }, 111 | "node_modules/log4js": { 112 | "version": "6.9.1", 113 | "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.9.1.tgz", 114 | "integrity": "sha512-1somDdy9sChrr9/f4UlzhdaGfDR2c/SaD2a4T7qEkG4jTS57/B3qmnjLYePwQ8cqWnUHZI0iAKxMBpCZICiZ2g==", 115 | "dependencies": { 116 | "date-format": "^4.0.14", 117 | "debug": "^4.3.4", 118 | "flatted": "^3.2.7", 119 | "rfdc": "^1.3.0", 120 | "streamroller": "^3.1.5" 121 | }, 122 | "engines": { 123 | "node": ">=8.0" 124 | } 125 | }, 126 | "node_modules/ms": { 127 | "version": "2.1.2", 128 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 129 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 130 | }, 131 | "node_modules/rfdc": { 132 | "version": "1.3.0", 133 | "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", 134 | "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==" 135 | }, 136 | "node_modules/streamroller": { 137 | "version": "3.1.5", 138 | "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.1.5.tgz", 139 | "integrity": "sha512-KFxaM7XT+irxvdqSP1LGLgNWbYN7ay5owZ3r/8t77p+EtSUAfUgtl7be3xtqtOmGUl9K9YPO2ca8133RlTjvKw==", 140 | "dependencies": { 141 | "date-format": "^4.0.14", 142 | "debug": "^4.3.4", 143 | "fs-extra": "^8.1.0" 144 | }, 145 | "engines": { 146 | "node": ">=8.0" 147 | } 148 | }, 149 | "node_modules/streamroller/node_modules/fs-extra": { 150 | "version": "8.1.0", 151 | "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", 152 | "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", 153 | "dependencies": { 154 | "graceful-fs": "^4.2.0", 155 | "jsonfile": "^4.0.0", 156 | "universalify": "^0.1.0" 157 | }, 158 | "engines": { 159 | "node": ">=6 <7 || >=8" 160 | } 161 | }, 162 | "node_modules/streamroller/node_modules/jsonfile": { 163 | "version": "4.0.0", 164 | "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", 165 | "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", 166 | "optionalDependencies": { 167 | "graceful-fs": "^4.1.6" 168 | } 169 | }, 170 | "node_modules/streamroller/node_modules/universalify": { 171 | "version": "0.1.2", 172 | "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", 173 | "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", 174 | "engines": { 175 | "node": ">= 4.0.0" 176 | } 177 | }, 178 | "node_modules/universalify": { 179 | "version": "2.0.1", 180 | "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", 181 | "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", 182 | "engines": { 183 | "node": ">= 10.0.0" 184 | } 185 | } 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "@types/fs-extra": "^11.0.4", 4 | "@types/node": "^16.18.66" 5 | }, 6 | "dependencies": { 7 | "fs-extra": "^11.2.0", 8 | "hmc-shake": "^1.0.2", 9 | "jsonfm": "^1.0.2", 10 | "log4js": "^6.9.1" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/source/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "skipLibCheck": true, 4 | /* Basic Options */ 5 | // "moduleResolution": "node", 6 | // "importHelpers": true, 7 | // "skipLibCheck": true, 8 | // "resolveJsonModule": true, 9 | // "noImplicitAny": false, 10 | "target": "ES2017" /* target用于指定编译之后的版本目标: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, 11 | "module": "commonjs" /* 用来指定要使用的模块标准: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, 12 | // "lib": [ "ES2021"] /* lib用于指定要包含在编译中的库文件 */, 13 | // "allowJs": true, /* allowJs设置的值为true或false,用来指定是否允许编译js文件,默认是false,即不编译js文件 */ 14 | // "checkJs": true, /* checkJs的值为true或false,用来指定是否检查和报告js文件中的错误,默认是false */ 15 | // "jsx": "preserve", /* 指定jsx代码用于的开发环境: 'preserve', 'react-native', or 'react'. */ 16 | // "declaration": true, /* declaration的值为true或false,用来指定是否在编译的时候生成相应的".d.ts"声明文件。如果设为true,编译每个ts文件之后会生成一个js文件和一个声明文件。但是declaration和allowJs不能同时设为true */ 17 | // "declarationMap": true, /* 值为true或false,指定是否为声明文件.d.ts生成map文件 */ 18 | "sourceMap": false /* sourceMap的值为true或false,用来指定编译时是否生成.map文件 */, 19 | // "outFile": "./", /* outFile用于指定将输出文件合并为一个文件,它的值为一个文件路径名。比如设置为"./dist/main.js",则输出的文件为一个main.js文件。但是要注意,只有设置module的值为amd和system模块时才支持这个配置 */ 20 | // "outDir": "", 21 | /* outDir用来指定输出文件夹,值为一个文件夹路径字符串,输出的文件都将放置在这个文件夹 */ 22 | // "rootDir": "./", /* 用来指定编译文件的根目录,编译器会在根目录查找入口文件,如果编译器发现以rootDir的值作为根目录查找入口文件并不会把所有文件加载进去的话会报错,但是不会停止编译 */ 23 | // "composite": true, /* 是否编译构建引用项目 */ 24 | // "incremental": true, /* 是否启用增量编译*/ 25 | //"tsBuildInfoFile": "./builds/Tsc-BuildInfoFile" /* 指定文件用来存储增量编译信息 */, 26 | "removeComments": false /* removeComments的值为true或false,用于指定是否将编译后的文件中的注释删掉,设为true的话即删掉注释,默认为false */, 27 | // "noEmit": true, /* 不生成编译文件,这个一般比较少用 */ 28 | // "importHelpers": true, /* importHelpers的值为true或false,指定是否引入tslib里的辅助工具函数,默认为false */ 29 | // "downlevelIteration": true, /* 当target为'ES5' or 'ES3'时,为'for-of', spread, and destructuring'中的迭代器提供完全支持 */ 30 | // "isolatedModules": true, /* isolatedModules的值为true或false,指定是否将每个文件作为单独的模块,默认为true,它不可以和declaration同时设定 */ 31 | 32 | // /* Strict Type-Checking Options */ 33 | "strict": true, 34 | /* strict的值为true或false,用于指定是否启动所有类型检查,如果设为true则会同时开启下面这几个严格类型检查,默认为false */ 35 | // "noImplicitAny": false, /* noImplicitAny的值为true或false,如果我们没有为一些值设置明确的类型,编译器会默认认为这个值为any,如果noImplicitAny的值为true的话。则没有明确的类型会报错。默认值为false */ 36 | // "strictNullChecks": true, /* strictNullChecks为true时,null和undefined值不能赋给非这两种类型的值,别的类型也不能赋给他们,除了any类型。还有个例外就是undefined可以赋值给void类型 */ 37 | // "strictFunctionTypes": true, /* strictFunctionTypes的值为true或false,用于指定是否使用函数参数双向协变检查 */ 38 | // "strictBindCallApply": true, /* 设为true后会对bind、call和apply绑定的方法的参数的检测是严格检测的 */ 39 | // "strictPropertyInitialization": true, /* 设为true后会检查类的非undefined属性是否已经在构造函数里初始化,如果要开启这项,需要同时开启strictNullChecks,默认为false */ 40 | // "noImplicitThis": true, /* 当this表达式的值为any类型的时候,生成一个错误 */ 41 | // "alwaysStrict": true, /* alwaysStrict的值为true或false,指定始终以严格模式检查每个模块,并且在编译之后的js文件中加入"use strict"字符串,用来告诉浏览器该js为严格模式 */ 42 | 43 | // /* Additional Checks */ 44 | // "noUnusedLocals": true, /* 用于检查是否有定义了但是没有使用的变量,对于这一点的检测,使用eslint可以在你书写代码的时候做提示,你可以配合使用。它的默认值为false */ 45 | // "noUnusedParameters": true, /* 用于检查是否有在函数体中没有使用的参数,这个也可以配合eslint来做检查,默认为false */ 46 | // "noImplicitReturns": true, /* 用于检查函数是否有返回值,设为true后,如果函数没有返回值则会提示,默认为false */ 47 | "noFallthroughCasesInSwitch": true /* 用于检查switch中是否有case没有使用break跳出switch,默认为false */, 48 | 49 | // /* Module Resolution Options */ 50 | // "moduleResolution": "node", /* 用于选择模块解析策略,有'node'和'classic'两种类型' */ 51 | // "baseUrl": "./", /* baseUrl用于设置解析非相对模块名称的基本目录,相对模块不会受baseUrl的影响 */ 52 | // "paths": {}, 53 | /* 用于设置模块名称到基于baseUrl的路径映射 */ 54 | // "rootDirs": [], 55 | /* rootDirs可以指定一个路径列表,在构建时编译器会将这个路径列表中的路径的内容都放到一个文件夹中 */ 56 | "typeRoots": ["./node_modules/@types", "@types"], 57 | /* typeRoots用来指定声明文件或文件夹的路径列表,如果指定了此项,则只有在这里列出的声明文件才会被加载 */ 58 | // "types": [], /* types用来指定需要包含的模块,只有在这里列出的模块的声明文件才会被加载进来 */ 59 | "allowSyntheticDefaultImports": true, 60 | /* 用来指定允许从没有默认导出的模块中默认导入 */ 61 | "esModuleInterop": true /* 通过为导入内容创建命名空间,实现CommonJS和ES模块之间的互操作性 */, 62 | "preserveSymlinks": true /* 不把符号链接解析为其真实路径,具体可以了解下webpack和nodejs的symlink相关知识 */, 63 | // /* Source Map Options */ 64 | // "sourceRoot": "", /* sourceRoot用于指定调试器应该找到TypeScript文件而不是源文件位置,这个值会被写进.map文件里 */ 65 | // "mapRoot": "", /* mapRoot用于指定调试器找到映射文件而非生成文件的位置,指定map文件的根路径,该选项会影响.map文件中的sources属性 */ 66 | "inlineSourceMap": false /* 指定是否将map文件的内容和js文件编译在同一个js文件中,如果设为true,则map的内容会以//# sourceMappingURL=然后拼接base64字符串的形式插入在js文件底部 */, 67 | "inlineSources": false /* 用于指定是否进一步将.ts文件的内容也包含到输入文件中 */ 68 | 69 | // /* Experimental Options */ 70 | // "experimentalDecorators": true, /* 用于指定是否启用实验性的装饰器特性 */ 71 | // "emitDecoratorMetadata": true, /* 用于指定是否为装饰器提供元数据支持,关于元数据,也是ES6的新标准,可以通过Reflect提供的静态方法获取元数据,如果需要使用Reflect的一些方法,需要引入ES2015.Reflect这个库 */ 72 | }, 73 | // "files": [], // files可以配置一个数组列表,里面包含指定文件的相对或绝对路径,编译器在编译的时候只会编译包含在files中列出的文件,如果不指定,则取决于有没有设置include选项,如果没有include选项,则默认会编译根目录以及所有子目录中的文件。这里列出的路径必须是指定文件,而不是某个文件夹,而且不能使用* ? **/ 等通配符 74 | "include": ["./"], // include也可以指定要编译的路径列表,但是和files的区别在于,这里的路径可以是文件夹,也可以是文件,可以使用相对和绝对路径,而且可以使用通配符,比如"./src"即表示要编译src文件夹下的所有文件以及子文件夹的文件 75 | "exclude": ["*node_modules/*"] // exclude表示要排除的、不编译的文件,它也可以指定一个列表,规则和include一样,可以是文件或文件夹,可以是相对路径或绝对路径,可以使用通配符 76 | // "extends": "", // extends可以通过指定一个其他的tsconfig.json文件路径,来继承这个配置文件里的配置,继承来的文件的配置会覆盖当前文件定义的配置。TS在3.2版本开始,支持继承一个来自Node.js包的tsconfig.json配置文件 77 | // "compileOnSave": true, // compileOnSave的值是true或false,如果设为true,在我们编辑了项目中的文件保存的时候,编辑器会根据tsconfig.json中的配置重新生成文件,不过这个要编辑器支持 78 | // "references": [], // 一个对象数组,指定要引用的项目 79 | } 80 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/type/ShellPromiseEval.d.ts: -------------------------------------------------------------------------------- 1 | import main = require("./index"); 2 | export declare enum HMC_PROMISEEVAL_TASK_TYPE { 3 | getLinkTarget2 = 1, 4 | getFileAttributes2 = 2, 5 | getVolumeList2 = 3, 6 | formatVolumePath2 = 5, 7 | formatVolumeName2 = 6, 8 | formatVolumeNtName2 = 7, 9 | getLinkPath2 = 8, 10 | hasFileSymbolicLink2 = 9, 11 | hasFileHardLink2 = 10, 12 | hasDirSymbolicLink2 = 12, 13 | hasDirJunctionPoint2 = 13, 14 | getLinkType2 = 15, 15 | createLink = 16, 16 | createDirJunctionPoint2 = 17, 17 | createHardLink2 = 18, 18 | createSymlink2 = 19, 19 | createDirSymlink2 = 20, 20 | setFolderIcon2 = 21, 21 | setExtensionIcon2 = 22, 22 | setAppURLProtocol2 = 23, 23 | getShortcutLink2 = 25, 24 | trashFile2 = 26, 25 | clearTrash2 = 27, 26 | copyFile2 = 28, 27 | moveFile2 = 29, 28 | setShortcutLink2 = 30 29 | } 30 | export type HMC_PROMISEEVAL_TASK_TYPE_ALL_NAME = keyof typeof HMC_PROMISEEVAL_TASK_TYPE; 31 | export type LINK_TYPE = main.HMC2_MODE.LINK_TYPE; 32 | declare class HMC_PromiseeEvalTask { 33 | async: Partial Promise>>; 34 | sync: Partial any>>; 35 | constructor(); 36 | getLinkTarget2(targetPath: string): Promise; 37 | getLinkTarget2Sync(targetPath: string): main.HMC2_MODE.LINK_TARGET | null; 38 | getFileAttributes2(targetPath: string): Promise; 39 | getFileAttributes2Sync(targetPath: string): null | main.HMC2_MODE.FileAttributesStat; 40 | getVolumeList2(): Promise; 41 | getVolumeList2Sync(): null | main.HMC2_MODE.Volume[]; 42 | } 43 | interface HMC_PromiseeEvalTask { 44 | formatVolumePath2(Path2: string): Promise; 45 | formatVolumePath2Sync(Path2: string): null | string; 46 | formatVolumeName2(Path2: string): Promise; 47 | formatVolumeName2Sync(Path2: string): null | string; 48 | formatVolumeNtName2(Path2: string): Promise; 49 | formatVolumeNtName2Sync(Path2: string): null | string; 50 | getLinkType2(targetPath: string): Promise; 51 | getLinkType2Sync(targetPath: string): main.HMC2_MODE.LINK_TYPE_EQ | null; 52 | /** 53 | * 获取 软链接/ 硬链接 指向的路径 54 | * @param targetPath 55 | */ 56 | getLinkPath2(targetPath: string): Promise; 57 | /** 58 | * 获取 软链接/ 硬链接 指向的路径 59 | * @param targetPath 60 | */ 61 | getLinkPath2Sync(targetPath: string): string | string[] | null; 62 | /** 63 | * 判断是否是符号链接 64 | * @example 适用 -> [文件]符号连接 65 | * @example 适用 -> [文件夹]符号连接 66 | * @example 适用 -> [文件夹]文件夹符号链接 67 | * @param targetPath 68 | */ 69 | hasFileSymbolicLink2(targetPath: string): Promise; 70 | /** 71 | * 判断是否是符号链接 72 | * @example 适用 -> [文件]符号连接 73 | * @example 适用 -> [文件夹]符号连接 74 | * @example 适用 -> [文件夹]文件夹符号链接 75 | * @param targetPath 76 | */ 77 | hasFileSymbolicLink2Sync(targetPath: string): boolean; 78 | /** 79 | * 判断是否是硬链接 80 | * @example 仅适用 -> [文件]硬链接 81 | * @param targetPath 82 | */ 83 | hasFileHardLink2(targetPath: string): Promise; 84 | /** 85 | * 判断是否是硬链接 86 | * @example 仅适用 -> [文件]硬链接 87 | * @param targetPath 88 | */ 89 | hasFileHardLink2Sync(targetPath: string): boolean; 90 | /** 91 | * 判断是否是文件夹符号链接 92 | * @example 适用 -> [文件夹]符号连接 93 | * @param targetPath 94 | */ 95 | hasDirSymbolicLink2(targetPath: string): Promise; 96 | /** 97 | * 判断是否是文件夹符号链接 98 | * @example 适用 -> [文件夹]符号连接 99 | * @param targetPath 100 | */ 101 | hasDirSymbolicLink2Sync(targetPath: string): boolean; 102 | /** 103 | * 判断是否是 文件夹链接连接点 104 | * @example 仅适用 -> [文件夹]文件夹连接点 105 | * @param targetPath 106 | */ 107 | hasDirJunctionPoint2(targetPath: string): Promise; 108 | /** 109 | * 判断是否是 文件夹链接连接点 110 | * @example 仅适用 -> [文件夹]文件夹连接点 111 | * @param targetPath 112 | */ 113 | hasDirJunctionPoint2Sync(targetPath: string): boolean; 114 | createLink(targetType: main.HMC2_MODE.FS_MK_LINK_TARGET_TYPE, targetPath: string, sourcePath: string): Promise; 115 | createLinkSync(targetType: main.HMC2_MODE.FS_MK_LINK_TARGET_TYPE, targetPath: string, sourcePath: string): boolean; 116 | createDirJunctionPoint2(targetPath: string, sourcePath: string): Promise; 117 | createDirJunctionPoint2Sync(targetPath: string, sourcePath: string): boolean; 118 | createHardLink2(targetPath: string, sourcePath: string): Promise; 119 | createHardLink2Sync(targetPath: string, sourcePath: string): boolean; 120 | createSymlink2(targetPath: string, sourcePath: string): Promise; 121 | createSymlink2Sync(targetPath: string, sourcePath: string): boolean; 122 | createDirSymlink2(targetPath: string, sourcePath: string): Promise; 123 | createDirSymlink2Sync(targetPath: string, sourcePath: string): boolean; 124 | setFolderIcon2(targetPath: string, iconPath: string, iconIndex: number): Promise; 125 | setFolderIcon2Sync(targetPath: string, iconPath: string, iconIndex: number): boolean; 126 | setExtensionIcon2(extensionName: string, typeName: string, iconPath: string, iconIndex: number): Promise; 127 | setExtensionIcon2Sync(extensionName: string, typeName: string, iconPath: string, iconIndex: number): boolean; 128 | setAppURLProtocol2(protocolName: string, appPath: string, command: string): Promise; 129 | setAppURLProtocol2Sync(protocolName: string, appPath: string, command: string): boolean; 130 | getShortcutLink2(targetPath: string, QueryDetaile?: boolean): Promise; 131 | getShortcutLink2Sync(targetPath: string, QueryDetaile?: boolean): main.HMC2_MODE.SHORTCUT_LINK | null; 132 | setShortcutLink2(targetPath: string, FilePath: string, work_dir: string, desc: string, args: string, iShowCmd: number, icon: string, iconIndex: number): Promise; 133 | trashFile2(trash_path: string, is_Recycle: boolean, isShow: boolean): Promise; 134 | clearTrash2(root_path: string, isShow: boolean): Promise; 135 | copyFile2(filePath: string, newFilePath: string, isShowConfirm: boolean, isShow: boolean, isShowProgress: boolean): Promise; 136 | moveFile2(filePath: string, newFilePath: string, isShowConfirm: boolean, isShow: boolean, isShowProgress: boolean): Promise; 137 | setShortcutLink2Sync(targetPath: string, FilePath: string, work_dir: string, desc: string, args: string, iShowCmd: number, icon: string, iconIndex: number): boolean; 138 | trashFile2Sync(trash_path: string, is_Recycle: boolean, isShow: boolean): boolean; 139 | clearTrash2Sync(root_path: string, isShow: boolean): boolean; 140 | copyFile2Sync(filePath: string, newFilePath: string, isShowConfirm: boolean, isShow: boolean, isShowProgress: boolean): boolean; 141 | moveFile2Sync(filePath: string, newFilePath: string, isShowConfirm: boolean, isShow: boolean, isShowProgress: boolean): boolean; 142 | } 143 | export declare const ShellPromiseEval: HMC_PromiseeEvalTask; 144 | export {}; 145 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/type/Usb.d.ts: -------------------------------------------------------------------------------- 1 | import main = require("./index"); 2 | export declare namespace Usb { 3 | type Volume = main.HMC2_MODE.Volume; 4 | /** 5 | * 格式化 Volume路径 6 | * @example 7 | * - volumeid -> "\\\\?\\Volume{68de5ae6-0000-0000-0000-100000000000}\\123456\\1234" 8 | * - nt -> "\\Device\\HarddiskVolume2" 9 | * @param Path 路径 10 | * @returns 11 | */ 12 | function formatVolumePath2(Path: string): Promise; 13 | /** 14 | * 格式化 Volume路径 15 | * @example 16 | * - volumeid -> "\\\\?\\Volume{68de5ae6-0000-0000-0000-100000000000}\\123456\\1234" 17 | * - nt -> "\\Device\\HarddiskVolume2" 18 | * @param Path 路径 19 | * @returns 20 | */ 21 | function formatVolumePath2Sync(Path: string): string; 22 | /** 23 | * 格式化 Volume路径 24 | * @example "\\\\?\\Volume{68de5ae6-0000-0000-0000-100000000000}\\123456\\1234" 25 | * @param Path 路径 26 | * @returns 27 | */ 28 | function formatVolumeName2(Path: string): Promise; 29 | /** 30 | * 格式化 Volume路径 31 | * @example "\\\\?\\Volume{68de5ae6-0000-0000-0000-100000000000}\\123456\\1234" 32 | * @param Path 路径 33 | * @returns 34 | */ 35 | function formatVolumeName2Sync(Path: string): string | null; 36 | /** 37 | * 格式化 Nt路径 38 | * @example "\\Device\\HarddiskVolume2" 39 | * @param Path 路径 40 | * @returns 41 | */ 42 | function formatVolumeNtName2(Path: string): Promise; 43 | /** 44 | * 格式化 Nt路径 45 | * @example "\\Device\\HarddiskVolume2" 46 | * @param Path 路径 47 | * @returns 48 | */ 49 | function formatVolumeNtName2Sync(Path: string): string | null; 50 | /** 51 | * 枚举指定匹配磁盘的Volume信息 52 | * @param search 匹配信息 正则/文本 如: 53 | * - {68de5ae6-0000-0000-0000-100000000000} 54 | * - D: 55 | * - HarddiskVolume2 56 | */ 57 | function getVolumeList2(search: string | RegExp): Promise; 58 | /** 59 | * 枚举所有的磁盘的Volume信息 60 | * @returns 61 | */ 62 | function getVolumeList2(): Promise; 63 | /** 64 | * 枚举指定匹配磁盘的Volume信息 65 | * @param search 匹配信息 正则/文本 如: 66 | * - {68de5ae6-0000-0000-0000-100000000000} 67 | * - D: 68 | * - HarddiskVolume2 69 | */ 70 | function getVolumeList2Sync(search: string | RegExp): Volume | null; 71 | /** 72 | * 枚举所有的磁盘的Volume信息 73 | * @returns 74 | */ 75 | function getVolumeList2Sync(): Volume[]; 76 | } 77 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/type/auto.d.ts: -------------------------------------------------------------------------------- 1 | import main = require("./index"); 2 | /** 3 | * 限制鼠标光标可移动范围 (异步) 4 | * @description 可以调用 stop 提前结束 5 | * ?最高不允许超过30000ms (30秒) 最低不允许低于31ms 6 | * ?范围为正方形 如果没有设置right与bottom的值则将限制为1x1的正方形 (不可动) 7 | * @param ms 本次限制的时间 8 | * @param x 限制左边初始化点的位置 9 | * @param y 限制顶部初始化点的位置 10 | * @param right 允许的范围(左边到右边部) 11 | * @param bottom 允许光标移动的范围(顶到底部) 12 | */ 13 | export declare function setLimitMouseRange(ms: number, x: number, y: number, right?: number, bottom?: number): { 14 | ms: number; 15 | x: number; 16 | y: number; 17 | right: number; 18 | bottom: number; 19 | closed: boolean; 20 | /** 21 | * 停止本次 22 | * @returns 23 | */ 24 | close(): boolean; 25 | stop(): boolean; 26 | /** 27 | * 是否正在执行中 28 | * @returns 29 | */ 30 | has(): boolean; 31 | }; 32 | declare class Iohook_Keyboard { 33 | private _onlistenerCountList; 34 | private _oncelistenerCountList; 35 | private _Close; 36 | private _next_Sleep; 37 | private _hook_Task_id; 38 | constructor(); 39 | once(eventName: "start" | "close", listener: () => void): this; 40 | once(eventName: "data", listener: (data: (`${number}|0` | `${number}|1`)[]) => void): this; 41 | once(eventName: "change", listener: (KeyboardPoint: main.HMC2_MODE.KeyboardEvent) => void): this; 42 | once(listener: (KeyboardPoint: main.HMC2_MODE.KeyboardEvent) => void): this; 43 | on(eventName: "start" | "close", listener: () => void): this; 44 | on(eventName: "data", listener: (data: main.HMC2_MODE.KeyboardEvent[]) => void): this; 45 | on(eventName: "change", listener: (KeyboardPoint: main.HMC2_MODE.KeyboardEvent) => void): this; 46 | on(listener: (KeyboardPoint: main.HMC2_MODE.KeyboardEvent) => void): this; 47 | /** 48 | * 设置于hmc 对接的刷新延迟毫秒数 数字越小读取越快但是性能消耗将会增加 49 | * @param Sleep 要求 10ms - 10,000 50 | * @default 50ms 51 | * @returns 52 | */ 53 | setRefreshRate(Sleep?: number): boolean; 54 | /** 55 | * 开始 56 | * @returns 57 | */ 58 | start(): boolean; 59 | /** 60 | * 挂起 并且不销毁已经绑定的函数 以及当前配置 61 | */ 62 | suspend(): boolean; 63 | /** 64 | * 解除suspend的挂起状态 65 | */ 66 | next(): boolean; 67 | /** 68 | * 判断当前的hook是否有效 有效返回线程id 69 | * @returns 70 | */ 71 | isValidHook(): false | number; 72 | /** 73 | * 结束 74 | */ 75 | close(): void; 76 | emit(eventName: "data", data: (main.HMC2_MODE.KeyboardEvent)[]): boolean; 77 | emit(eventName: "start" | "close"): boolean; 78 | emit(eventName: "change", KeyboardPoint: main.HMC2_MODE.KeyboardEvent): boolean; 79 | /** 80 | * 关闭监听 81 | * @param eventName 82 | * @param data 83 | * @returns 84 | */ 85 | off(eventName: "start" | "close" | "change" | "data", treatmentMode: "on" | "once" | Function, data?: Function): boolean; 86 | } 87 | /** 88 | * 设置一个键盘低级变化监听 89 | * @example ```javascript 90 | // 添加处理函数 91 | hmc.Auto.keyboardHook.on("change",function(env){ 92 | console.log(env.key,env.isDown,env); 93 | }); 94 | // log => ctrl , true {...env} 95 | 96 | // 启动 97 | hmc.Auto.keyboardHook.start(); 98 | 99 | // 暂停 / 开始 100 | hmc.Auto.keyboardHook.suspend()&&console.log("hook -> stop"); 101 | 102 | hmc.Sleep(5000).then(()=>hmc.Auto.keyboardHook.next()&&console.log("hook -> next")); 103 | 104 | // close 105 | hmc.Sleep(15000).then(hmc.Auto.keyboardHook.close); 106 | 107 | * ``` 108 | * 109 | */ 110 | export declare const keyboardHook: Iohook_Keyboard; 111 | export {}; 112 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/type/clip.d.ts: -------------------------------------------------------------------------------- 1 | import main = require("./index"); 2 | export declare module Clipboard { 3 | /** 4 | * 获取剪贴板文件路径列表 以\0切割 5 | * @returns 6 | */ 7 | function getClipboardFilePaths(): string[]; 8 | /** 9 | * 设置剪贴板本文或者html 10 | * @param text 11 | * @param is_html 12 | * @returns 13 | */ 14 | function setClipboardText(text: string, is_html?: boolean): boolean; 15 | /** 16 | * 获取剪贴板文本 17 | * @returns 18 | */ 19 | function getClipboardText(): string | null; 20 | /** 21 | * 清空剪贴板 22 | * @returns 23 | */ 24 | function clearClipboard(): boolean; 25 | /** 26 | * 设置文件路径列表 27 | * @param paths 支持以 \0 切割的路径或者单文件路径 或者数组 28 | */ 29 | function setClipboardFilePaths(paths: string | string[]): boolean; 30 | /** 31 | * 获取剪贴板文本 `async` 32 | * @returns 33 | */ 34 | const getClipboardText2: () => Promise; 35 | /** 36 | * 获取剪贴板文本 `sync` 37 | */ 38 | const getClipboardText2Sync: () => Promise; 39 | /** 40 | * 获取剪贴板中的文件列表 `async` 41 | * @returns 42 | */ 43 | const getClipboardFilePaths2: { 44 | (): Promise; 45 | (): Promise; 46 | }; 47 | /** 48 | * 获取剪贴板中的文件列表 `sync` 49 | */ 50 | const getClipboardFilePaths2Sync: typeof getClipboardFilePaths; 51 | /** 52 | * 获取剪贴板中的html 53 | * @returns 54 | */ 55 | function getClipboardHTML(): main.HMC2_MODE.CLIP_HTML_INFO | null; 56 | /** 57 | * 枚举剪贴板包含的格式 58 | * @returns 59 | */ 60 | function enumClipboardFormats(): Array<{ 61 | "type": string; 62 | "type_name": string; 63 | }>; 64 | /** 65 | * 获取剪贴板内容响应 66 | * @returns 67 | */ 68 | function getClipboardInfo(): { 69 | format: string; 70 | hwnd: number; 71 | id: number; 72 | formatCount: number; 73 | } | null; 74 | } 75 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/type/promiseEval.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import main = require("./index"); 3 | export declare enum HMC_PROMISEEVAL_TASK_TYPE { 4 | getClipboardFilePaths2 = 1, 5 | captureBmp2 = 2, 6 | closeWindow2 = 3, 7 | getClipboardText2 = 5, 8 | getThumbnailPng2 = 6, 9 | getTrayList2 = 7 10 | } 11 | export type HMC_PROMISEEVAL_TASK_TYPE_ALL_NAME = keyof typeof HMC_PROMISEEVAL_TASK_TYPE; 12 | export declare class HMC_PromiseeEvalTask { 13 | async: Partial Promise>>; 14 | sync: Partial any>>; 15 | constructor(); 16 | getTrayList2(): Promise>; 17 | getTrayList2Sync(): Array; 18 | } 19 | export interface HMC_PromiseeEvalTask { 20 | /** 21 | * 获取剪贴板的文件列表 22 | */ 23 | getClipboardFilePaths2(): Promise; 24 | /** 25 | * 获取剪贴板的文件列表 26 | */ 27 | getClipboardFilePaths2Sync(): string[]; 28 | /** 29 | * 截图指定窗口 30 | * @param handle 句柄 31 | */ 32 | captureBmp2(handle: number): Promise; 33 | /** 34 | * 截图指定窗口并保存为文件 35 | * @param handle 句柄 36 | * @param path 文件路径 37 | */ 38 | captureBmp2(handle: number, path: string): Promise; 39 | /** 40 | * 截图指定窗口并保存为文件 41 | * @param path 文件路径 42 | * @param handle 句柄 43 | */ 44 | captureBmp2(path: string, handle: number): Promise; 45 | /** 46 | * 截图整个屏幕到文件 47 | * @param path 文件路径 48 | */ 49 | captureBmp2(path: string): Promise; 50 | /** 51 | * 截图整个屏幕到Buffer 52 | */ 53 | captureBmp2(): Promise; 54 | /** 55 | * 从指定坐标开始截图并返回为Buffer 56 | * @param x 左边开始的坐标 `left` 57 | * @param y 顶部坐标 `top` 58 | * @param nScopeWidth 宽度 59 | * @param nScopeHeight 高度 60 | */ 61 | captureBmp2(x: number, y: number, nScopeWidth: number, nScopeHeight: number): Promise; 62 | /** 63 | * 截图整个屏幕到文件 64 | * @param path 文件路径 65 | * @param x 左边开始的坐标 `left` 66 | * @param y 顶部坐标 `top` 67 | * @param nScopeWidth 宽度 68 | * @param nScopeHeight 高度 69 | */ 70 | captureBmp2(path: string, x: number, y: number, nScopeWidth: number, nScopeHeight: number): Promise; 71 | /** 72 | * 截图整个屏幕到文件 73 | * @param x 左边开始的坐标 `left` 74 | * @param y 顶部坐标 `top` 75 | * @param nScopeWidth 宽度 76 | * @param nScopeHeight 高度 77 | * @param path 文件路径 78 | */ 79 | captureBmp2(x: number, y: number, nScopeWidth: number, nScopeHeight: number, path: string): Promise; 80 | /** 81 | * 截图指定窗口 82 | * @param handle 句柄 83 | */ 84 | captureBmp2Sync(handle: number): Buffer | null; 85 | /** 86 | * 截图指定窗口并保存为文件 87 | * @param handle 句柄 88 | * @param path 文件路径 89 | */ 90 | captureBmp2Sync(handle: number, path: string): boolean; 91 | /** 92 | * 截图指定窗口并保存为文件 93 | * @param path 文件路径 94 | * @param handle 句柄 95 | */ 96 | captureBmp2Sync(path: string, handle: number): boolean; 97 | /** 98 | * 截图整个屏幕到文件 99 | * @param path 文件路径 100 | */ 101 | captureBmp2Sync(path: string): boolean; 102 | /** 103 | * 截图整个屏幕到Buffer 104 | */ 105 | captureBmp2Sync(): Buffer | null; 106 | /** 107 | * 从指定坐标开始截图并返回为Buffer 108 | * @param x 左边开始的坐标 `left` 109 | * @param y 顶部坐标 `top` 110 | * @param nScopeWidth 宽度 111 | * @param nScopeHeight 高度 112 | */ 113 | captureBmp2Sync(x: number, y: number, nScopeWidth: number, nScopeHeight: number): Buffer | null; 114 | /** 115 | * 截图整个屏幕到文件 116 | * @param path 文件路径 117 | * @param x 左边开始的坐标 `left` 118 | * @param y 顶部坐标 `top` 119 | * @param nScopeWidth 宽度 120 | * @param nScopeHeight 高度 121 | */ 122 | captureBmp2Sync(path: string, x: number, y: number, nScopeWidth: number, nScopeHeight: number): boolean; 123 | /** 124 | * 截图整个屏幕到文件 125 | * @param x 左边开始的坐标 `left` 126 | * @param y 顶部坐标 `top` 127 | * @param nScopeWidth 宽度 128 | * @param nScopeHeight 高度 129 | * @param path 文件路径 130 | */ 131 | captureBmp2Sync(x: number, y: number, nScopeWidth: number, nScopeHeight: number, path: string): boolean; 132 | /** 133 | * 关闭窗口 异步 134 | * @param handle 句柄 135 | * @param grade 等级 136 | * - 1 关闭 / 非强制 137 | * - 2 关闭 / 系统级(半强制) 138 | * - 3 关闭线程 (强制) 139 | * - 5 尝试所有办法直到关闭 (默认) 140 | */ 141 | closeWindow2(handle: number, grade?: 1 | 2 | 3 | 5): Promise; 142 | /** 143 | * 关闭窗口 同步 144 | * @param handle 句柄 145 | * @param grade 等级 146 | * - 1 关闭 / 非强制 147 | * - 2 关闭 / 系统级(半强制) 148 | * - 3 关闭线程 (强制) 149 | * - 5 尝试所有办法直到关闭 (默认) 150 | */ 151 | closeWindow2Sync(handle: number, grade?: 1 | 2 | 3 | 5): boolean; 152 | /** 153 | * 获取剪贴板文本 `async` 154 | */ 155 | getClipboardText2(): Promise; 156 | /** 157 | * 获取剪贴板文本 `sync` 158 | */ 159 | getClipboardText2Sync(): string | null; 160 | /** 161 | * 获取 文件 / EXE / icon / folder /img 的缩略图 (png格式) 162 | * @param filePath 被获取路径 163 | * @param output 输出路径 164 | * @param img_size 图片大小 推荐: `16` `64` `128` `256` 165 | * @default 256 166 | */ 167 | getThumbnailPng2(filePath: string, output: string, img_size: number): Promise; 168 | /** 169 | * 获取 文件 / EXE / icon / folder /img 的缩略图 (png格式) 170 | * @param filePath 被获取路径 171 | * @param output 输出路径 172 | * @default 256 173 | */ 174 | getThumbnailPng2(filePath: string, output: string): Promise; 175 | /** 176 | * 获取 文件 / EXE / icon / folder /img 的缩略图 (png格式) 177 | * @param filePath 被获取路径 178 | * @param img_size 图片大小 推荐: `16` `64` `128` `256` 179 | * @default 256 180 | */ 181 | getThumbnailPng2(filePath: string, img_size: number): Promise; 182 | /** 183 | * 获取 文件 / EXE / icon / folder /img 的缩略图 (png格式) 184 | * @param filePath 被获取路径 185 | * @param img_size 图片大小 `256` 186 | */ 187 | getThumbnailPng2(filePath: string): Promise; 188 | /** 189 | * 获取 文件 / EXE / icon / folder /img 的缩略图 (png格式) 190 | * @param filePath 被获取路径 191 | * @param output 输出路径 192 | * @param img_size 图片大小 推荐: `16` `64` `128` `256` 193 | * @default 256 194 | */ 195 | getThumbnailPng2(filePath: string, output?: string, img_size?: number): Promise; 196 | /** 197 | * 获取 文件 / EXE / icon / folder /img 的缩略图 (png格式) 198 | * @param filePath 被获取路径 199 | * @param output 输出路径 200 | * @param img_size 图片大小 推荐: `16` `64` `128` `256` 201 | * @default 256 202 | */ 203 | getThumbnailPng2Sync(filePath: string, output: string, img_size: number): boolean | null; 204 | /** 205 | * 获取 文件 / EXE / icon / folder /img 的缩略图 (png格式) 206 | * @param filePath 被获取路径 207 | * @param output 输出路径 208 | * @default 256 209 | */ 210 | getThumbnailPng2Sync(filePath: string, output: string): boolean | null; 211 | /** 212 | * 获取 文件 / EXE / icon / folder /img 的缩略图 (png格式) 213 | * @param filePath 被获取路径 214 | * @param img_size 图片大小 推荐: `16` `64` `128` `256` 215 | * @default 256 216 | */ 217 | getThumbnailPng2Sync(filePath: string, img_size: number): Buffer | null; 218 | /** 219 | * 获取 文件 / EXE / icon / folder /img 的缩略图 (png格式) 220 | * @param filePath 被获取路径 221 | * @param img_size 图片大小 `256` 222 | */ 223 | getThumbnailPng2Sync(filePath: string): Buffer | null; 224 | /** 225 | * 获取 文件 / EXE / icon / folder /img 的缩略图 (png格式) 226 | * @param filePath 被获取路径 227 | * @param output 输出路径 228 | * @param img_size 图片大小 推荐: `16` `64` `128` `256` 229 | * @default 256 230 | */ 231 | getThumbnailPng2Sync(filePath: string, output?: string, img_size?: number): unknown; 232 | } 233 | export declare const promiseEvalTask: HMC_PromiseeEvalTask; 234 | -------------------------------------------------------------------------------- /source/hmc-win32@2.0/type/util.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | export declare namespace ref { 3 | /** 4 | * 将内容格式化为文本路径 5 | * @param Str 6 | * @returns 7 | */ 8 | function path(Str: any): string; 9 | /** 10 | * 格式化为bool 11 | * @param bool 12 | * @returns 13 | */ 14 | function bool(bool: any): boolean; 15 | /** 16 | * 将内容格式化为文本 17 | * @param Str 18 | * @returns 19 | */ 20 | function string(Str: any): any; 21 | /** 22 | * 格式化数字为float(强制) 浮点 23 | * @param Num 24 | * @returns 25 | */ 26 | function float(Num: any): number; 27 | /** 28 | * 格式化数字为int(强制) 取整 29 | * @param Num 整数型 30 | * @returns 31 | */ 32 | function int(Num: any): number; 33 | /** 34 | * 格式化数字为int(强制) 取整 35 | * @param Num 整数型 36 | * @returns 37 | */ 38 | function long(Num: any): number; 39 | /** 40 | * 文本数组 41 | * @param array 42 | * @returns 43 | */ 44 | function stringArray(array: Set | Array): string[]; 45 | function is_stringArray(array: Array): array is Array; 46 | function convertMultiStringArray(input: string): string[]; 47 | function convertMultiStringArray(input: Array): string; 48 | function convertMultiStringArray(input: Set): string; 49 | /** 50 | * 文本数组 51 | * @param array 52 | * @returns 53 | */ 54 | function intArray(array: Set | Array): number[]; 55 | /** 56 | * 将命令行内容组转为cmd文本 57 | * @param argv 58 | */ 59 | function formatArgv(...argv: Array[] | any[]): string; 60 | /** 61 | * 拼合buff片段 62 | * @param buffList 63 | * @returns 64 | */ 65 | function concatBuff(buffList: Buffer[]): Buffer; 66 | function JSONP(input: any, orData: T): T; 67 | function JSONP(input: any): { 68 | [key: string | number]: any; 69 | } | Array | null; 70 | } 71 | -------------------------------------------------------------------------------- /source/lib_temp/example/hmc_console.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../console.hpp" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | 12 | int main() 13 | { 14 | hmc_console::setLevel(hmc_console::level::all); 15 | 16 | hmc_console::warn("example", "hmc_console -> "); 17 | hmc_console::error("example", "hmc_console -> "); 18 | hmc_console::info("example", "hmc_console -> "); 19 | 20 | hmc_console::debug("example", vector({6566, 2314163, 136541313, 153541536, 442233})); 21 | 22 | hmc_console::debug("example", map()); 23 | 24 | hmc_console::debug("example", vector({"sagdsh", "sagdfsh", "136541313", "sagdstgw4e"})); 25 | 26 | hmc_console::debug("HWND", GetConsoleWindow()); 27 | 28 | return 0; 29 | 30 | } -------------------------------------------------------------------------------- /source/lib_temp/example/hmc_env.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../include/attribute.hpp" 4 | #include "../registr.hpp" 5 | #include "../environment.hpp" 6 | 7 | using namespace std; 8 | using namespace hmc_registr; 9 | using namespace hmc_env; 10 | 11 | int main() 12 | { 13 | 14 | // 枚举所有的 系统变量的键 15 | for (auto &&keyUse : hmc_env::systemEnv::keySysList()) 16 | { 17 | cout << keyUse << endl; 18 | } 19 | 20 | // 枚举所有的 用户变量的键 21 | for (auto &&keyUse : hmc_env::systemEnv::keyUseList()) 22 | { 23 | cout << keyUse << endl; 24 | } 25 | 26 | 27 | // 枚举所有的 用户变量 (按照系统的环境变量分析的) 28 | for (auto &&globalVariable : hmc_env::systemEnv::getGlobalVariable()) 29 | { 30 | 31 | cout << globalVariable.first << " : " << globalVariable.second << endl; 32 | 33 | } 34 | 35 | 36 | // 添加用户变量 37 | hmc_env::systemEnv::putUse("环境名称", "值", false /*添加到尾部*/, true /*自转义变量: %变量% */); 38 | 39 | // 转义环境文本带入(实时获取) 40 | hmc_env::systemEnv::escapeEnvVariable("%APPDATA%\\目录"); 41 | 42 | // 获取指定变量 (按照变量实际优先级排序) 43 | string pEnvStr = string(); 44 | if (hmc_env::systemEnv::get("APPDATA", pEnvStr)) 45 | { 46 | cout << "获取默认的变量值 成功 值是 -> " << pEnvStr << endl; 47 | }; 48 | 49 | 50 | // 获取指定变量 (按照变量实际优先级排序) [系统变量] 51 | string pSysEnvStr = string(); 52 | if (hmc_env::systemEnv::getSys("APPDATA", pSysEnvStr)) 53 | { 54 | cout << "获取系统的变量值 成功 值是 -> " << pSysEnvStr << endl; 55 | }; 56 | 57 | 58 | hmc_env::systemEnv::removeUse("需要删除的变量名"); 59 | 60 | 61 | // 从系统获取所有变量并写入到当前进程 62 | hmc_env::systemEnv::updateThis(true/*触发已删除的值移除*/,true/*触发值更新*/); 63 | 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /source/lib_temp/example/hmc_registr.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/attribute.hpp" 2 | #include "../registr.hpp" 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | // 设置注册表值 9 | hmc_registr::setRegistrValue(HKEY_CURRENT_USER, "hmc", "hello", string("Hello HMC API Tool"), REG_SZ); 10 | 11 | // 32 bit munber 12 | hmc_registr::setRegistrValue(HKEY_CURRENT_USER, "hmc", "hmc_munber", (DWORD)566554); 13 | 14 | // 64 bit munber 15 | hmc_registr::setRegistrValue(HKEY_CURRENT_USER, "hmc", "hmc_munber_long",(DWORD64) 56650000005004); 16 | 17 | hmc_registr::setRegistrValue(HKEY_CURRENT_USER, "hmc", "AutoStr", (string)"Auto Detect Type"); 18 | 19 | // GET 20 | string str_AutoStr = hmc_registr::getRegistrValue(HKEY_CURRENT_USER, "hmc", "AutoStr"); 21 | cout << "str_AutoStr -> " << str_AutoStr << endl; 22 | 23 | DWORD DW_hmc_munber = hmc_registr::getRegistrValue(HKEY_CURRENT_USER, "hmc", "hmc_munber"); 24 | cout << "str_AutoStr -> " << DW_hmc_munber << endl; 25 | 26 | cout << "long long -> " << hmc_registr::getRegistrValue(HKEY_CURRENT_USER, "hmc", "hmc_munber_long") << endl; 27 | 28 | cout << "has data"<<(hmc_registr::hasRegistrKey(HKEY_CURRENT_USER, "hmc","hmc_munber_long")?"true":"false")< */ false, /* 过滤-> */ REG_SZ); 37 | 38 | for (auto &&data : walkRegistrDir) 39 | { 40 | cout << "-----------------------------------" << endl; 41 | cout << "dirPath : " << data.dirPath << endl; 42 | cout << "is_value : " << data.is_value << endl; 43 | cout << "isDir : " << data.isDir << endl; 44 | cout << "root : " << hmc_registr::getHive(data.root) << endl; 45 | cout << "size : " << data.size << endl; 46 | cout << "time : " << data.time << endl; 47 | cout << "type : " << data.type << endl; 48 | cout << "vkey : " << data.vkey << endl; 49 | cout << "dirPath : " << data.dirPath << endl; 50 | cout << "value[size] : " << data.value.size() << endl; 51 | } 52 | 53 | 54 | // 删除单个值 55 | hmc_registr::removeRegistrValue(HKEY_CURRENT_USER, "hmc", "hmc_munber_long"); 56 | 57 | hmc_registr::copyRegistrDir(HKEY_CURRENT_USER, "hmc","hmc2copy"); 58 | 59 | hmc_registr::removeRegistrTree(HKEY_CURRENT_USER, "hmc","hmc"); 60 | 61 | hmc_registr::removeRegistrDir(HKEY_CURRENT_USER, "hmc"); 62 | 63 | 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /source/lib_temp/example/hmc_tray.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../tray.hpp" 4 | 5 | using namespace std; 6 | 7 | int main() 8 | { 9 | // 启动 10 | hmc_tray::start(); 11 | // 设置图标 12 | hmc_tray::setTrayIcon("C:\\Windows\\explorer.exe"); 13 | 14 | // 设置主按钮 15 | hmc_tray::addMenuItem(hmc_tray::Menu::menu("显示窗口", "btn::show_window")); 16 | hmc_tray::addMenuItem(hmc_tray::Menu::check("自动同步", "btn::auto_sync", true)); 17 | hmc_tray::addMenuItem(hmc_tray::Menu::separator("btn::separator::01")); 18 | hmc_tray::addMenuItem(hmc_tray::Menu::menu("马上同步", "btn::show_start")); 19 | hmc_tray::addMenuItem(hmc_tray::Menu::check("自动启动", "btn::auto_start_app", true)); 20 | hmc_tray::addMenuItem(hmc_tray::Menu::menu("退出程序", "btn::quit_app")); 21 | 22 | // 子键创建方式 演示 23 | hmc_tray::addMenuItem(hmc_tray::Menu::menu("同步方式", "sub::type_sync", true)); 24 | 25 | hmc_tray::addMenuItem(hmc_tray::Menu::check("立刻同步", "sub::at_once_sync", true)); 26 | // 分割线 27 | hmc_tray::addMenuItem(hmc_tray::Menu::separator("sub::separator::02")); 28 | 29 | hmc_tray::addMenuItem(hmc_tray::Menu::check("停止同步", "sub::check_stop_sync", true)); 30 | hmc_tray::addMenuItem(hmc_tray::Menu::check("每分钟制", "sub::check_min", true)); 31 | hmc_tray::addMenuItem(hmc_tray::Menu::check("每小时制", "sub::check_hourly", true)); 32 | 33 | // hmc_tray::on 34 | /** 35 | * 他还支持 36 | * - middleClick 37 | * - move 38 | * - click 39 | * - mouseMove 40 | * - leftButtonDoubleClick 41 | * - dblclick 42 | * - leftButtonUp 43 | * - leftButtonDown 44 | * - rightButtonUp 45 | * - rightButtonDown 46 | */ 47 | 48 | hmc_tray::on("move", ([]() 49 | { cout << "move->" 50 | << "" << endl; })); 51 | 52 | // 按下了 停止同步 后 其他选择都取消 53 | hmc_tray::on("sub::check_stop_sync", ([]() 54 | { 55 | cout << "click->" 56 | << "sub::check_stop_sync" << endl; 57 | hmc_tray::setMenuItmeSelect("sub::check_min", false); 58 | hmc_tray::setMenuItmeSelect("sub::check_hourly", false); 59 | hmc_tray::setMenuItmeSelect("sub::at_once_sync", false); 60 | 61 | // 如果未选中就选中 62 | if (hmc_tray::getMenuItme("sub::check_stop_sync").select) 63 | { 64 | hmc_tray::setMenuItmeSelect("sub::check_stop_sync", true); 65 | } 66 | else 67 | { 68 | hmc_tray::setMenuItmeSelect("sub::check_stop_sync", false); 69 | } })); 70 | 71 | // 将这些按钮添加到XXX按钮中 72 | hmc_tray::setMenuItmetoSubMenu( 73 | // 主按钮是此ID 74 | "sub::type_sync", 75 | // 子按钮是这些 76 | "sub::at_once_sync", "sub::separator::02", "sub::check_stop_sync", "sub::check_min", "sub::check_hourly"); 77 | 78 | Sleep(3000); 79 | hmc_tray::setTrayInfo("时间已经过去了三秒"); 80 | 81 | // 禁用此id的按钮: 82 | hmc_tray::setMenuItmeEnable("sub::check_min", true); 83 | 84 | // 隐藏此id的按钮: 85 | hmc_tray::setMenuItmeVisible("btn::quit_app", false); 86 | 87 | Sleep(5000); 88 | // 设置此按钮的名称为: 89 | hmc_tray::setMenuItmeName("btn::auto_sync", "取消同步"); 90 | hmc_tray::setTrayInfo("正在同步中...."); 91 | Sleep(9000); 92 | 93 | hmc_tray::setMenuItmeName("btn::auto_sync", "自动同步"); 94 | hmc_tray::setTrayInfo("上传一次更新为9秒前\n共更新了9999条数据"); 95 | 96 | while (true) 97 | { 98 | } 99 | 100 | hmc_tray::close(); 101 | 102 | return 0; 103 | } 104 | -------------------------------------------------------------------------------- /source/mian/chcpList.d.ts: -------------------------------------------------------------------------------- 1 | import { HMC } from "./hmc"; 2 | export declare let chcpList: { 3 | [key: string | number]: HMC.SystemDecoder; 4 | }; 5 | -------------------------------------------------------------------------------- /source/mian/chcpList.ts: -------------------------------------------------------------------------------- 1 | import { HMC } from "./hmc"; 2 | export let chcpList: { [key: string | number]: HMC.SystemDecoder } = { 3 | 37: "IBM037", 4 | 437: "IBM437", 5 | 500: "IBM500", 6 | 708: "ASMO-708", 7 | 720: "DOS-720", 8 | 737: "ibm737", 9 | 775: "ibm775", 10 | 850: "ibm850", 11 | 852: "ibm852", 12 | 855: "IBM855", 13 | 857: "ibm857", 14 | 858: "IBM00858", 15 | 860: "IBM860", 16 | 861: "ibm861", 17 | 862: "DOS-862", 18 | 863: "IBM863", 19 | 864: "IBM864", 20 | 865: "IBM865", 21 | 866: "cp866", 22 | 869: "ibm869", 23 | 870: "IBM870", 24 | 874: "windows-874", 25 | 875: "cp875", 26 | 932: "shift_jis", 27 | 936: "gb2312", 28 | 949: "ks_c_5601-1987", 29 | 950: "big5", 30 | 1026: "IBM1026", 31 | 1047: "IBM01047", 32 | 1140: "IBM01140", 33 | 1141: "IBM01141", 34 | 1142: "IBM01142", 35 | 1143: "IBM01143", 36 | 1144: "IBM01144", 37 | 1145: "IBM01145", 38 | 1146: "IBM01146", 39 | 1147: "IBM01147", 40 | 1148: "IBM01148", 41 | 1149: "IBM01149", 42 | 1200: "utf-16", 43 | 1201: "unicodeFFFE", 44 | 1250: "windows-1250", 45 | 1251: "windows-1251", 46 | 1252: "windows-1252", 47 | 1253: "windows-1253", 48 | 1254: "windows-1254", 49 | 1255: "windows-1255", 50 | 1256: "windows-1256", 51 | 1257: "windows-1257", 52 | 1258: "windows-1258", 53 | 1361: "Johab", 54 | 10000: "macintosh", 55 | 10001: "x-mac-japanese", 56 | 10002: "x-mac-chinesetrad", 57 | 10003: "x-mac-korean", 58 | 10004: "x-mac-arabic", 59 | 10005: "x-mac-hebrew", 60 | 10006: "x-mac-greek", 61 | 10007: "x-mac-cyrillic", 62 | 10008: "x-mac-chinesesimp", 63 | 10010: "x-mac-romanian", 64 | 10017: "x-mac-ukrainian", 65 | 10021: "x-mac-thai", 66 | 10029: "x-mac-ce", 67 | 10079: "x-mac-icelandic", 68 | 10081: "x-mac-turkish", 69 | 10082: "x-mac-croatian", 70 | 12000: "utf-32", 71 | 12001: "utf-32BE", 72 | 20000: "x-Chinese_CNS", 73 | 20001: "x-cp20001", 74 | 20002: "x_Chinese-Eten", 75 | 20003: "x-cp20003", 76 | 20004: "x-cp20004", 77 | 20005: "x-cp20005", 78 | 20105: "x-IA5", 79 | 20106: "x-IA5-German", 80 | 20107: "x-IA5-Swedish", 81 | 20108: "x-IA5-Norwegian", 82 | 20127: "us-ascii", 83 | 20261: "x-cp20261", 84 | 20269: "x-cp20269", 85 | 20273: "IBM273", 86 | 20277: "IBM277", 87 | 20278: "IBM278", 88 | 20280: "IBM280", 89 | 20284: "IBM284", 90 | 20285: "IBM285", 91 | 20290: "IBM290", 92 | 20297: "IBM297", 93 | 20420: "IBM420", 94 | 20423: "IBM423", 95 | 20424: "IBM424", 96 | 20833: "x-EBCDIC-KoreanExtended", 97 | 20838: "IBM-Thai", 98 | 20866: "koi8-r", 99 | 20871: "IBM871", 100 | 20880: "IBM880", 101 | 20905: "IBM905", 102 | 20924: "IBM00924", 103 | 20932: "EUC-JP", 104 | 20936: "x-cp20936", 105 | 20949: "x-cp20949", 106 | 21025: "cp1025", 107 | 21866: "koi8-u", 108 | 28591: "iso-8859-1", 109 | 28592: "iso-8859-2", 110 | 28593: "iso-8859-3", 111 | 28594: "iso-8859-4", 112 | 28595: "iso-8859-5", 113 | 28596: "iso-8859-6", 114 | 28597: "iso-8859-7", 115 | 28598: "iso-8859-8", 116 | 28599: "iso-8859-9", 117 | 28603: "iso-8859-13", 118 | 28605: "iso-8859-15", 119 | 29001: "x-Europa", 120 | 38598: "iso-8859-8-i", 121 | 50220: "iso-2022-jp", 122 | 50221: "csISO2022JP", 123 | 50222: "iso-2022-jp", 124 | 50225: "iso-2022-kr", 125 | 50227: "x-cp50227", 126 | 51932: "euc-jp", 127 | 51936: "EUC-CN", 128 | 51949: "euc-kr", 129 | 52936: "hz-gb-2312", 130 | 54936: "GB18030", 131 | 57002: "x-iscii-de", 132 | 57003: "x-iscii-be", 133 | 57004: "x-iscii-ta", 134 | 57005: "x-iscii-te", 135 | 57006: "x-iscii-as", 136 | 57007: "x-iscii-or", 137 | 57008: "x-iscii-ka", 138 | 57009: "x-iscii-ma", 139 | 57010: "x-iscii-gu", 140 | 57011: "x-iscii-pa", 141 | 65000: "utf-7", 142 | 65001: "utf-8" 143 | }; -------------------------------------------------------------------------------- /source/mian/trash/chcpList.d.ts: -------------------------------------------------------------------------------- 1 | import { HMC } from "./hmc"; 2 | export declare let chcpList: { 3 | [key: string | number]: HMC.SystemDecoder; 4 | }; 5 | -------------------------------------------------------------------------------- /source/mian/trash/chcpList.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.chcpList = void 0; 4 | exports.chcpList = { 5 | 37: "IBM037", 6 | 437: "IBM437", 7 | 500: "IBM500", 8 | 708: "ASMO-708", 9 | 720: "DOS-720", 10 | 737: "ibm737", 11 | 775: "ibm775", 12 | 850: "ibm850", 13 | 852: "ibm852", 14 | 855: "IBM855", 15 | 857: "ibm857", 16 | 858: "IBM00858", 17 | 860: "IBM860", 18 | 861: "ibm861", 19 | 862: "DOS-862", 20 | 863: "IBM863", 21 | 864: "IBM864", 22 | 865: "IBM865", 23 | 866: "cp866", 24 | 869: "ibm869", 25 | 870: "IBM870", 26 | 874: "windows-874", 27 | 875: "cp875", 28 | 932: "shift_jis", 29 | 936: "gb2312", 30 | 949: "ks_c_5601-1987", 31 | 950: "big5", 32 | 1026: "IBM1026", 33 | 1047: "IBM01047", 34 | 1140: "IBM01140", 35 | 1141: "IBM01141", 36 | 1142: "IBM01142", 37 | 1143: "IBM01143", 38 | 1144: "IBM01144", 39 | 1145: "IBM01145", 40 | 1146: "IBM01146", 41 | 1147: "IBM01147", 42 | 1148: "IBM01148", 43 | 1149: "IBM01149", 44 | 1200: "utf-16", 45 | 1201: "unicodeFFFE", 46 | 1250: "windows-1250", 47 | 1251: "windows-1251", 48 | 1252: "windows-1252", 49 | 1253: "windows-1253", 50 | 1254: "windows-1254", 51 | 1255: "windows-1255", 52 | 1256: "windows-1256", 53 | 1257: "windows-1257", 54 | 1258: "windows-1258", 55 | 1361: "Johab", 56 | 10000: "macintosh", 57 | 10001: "x-mac-japanese", 58 | 10002: "x-mac-chinesetrad", 59 | 10003: "x-mac-korean", 60 | 10004: "x-mac-arabic", 61 | 10005: "x-mac-hebrew", 62 | 10006: "x-mac-greek", 63 | 10007: "x-mac-cyrillic", 64 | 10008: "x-mac-chinesesimp", 65 | 10010: "x-mac-romanian", 66 | 10017: "x-mac-ukrainian", 67 | 10021: "x-mac-thai", 68 | 10029: "x-mac-ce", 69 | 10079: "x-mac-icelandic", 70 | 10081: "x-mac-turkish", 71 | 10082: "x-mac-croatian", 72 | 12000: "utf-32", 73 | 12001: "utf-32BE", 74 | 20000: "x-Chinese_CNS", 75 | 20001: "x-cp20001", 76 | 20002: "x_Chinese-Eten", 77 | 20003: "x-cp20003", 78 | 20004: "x-cp20004", 79 | 20005: "x-cp20005", 80 | 20105: "x-IA5", 81 | 20106: "x-IA5-German", 82 | 20107: "x-IA5-Swedish", 83 | 20108: "x-IA5-Norwegian", 84 | 20127: "us-ascii", 85 | 20261: "x-cp20261", 86 | 20269: "x-cp20269", 87 | 20273: "IBM273", 88 | 20277: "IBM277", 89 | 20278: "IBM278", 90 | 20280: "IBM280", 91 | 20284: "IBM284", 92 | 20285: "IBM285", 93 | 20290: "IBM290", 94 | 20297: "IBM297", 95 | 20420: "IBM420", 96 | 20423: "IBM423", 97 | 20424: "IBM424", 98 | 20833: "x-EBCDIC-KoreanExtended", 99 | 20838: "IBM-Thai", 100 | 20866: "koi8-r", 101 | 20871: "IBM871", 102 | 20880: "IBM880", 103 | 20905: "IBM905", 104 | 20924: "IBM00924", 105 | 20932: "EUC-JP", 106 | 20936: "x-cp20936", 107 | 20949: "x-cp20949", 108 | 21025: "cp1025", 109 | 21866: "koi8-u", 110 | 28591: "iso-8859-1", 111 | 28592: "iso-8859-2", 112 | 28593: "iso-8859-3", 113 | 28594: "iso-8859-4", 114 | 28595: "iso-8859-5", 115 | 28596: "iso-8859-6", 116 | 28597: "iso-8859-7", 117 | 28598: "iso-8859-8", 118 | 28599: "iso-8859-9", 119 | 28603: "iso-8859-13", 120 | 28605: "iso-8859-15", 121 | 29001: "x-Europa", 122 | 38598: "iso-8859-8-i", 123 | 50220: "iso-2022-jp", 124 | 50221: "csISO2022JP", 125 | 50222: "iso-2022-jp", 126 | 50225: "iso-2022-kr", 127 | 50227: "x-cp50227", 128 | 51932: "euc-jp", 129 | 51936: "EUC-CN", 130 | 51949: "euc-kr", 131 | 52936: "hz-gb-2312", 132 | 54936: "GB18030", 133 | 57002: "x-iscii-de", 134 | 57003: "x-iscii-be", 135 | 57004: "x-iscii-ta", 136 | 57005: "x-iscii-te", 137 | 57006: "x-iscii-as", 138 | 57007: "x-iscii-or", 139 | 57008: "x-iscii-ka", 140 | 57009: "x-iscii-ma", 141 | 57010: "x-iscii-gu", 142 | 57011: "x-iscii-pa", 143 | 65000: "utf-7", 144 | 65001: "utf-8" 145 | }; 146 | -------------------------------------------------------------------------------- /source/mian/trash/native.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.native = void 0; 4 | let HMCNotPlatform = "HMC::HMC current method only supports win32 platform"; 5 | function fnBool(...args) { console.error(HMCNotPlatform); return false; } 6 | function fnVoid(...args) { console.error(HMCNotPlatform); return undefined; } 7 | function fnNull(...args) { console.error(HMCNotPlatform); return null; } 8 | function fnNum(...args) { console.error(HMCNotPlatform); return 0; } 9 | function fnStrList(...args) { console.error(HMCNotPlatform); return []; } 10 | function fnStr(...args) { console.error(HMCNotPlatform); return ''; } 11 | let NotHMC = { 12 | MessageError: fnVoid, 13 | MessageStop: fnBool, 14 | SetBlockInput: fnBool, 15 | SetSystemHOOK: fnBool, 16 | SetWindowInTaskbarVisible: fnBool, 17 | alert: fnBool, 18 | clearClipboard: fnBool, 19 | closedHandle: fnVoid, 20 | confirm: fnBool, 21 | createDirSymlink: fnBool, 22 | createHardLink: fnBool, 23 | createPathRegistr: fnBool, 24 | createSymlink: fnBool, 25 | desc: "HMC Connection System api", 26 | enumRegistrKey: () => { console.error(HMCNotPlatform); return []; }, 27 | getAllWindows: () => { console.error(HMCNotPlatform); return []; }, 28 | getAllWindowsHandle: () => { console.error(HMCNotPlatform); return []; }, 29 | getBasicKeys: () => { 30 | console.error(HMCNotPlatform); 31 | return { 32 | "alt": false, 33 | "ctrl": false, 34 | "shift": false, 35 | "win": false, 36 | }; 37 | }, 38 | getClipboardFilePaths: fnStrList, 39 | getClipboardText: fnStr, 40 | getDetailsProcessList: () => { console.error(HMCNotPlatform); return []; }, 41 | getDeviceCaps: () => { 42 | console.error(HMCNotPlatform); 43 | return { 44 | "height": 0, 45 | "width": 0, 46 | }; 47 | }, 48 | getForegroundWindow: fnNum, 49 | getForegroundWindowProcessID: fnNull, 50 | getHandleProcessID: fnNull, 51 | getHidUsbList: () => { console.error(HMCNotPlatform); return []; }, 52 | getMainWindow: fnNull, 53 | getMetrics: () => { console.error(HMCNotPlatform); return { "left": 0, "top": 0, "x": 0, "y": 0 }; }, 54 | getMouseMovePoints: () => { console.error(HMCNotPlatform); return []; }, 55 | getPointWindow: fnNull, 56 | getPointWindowMain: fnNum, 57 | getPointWindowName: fnStr, 58 | getPointWindowProcessId: fnNum, 59 | getProcessHandle: fnNull, 60 | getProcessList: () => { console.error(HMCNotPlatform); return []; }, 61 | getProcessName: fnNull, 62 | getProcessidFilePath: fnNull, 63 | getRegistrBuffValue: fnVoid, 64 | getRegistrDword: fnNum, 65 | getRegistrQword: () => { 66 | console.error(HMCNotPlatform); 67 | return BigInt(0); 68 | }, 69 | getShortcutLink: () => { 70 | console.error(HMCNotPlatform); 71 | return { "args": "", "cwd": '', "desc": "", "hotkey": 0, "icon": "", "iconIndex": 0, "showCmd": 0, "path": "" }; 72 | }, 73 | getStringRegKey: fnStr, 74 | getSystemIdleTime: fnNum, 75 | getSystemMenu: fnBool, 76 | getTrayList: () => { console.error(HMCNotPlatform); return []; }, 77 | getUsbDevsInfo: fnStrList, 78 | getWindowRect: () => { 79 | console.error(HMCNotPlatform); 80 | return { "bottom": 0, "height": 0, "width": 0, "left": 0, "top": 0, "right": 0, "x": 0, "y": 0 }; 81 | }, 82 | hasKeyActivate: fnBool, 83 | hasProcess: fnBool, 84 | hasRegistrKey: fnBool, 85 | hasWindowTop: fnBool, 86 | isAdmin: fnBool, 87 | isEnabled: fnBool, 88 | isHandle: fnBool, 89 | isHandleWindowVisible: fnBool, 90 | isProcess: fnBool, 91 | isSystemX64: fnBool, 92 | killProcess: fnBool, 93 | leftClick: fnBool, 94 | lookHandleCloseWindow: fnBool, 95 | lookHandleGetTitle: fnNull, 96 | lookHandleSetTitle: fnBool, 97 | lookHandleShowWindow: fnBool, 98 | messageBox: fnNum, 99 | mouse: fnBool, 100 | openApp: fnBool, 101 | openExternal: fnBool, 102 | openPath: fnBool, 103 | openURL: fnBool, 104 | platform: "win32", 105 | powerControl: fnVoid, 106 | removeStringRegKey: fnBool, 107 | removeStringRegKeyWalk: fnBool, 108 | removeStringRegValue: fnBool, 109 | rightClick: fnBool, 110 | setClipboardFilePaths: fnBool, 111 | setClipboardText: fnBool, 112 | setCursorPos: fnBool, 113 | setHandleTransparent: fnBool, 114 | setRegistrDword: fnBool, 115 | setRegistrKey: fnBool, 116 | setRegistrQword: fnBool, 117 | setShortcutLink: fnBool, 118 | setWindowEnabled: fnBool, 119 | setWindowFocus: fnBool, 120 | setWindowMode: fnBool, 121 | setWindowTop: fnBool, 122 | showMonitors: fnBool, 123 | shutMonitors: fnBool, 124 | sleep: fnBool, 125 | system: fnNum, 126 | systemStartTime: fnNum, 127 | updateWindow: fnBool, 128 | version: "1.0.5", 129 | windowJitter: fnVoid, 130 | enumChildWindows: () => { console.error(HMCNotPlatform); return []; }, 131 | deleteFile: fnNum, 132 | getClipboardSequenceNumber: fnNum, 133 | enumClipboardFormats: () => { console.error(HMCNotPlatform); return []; }, 134 | getHidUsbIdList: () => { console.error(HMCNotPlatform); return []; }, 135 | getDeviceCapsAll: () => { console.error(HMCNotPlatform); return []; }, 136 | isInMonitorWindow: fnBool, 137 | isMouseMonitorWindow: fnBool, 138 | getCurrentMonitorRect: () => { console.error(HMCNotPlatform); return { "bottom": 0, "left": 0, "top": 0, "right": 0, }; }, 139 | getSystemMetricsLen: fnNum 140 | }; 141 | exports.native = (() => { 142 | return process.platform == "win32" ? require("./HMC.node") : NotHMC; 143 | })(); 144 | -------------------------------------------------------------------------------- /source/mian/vkKey.d.ts: -------------------------------------------------------------------------------- 1 | export declare let KeyboardcodeComparisonTable: Map; 2 | export declare const KeyboardVKcodeComparisonEmenList: Array<[VK_key, VK_code | null, VK_keyCode, VK_VirtualKey] | [VK_key, VK_code | null, VK_keyCode, VK_VirtualKey, VK_Nickname]>; 3 | /** 4 | * 格式化键值码 5 | * @param key 6 | * @returns 7 | */ 8 | export declare function vkKey(key: any): number | null; 9 | export declare const KeyboardVKcodeEmenList: Array<[VK_key, VK_code | null, VK_keyCode, VK_VirtualKey] | [VK_key, VK_code | null, VK_keyCode, VK_VirtualKey, VK_Nickname]>; 10 | export type VK_key = string; 11 | export type VK_code = string; 12 | export type VK_keyCode = number; 13 | export type VK_VirtualKey = number; 14 | export type VK_Nickname = string[] | undefined; 15 | export declare const KeyboardcodeEmenList: Map; 16 | -------------------------------------------------------------------------------- /source/src/NAPI异步任务.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/src/NAPI异步任务.png -------------------------------------------------------------------------------- /source/src/NAPI异步任务.xmind: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/src/NAPI异步任务.xmind -------------------------------------------------------------------------------- /source/src/NAPI异步任务设计.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/src/NAPI异步任务设计.png -------------------------------------------------------------------------------- /source/src/us_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/src/us_en.png -------------------------------------------------------------------------------- /source/src/us_en_max.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/src/us_en_max.png -------------------------------------------------------------------------------- /source/src/zh_cn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/src/zh_cn.png -------------------------------------------------------------------------------- /source/src/zh_cn_max.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kihlh/hmc-win32/f6307a08cc59c59f7cf371eb3e0539d4aa999a47/source/src/zh_cn_max.png -------------------------------------------------------------------------------- /source/测试/PromiseFunctionEx 2.0.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace PromiseFunction 15 | { 16 | 17 | std::any resultSend = std::any(); 18 | std::vector arguments_list = {}; 19 | napi_value FormatResultValue(napi_env env, std::any *result_any_data); 20 | std::any PromiseWorkFunc(std::vector *arguments_list); 21 | // void FunArgsToCallBack(napi_env env, napi_callback_info info, std::vector *ArgumentsList, hmc_NodeArgsValue args_value); 22 | 23 | std::optional GpArgsToCallBack; 24 | // 函数名称 25 | std::atomic work = NULL; 26 | std::atomic deferred = NULL; 27 | 28 | // 这些函数虽然是通用的但是不能同用 需要通过静态类或者命名空间区分开 不然会导致函数空间位置不一样 导致不可预测的错误 请勿改动此 29 | void asyncWorkFun(napi_env env, void *data) 30 | { 31 | resultSend = PromiseWorkFunc(&arguments_list); 32 | } 33 | 34 | void completeWork(napi_env env, napi_status status, void *data) 35 | { 36 | return PromiseFunctionUtil::completeWork(env, status, &work, &deferred, &arguments_list, &resultSend, FormatResultValue); 37 | } 38 | 39 | napi_value startWork(napi_env env, napi_callback_info info) 40 | { 41 | // return PromiseFunctionUtil::startWork(env, info, &work, &deferred, asyncWorkFun, completeWork, &arguments_list, FunArgsToCallBack); 42 | return PromiseFunctionUtil::startWork(env, info, &work, &deferred, asyncWorkFun, completeWork, &arguments_list, GpArgsToCallBack); 43 | } 44 | 45 | napi_value startSync(napi_env env, napi_callback_info info) 46 | { 47 | // return PromiseFunctionUtil::startWork(env, info, &work, &deferred, asyncWorkFun, completeWork, &arguments_list, FunArgsToCallBack); 48 | return PromiseFunctionUtil::startWork(env, info, &work, &deferred, asyncWorkFun, completeWork, &arguments_list, GpArgsToCallBack); 49 | } 50 | 51 | // 以下由当前函数功能进行自定义 52 | // 如果需要自定义格式化args 需要在导出时候声明用于导出的函数 或者编辑 startWork / startSync 例如: 53 | // PromiseFunctionUtil::exports(env, exports, "startThread", PromiseFunction::startWork, PromiseFunction::startSync); 54 | // PromiseFunction::GpArgsToCallBack = PromiseFunction::AddArgsToCallBack; 55 | void FunArgsToCallBack(napi_env env, napi_callback_info info, std::vector *ArgumentsList, hmc_NodeArgsValue args_value) 56 | { 57 | } 58 | 59 | // 需要异步的函数 60 | std::any PromiseWorkFunc(std::vector *arguments_list) 61 | { 62 | std::any result = std::any(); 63 | ::Sleep(5000); 64 | return result; 65 | } 66 | 67 | // 格式化<需要异步的函数>返回值到js 返回值 68 | napi_value FormatResultValue(napi_env env, std::any *result_any_data) 69 | { 70 | napi_value result; 71 | napi_get_null(env, &result); 72 | 73 | if (!result_any_data->has_value()) 74 | { 75 | return result; 76 | } 77 | 78 | return result; 79 | } 80 | 81 | }; 82 | 83 | napi_value Init(napi_env env, napi_value exports) 84 | { 85 | 86 | PromiseFunctionUtil::exports(env, exports, "startThread", PromiseFunction::startWork, PromiseFunction::startSync); 87 | PromiseFunction::GpArgsToCallBack = PromiseFunction::FunArgsToCallBack; 88 | 89 | return exports; 90 | } 91 | 92 | NAPI_MODULE(NODE_GYP_MODULE_NAME, Init); 93 | -------------------------------------------------------------------------------- /source/测试/async_callback.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | 10 | class setSparse { 11 | public: 12 | static bool func(const wchar_t* path, const bool create) { 13 | bool result = false; 14 | _sleep(100); 15 | return result; 16 | } 17 | static napi_value init(napi_env env, bool isSync = false) { 18 | napi_value f; 19 | napi_create_function(env, NULL, 0, isSync ? sync : async, NULL, &f); 20 | return f; 21 | } 22 | 23 | private: 24 | const struct cbdata { 25 | napi_async_work work; 26 | napi_ref self; 27 | napi_ref cb; 28 | wchar_t* path; 29 | bool create; 30 | bool result; 31 | }; 32 | static napi_value sync(napi_env env, napi_callback_info info) { 33 | napi_value result; 34 | napi_get_new_target(env, info, &result); 35 | if (result) { 36 | result = NULL; 37 | // napi_throw_error(env, SYB_EXP_INVAL, SYB_ERR_NOT_A_CONSTRUCTOR); 38 | } else { 39 | napi_value argv[2]; 40 | size_t argc = 2; 41 | napi_get_cb_info(env, info, &argc, argv, NULL, NULL); 42 | if (argc < 1) { 43 | // napi_throw_error(env, SYB_EXP_INVAL, SYB_ERR_WRONG_ARGUMENTS); 44 | } else { 45 | size_t str_len; 46 | napi_value tmp; 47 | napi_coerce_to_string(env, argv[0], &tmp); 48 | napi_get_value_string_utf16(env, tmp, NULL, 0, &str_len); 49 | str_len += 1; 50 | wchar_t* path = new wchar_t[str_len]; 51 | napi_get_value_string_utf16(env, tmp, (char16_t*)path, str_len, NULL); 52 | bool create = false; 53 | if (argc > 1) { 54 | napi_coerce_to_bool(env, argv[1], &tmp); 55 | napi_get_value_bool(env, tmp, &create); 56 | } 57 | napi_get_boolean(env, func(path, create), &result); 58 | delete[] path; 59 | } 60 | } 61 | return result; 62 | } 63 | static napi_value async(napi_env env, napi_callback_info info) { 64 | napi_value result; 65 | napi_get_new_target(env, info, &result); 66 | if (result) { 67 | result = NULL; 68 | // //napi_throw_error(env, SYB_EXP_INVAL, SYB_ERR_NOT_A_CONSTRUCTOR); 69 | } else { 70 | napi_value argv[3], self; 71 | size_t argc = 3; 72 | napi_get_cb_info(env, info, &argc, argv, &self, NULL); 73 | if (argc >= 2) { 74 | napi_valuetype t; 75 | napi_typeof(env, argv[1], &t); 76 | if (t == napi_function) { 77 | cbdata* data = new cbdata; 78 | data->create = false; 79 | size_t str_len; 80 | napi_value tmp; 81 | napi_create_reference(env, argv[1], 1, &data->cb); 82 | napi_create_reference(env, self, 1, &data->self); 83 | napi_coerce_to_string(env, argv[0], &tmp); 84 | napi_get_value_string_utf16(env, tmp, NULL, 0, &str_len); 85 | str_len += 1; 86 | data->path = new wchar_t[str_len]; 87 | napi_get_value_string_utf16( 88 | env, tmp, (char16_t*)data->path, str_len, NULL); 89 | if (argc > 2) { 90 | napi_coerce_to_bool(env, argv[2], &tmp); 91 | napi_get_value_bool(env, tmp, &data->create); 92 | } 93 | napi_create_string_latin1( 94 | env, "fswin.ntfs.setSparse", NAPI_AUTO_LENGTH, &tmp); 95 | napi_create_async_work( 96 | env, NULL, tmp, execute, complete, data, &data->work); 97 | if (napi_queue_async_work(env, data->work) == napi_ok) { 98 | napi_get_boolean(env, true, &result); 99 | } else { 100 | napi_get_boolean(env, false, &result); 101 | napi_delete_reference(env, data->cb); 102 | napi_delete_reference(env, data->self); 103 | napi_delete_async_work(env, data->work); 104 | delete[] data->path; 105 | delete data; 106 | } 107 | } 108 | } 109 | if (!result) { 110 | // //napi_throw_error(env, SYB_EXP_INVAL, SYB_ERR_WRONG_ARGUMENTS); 111 | } 112 | } 113 | return result; 114 | } 115 | static void execute(napi_env env, void* data) { 116 | cbdata* d = (cbdata*)data; 117 | d->result = func(d->path, d->create); 118 | } 119 | static void complete(napi_env env, napi_status status, void* data) { 120 | cbdata* d = (cbdata*)data; 121 | delete[] d->path; 122 | napi_value cb, self, argv; 123 | napi_get_reference_value(env, d->cb, &cb); 124 | napi_get_reference_value(env, d->self, &self); 125 | napi_get_boolean(env, status == napi_ok && d->result, &argv); 126 | napi_call_function(env, self, cb, 1, &argv, NULL); 127 | napi_delete_reference(env, d->cb); 128 | napi_delete_reference(env, d->self); 129 | napi_delete_async_work(env, d->work); 130 | delete d; 131 | } 132 | }; 133 | 134 | static napi_value Init(napi_env env, napi_value exports) { 135 | 136 | napi_set_named_property(env, exports, "setSparse", setSparse::init(env)); 137 | 138 | napi_set_named_property( 139 | env, exports, "setSparseSync", setSparse::init(env, true)); 140 | 141 | return exports; 142 | } 143 | 144 | NAPI_MODULE(NODE_GYP_MODULE_NAME, Init); 145 | -------------------------------------------------------------------------------- /source/测试/async_work_promise.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | typedef struct { 10 | napi_async_work work; 11 | napi_deferred deferred; 12 | vector data; 13 | } PromiseData; 14 | 15 | // 工作线程 上面运行的函数 16 | static void ExecuteWork(napi_env env, void* data) { 17 | PromiseData* addon_data = (PromiseData*)data; 18 | } 19 | 20 | // ExecuteWork 运行结束的时候会执行此 21 | static void WorkComplete(napi_env env, napi_status status, void* data) { 22 | if (status != napi_ok) { 23 | return; 24 | } 25 | 26 | PromiseData* addon_data = (PromiseData*)data; 27 | napi_value array; 28 | 29 | napi_create_array(env, &array); 30 | 31 | napi_resolve_deferred(env, addon_data->deferred, array); 32 | 33 | // 清理与此运行关联的工作环境 34 | napi_delete_async_work(env, addon_data->work); 35 | 36 | // 将这两个值都设置为NULL,这样JavaScript可以启动新的线程运行。 37 | addon_data->work = NULL; 38 | addon_data->deferred = NULL; 39 | } 40 | 41 | /**创建一个 promise对象*/ 42 | static napi_value StartWork(napi_env env, napi_callback_info info) { 43 | napi_value work_name, promise; 44 | PromiseData* addon_data; 45 | 46 | // 获取每个插件的数据。 47 | napi_get_cb_info(env, info, NULL, NULL, NULL, (void**)(&addon_data)); 48 | 49 | // 添加一个工作线程的 结构体 50 | // addon_data->work; 51 | 52 | // 创建一个字符串来描述这个异步操作。 53 | 54 | napi_create_string_utf8(env, 55 | "Node-API Deferred Promise from Async Work Item", 56 | NAPI_AUTO_LENGTH, 57 | &work_name); 58 | 59 | // 创建一个延迟的promise对象,在完成时我们将解决它 60 | napi_create_promise(env, &(addon_data->deferred), &promise); 61 | 62 | // 创建一个异步工作项,传递插件数据,这将使 63 | // 工作线程访问上述创建的延迟的 promise对象 64 | napi_create_async_work(env, 65 | NULL, 66 | work_name, 67 | ExecuteWork, 68 | WorkComplete, 69 | addon_data, 70 | &(addon_data->work)); 71 | 72 | // 添加进node的异步队列 73 | napi_queue_async_work(env, addon_data->work); 74 | 75 | return promise; 76 | } 77 | 78 | /** 79 | * @brief 释放内存 80 | * 81 | * @param env 82 | * @param data 83 | * @param hint 84 | */ 85 | static void addon_getting_unloaded(napi_env env, void* data, void* hint) { 86 | PromiseData* addon_data = (PromiseData*)data; 87 | // addon_data->work == NULL; 88 | free(addon_data); 89 | } 90 | 91 | static napi_value Init(napi_env env, napi_value exports) { 92 | PromiseData* addon_data = (PromiseData*)malloc(sizeof(*addon_data)); 93 | addon_data->work = NULL; 94 | 95 | // 导出模块 96 | napi_property_descriptor BIND_NAPI_METHOD[] = { 97 | {"startWork", 98 | NULL, 99 | StartWork, 100 | NULL, 101 | NULL, 102 | NULL, 103 | napi_default, 104 | addon_data}, 105 | }; 106 | 107 | napi_define_properties(env, 108 | exports, 109 | sizeof(BIND_NAPI_METHOD) / sizeof(BIND_NAPI_METHOD[0]), 110 | BIND_NAPI_METHOD); 111 | 112 | return exports; 113 | } 114 | 115 | NAPI_MODULE(NODE_GYP_MODULE_NAME, Init); 116 | -------------------------------------------------------------------------------- /source/测试/async_work_promise_namespace.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | namespace PromiseFun 10 | { 11 | 12 | typedef struct 13 | { 14 | // 工作环境 15 | napi_async_work work; 16 | // napi处理延迟的内联 17 | napi_deferred deferred; 18 | // 数据体的内存 必须是固定大小的值 不能动态调整内存 要多大的空间需要提前注册函数时候注册内存 19 | } PromiseData; 20 | 21 | /** 22 | * @brief 处理数据更新 这里是异步的 23 | * 24 | * @param env 25 | * @param data 26 | */ 27 | void asyncWorkFun(napi_env env, void *data) 28 | { 29 | PromiseData *addon_data = (PromiseData *)data; 30 | } 31 | 32 | /** 33 | * @brief 运行结束的时候会执行此 这里是同步的 34 | * 35 | * @param env 36 | * @param status 37 | * @param data 38 | */ 39 | void completeWork(napi_env env, napi_status status, void *data) 40 | { 41 | if (status != napi_ok) 42 | { 43 | return; 44 | } 45 | 46 | PromiseData *addon_data = (PromiseData *)data; 47 | napi_value result; 48 | 49 | napi_create_array(env, &result); 50 | 51 | napi_resolve_deferred(env, addon_data->deferred, result); 52 | 53 | // 清理与此运行关联的工作环境 54 | napi_delete_async_work(env, addon_data->work); 55 | 56 | // 将这两个值都设置为NULL,这样JavaScript可以启动新的线程运行。 57 | addon_data->work = NULL; 58 | addon_data->deferred = NULL; 59 | } 60 | 61 | /** 62 | * @brief 创建一个 promise对象 63 | * 64 | * @param env 65 | * @param info 66 | * @return napi_value 67 | */ 68 | napi_value startWork(napi_env env, napi_callback_info info) 69 | { 70 | napi_value work_name, promise; 71 | PromiseData *addon_data; 72 | 73 | string work_message = string(__FUNCTION__).append(" work_message -> "); 74 | 75 | // 获取插件的工作数据。 76 | napi_get_cb_info(env, info, NULL, NULL, NULL, (void **)(&addon_data)); 77 | 78 | // 添加一个工作线程的 结构体 79 | 80 | if (addon_data->work != NULL) 81 | { 82 | work_message.append("error < Promise workspace has not been released. > "); 83 | napi_throw_error(env, "TASK_CONFLICT", work_message.c_str()); 84 | return NULL; 85 | } 86 | 87 | // 创建一个字符串来描述这个异步操作。 88 | 89 | work_message.append("Node-API Deferred Promise from Async Work Item"); 90 | napi_create_string_utf8( 91 | env, work_message.c_str(), work_message.length(), &work_name); 92 | 93 | // 创建一个延迟的promise对象,在完成时我们将解决它 94 | napi_create_promise(env, &(addon_data->deferred), &promise); 95 | 96 | // 创建一个异步工作项,传递插件数据,这将使 97 | // 工作线程访问上述创建的延迟的 promise对象 98 | napi_create_async_work(env, 99 | NULL, 100 | work_name, 101 | asyncWorkFun, 102 | completeWork, 103 | addon_data, 104 | &(addon_data->work)); 105 | 106 | // 添加进node的异步队列 107 | napi_queue_async_work(env, addon_data->work); 108 | 109 | return promise; 110 | } 111 | 112 | /** 113 | * @brief 释放内存 请注意这里是模块卸载时候才执行 114 | * 115 | * @param env 116 | * @param data 117 | * @param hint 118 | */ 119 | void gcWork(napi_env env, void *data, void *hint) 120 | { 121 | PromiseData *addon_data = (PromiseData *)data; 122 | 123 | free(addon_data); 124 | } 125 | 126 | /** 127 | * @brief 导出这个异步函数 128 | * 129 | * @param env 130 | * @param exports 131 | * @param name 132 | */ 133 | void exports(napi_env env, napi_value exports, string name) 134 | { 135 | PromiseData *addon_data = (PromiseData *)malloc(sizeof(*addon_data)); 136 | 137 | addon_data->work = NULL; 138 | 139 | napi_value exported_function; 140 | 141 | napi_create_function(env, 142 | name.c_str(), 143 | NAPI_AUTO_LENGTH, 144 | startWork, 145 | addon_data, 146 | &exported_function); 147 | 148 | napi_set_named_property(env, exports, name.c_str(), exported_function); 149 | 150 | // 回收 151 | napi_wrap(env, exports, addon_data, gcWork, NULL, NULL); 152 | } 153 | 154 | } // namespace PromiseFun 155 | 156 | napi_value Init(napi_env env, napi_value exports) 157 | { 158 | PromiseFun::exports(env, exports, string("aaaa")); 159 | return exports; 160 | } 161 | 162 | NAPI_MODULE(NODE_GYP_MODULE_NAME, Init); 163 | -------------------------------------------------------------------------------- /source/测试/enumAllProcess.js: -------------------------------------------------------------------------------- 1 | let HMC_x64 = require("F:/515/hmc-win32/source/CPP/build/Release/HMC_x64.node"); 2 | 3 | let cp_id = HMC_x64.enumAllProcess(); 4 | 5 | let p = setInterval(_=>{ 6 | _ = HMC_x64.enumAllProcessPolling(cp_id); 7 | 8 | if(_){ 9 | // console.log(_) ; 10 | } 11 | },15); 12 | -------------------------------------------------------------------------------- /source/测试/find_win.js: -------------------------------------------------------------------------------- 1 | let HMC_x64 = require("../CPP/build/Release/HMC_x64.node"); 2 | 3 | console.log( 4 | // findWindow (class?:string|null , title?:string|null) 5 | `[findWindow] [ class , *title ] -> ${HMC_x64.findWindow(null, "模板助手")}\n`, 6 | `[findWindow] [*class , *title ] -> ${HMC_x64.findWindow("Chrome_WidgetWin_1", "模板助手")}\n`, 7 | `[findWindow] [*class , title ] -> ${HMC_x64.findWindow("Chrome_WidgetWin_1", null)} 8 | ----------------------------------------------------------------------------------\n`, 9 | 10 | // findWindowEx (hWndParent:number|null ,hWndChildAfter:number|null , class:string|null , title:string|null ) 11 | `[findWindowEx] [ ? , ? , ? , title] -> ${HMC_x64.findWindowEx(null, null, null, "模板助手")}\n`, 12 | `[findWindowEx] [ ? , ? , class , title] -> ${HMC_x64.findWindowEx(null, null, "Chrome_WidgetWin_1", "模板助手")}\n`, 13 | `[findWindowEx] [ Parent , ? , class , ? , ? ] -> ${HMC_x64.findWindowEx(396976, null, "Chrome_RenderWidgetHostHWND", null)}\n`, 14 | `[findWindowEx] [ Parent , ChildAfter , class , ? , ? ] -> ${HMC_x64.findWindowEx(49844, 131754, "DirectUIHWND", null)} 15 | ----------------------------------------------------------------------------------\n`, 16 | 17 | ); 18 | 19 | // console.log( 20 | // // findAllWindow (class:string|null , title:string|null , isWindow:boolean|null = true , isCaseSensitive:boolean|null = true ) 21 | // `[findAllWindow] [ ? , title ? ? ] -> ${JSON.stringify(HMC_x64.findAllWindow(null, "模板助手", null, null))}\n`, 22 | // `[findAllWindow] [ class , title ? ? ] -> ${JSON.stringify(HMC_x64.findAllWindow("Chrome_WidgetWin_1", "模板助手", null, null))}\n`, 23 | // `[findAllWindow][class , ? ? ? ] -> ${JSON.stringify(HMC_x64.findAllWindow("Chrome_RenderWidgetHostHWND", null, null, null))}\n`, 24 | // `[findAllWindow][class , ? false ? ] -> ${JSON.stringify(HMC_x64.findAllWindow("Chrome_RenderWidgetHostHWND", null, false, null))}\n`, 25 | // `[findAllWindow][class , ? false true ]-> ${JSON.stringify(HMC_x64.findAllWindow("CHRome_RenderWidgetHostHWND", null, false, true))}\n`, 26 | // `[findAllWindow][class , ? false false ]-> ${JSON.stringify(HMC_x64.findAllWindow("CHRome_RenderWidgetHostHWND", null, false, false))}\n 27 | // ---------------------------------------------------------------------------------- 28 | // ` 29 | // ); -------------------------------------------------------------------------------- /source/测试/main.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import { HMC } from "../../"; 3 | export interface Native { 4 | /** 5 | * 设置注册表值 (提供了初级和低级操作) 6 | * @param Hive 根目录 7 | * @param folderPath 目录路径 8 | * @param keyName 值键 9 | * @param data 数据体 10 | * - null 设置空值 11 | * - string 约 2^31 - 1 个字符 (2GB) 但是不建议存储过大数据 会出问题 12 | * - number DWORD 标准范围约为 0(0x0) 到 4294967295(0xffffffff) (即 2^32 - 1) 13 | * - bigint QWORD 标准范围约为 0n(0x0) 到 18446744073709551615n (0xffffffffffffffff)(即 2^64 - 1) 14 | * - boolean 布尔 以DWORD状态存储 范围 0-1 15 | * - Buffer 二进制 1024KB 以内 16 | * - Date 时间戳 以浮点二进制存储 17 | * - string[] 文本数组 REG_MULTI_SZ格式 允许存储空文本但是不建议 (因为非标准) 但是数组末尾的元素是空文本会被清空 18 | * @param type 类型 19 | * - true 文本时将转义到转义类型 20 | * - HMC.REG_TYPE 强制转义 仅限二进制类型 21 | */ 22 | setRegistrValue(Hive: HMC.HKEY, folderPath: string, keyName: string | null, data: null | number | bigint | boolean | Buffer | Date | string | string[], type: undefined | boolean | HMC.REG_TYPE): boolean; 23 | } 24 | /** 25 | * 设置注册表值 26 | * @param Hive 根目录 27 | * @param folderPath 目录路径 28 | * @param keyName 值键 29 | * @param data 数据体 30 | * @param is_expand 是否让其可以被自动转义 例如 %temp%/123 -> c:.../temp/123 31 | */ 32 | export declare function setRegistrValue(Hive: HMC.HKEY, folderPath: string, keyName: string | null, data: string, is_expand?: boolean): boolean; 33 | /** 34 | * 设置注册表值 35 | * @param Hive 根目录 36 | * @param folderPath 目录路径 37 | * @param keyName 值键 38 | * @param data 数据体 39 | * @param to_type 转义类型 详见 HMC.REG_TYPE https://learn.microsoft.com/zh-cn/windows/win32/sysinfo/registry-value-types 40 | */ 41 | export declare function setRegistrValue(Hive: HMC.HKEY, folderPath: string, keyName: string | null, data: Buffer, to_type?: HMC.REG_TYPE): boolean; 42 | /** 43 | * 设置注册表值 44 | * @param Hive 根目录 45 | * @param folderPath 目录路径 46 | * @param keyName 值键 47 | */ 48 | export declare function setRegistrValue(Hive: HMC.HKEY, folderPath: string, keyName: string | null): boolean; 49 | /** 50 | * 设置注册表值 文本数组 51 | * - REG_MULTI_SZ格式 52 | * ? 允许存储空文本但是不建议 (因为非标准) 但是数组末尾的元素是空文本会被清空 53 | * @param Hive 根目录 54 | * @param folderPath 目录路径 55 | * @param keyName 值键 56 | */ 57 | export declare function setRegistrValue(Hive: HMC.HKEY, folderPath: string, keyName: string, data: string[]): boolean; 58 | /** 59 | * 设置注册表值 60 | * @param Hive 根目录 61 | * @param folderPath 目录路径 62 | * @param keyName 值键 63 | * @param data 数据体 64 | * - number DWORD 标准范围约为 0(0x0) 到 4294967295(0xffffffff) (即 2^32 - 1) 65 | * - bigint QWORD 标准范围约为 0n(0x0) 到 18446744073709551615n (0xffffffffffffffff)(即 2^64 - 1) 66 | * - boolean 布尔 以DWORD状态存储 范围 0-1 67 | * - Buffer 二进制 1024KB 以内 68 | * - Date 时间戳 以浮点二进制存储 69 | */ 70 | export declare function setRegistrValue(Hive: HMC.HKEY, folderPath: string, keyName: string | null, data: number | bigint | boolean | Date): boolean; 71 | -------------------------------------------------------------------------------- /source/测试/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var _a; 3 | Object.defineProperty(exports, "__esModule", { value: true }); 4 | exports.setRegistrValue = void 0; 5 | const log4js = require("log4js"); 6 | const __1 = require("../../"); 7 | log4js.configure({ appenders: { cheese: { type: "file", filename: "cheese.log" } }, categories: { default: { appenders: ["cheese"], level: "error" } } }); 8 | const log = log4js.getLogger("cheese"); 9 | process.exitCode = 666; 10 | console.time("load hmc dll"); 11 | let native = setTimeout(() => { 12 | native = require(process.argv.at(-1) || ""); 13 | }); 14 | console.timeEnd("load hmc dll"); 15 | function setRegistrValue(Hive, folderPath, keyName, data = null, type = undefined) { 16 | const hive_value = __1.ref.string(Hive || "HKEY_CURRENT_USER"); 17 | // 虽然不符合规范 都是根目录下是允许写数据的 18 | const folder_path = __1.ref.string(folderPath || "").replace(/[\\\/]+/g, "\\"); 19 | const key_name = __1.ref.string(keyName || ""); 20 | let data_output = data; 21 | let types = undefined; 22 | let is_type_valid = false; 23 | // !这里有个判断文件夹的逻辑 因为设置值不会创建目录 24 | // 处理转义 25 | if (Buffer.isBuffer(data_output)) { 26 | if (typeof type == "number") { 27 | types = type; 28 | } 29 | } 30 | else if (typeof data_output == "string") { 31 | if (typeof type == "boolean" || type == 2) { 32 | types = type ? true : false; 33 | } 34 | } 35 | // 判断值有效 36 | if (typeof data_output == "boolean" || 37 | typeof data_output == "string" || 38 | typeof data_output == "number" || 39 | typeof data_output == "bigint" || 40 | data_output instanceof Date || 41 | data_output === null || 42 | Array.isArray(data_output) || 43 | Buffer.isBuffer(data_output)) { 44 | is_type_valid = true; 45 | } 46 | else 47 | return is_type_valid; 48 | // 提前强转 虽然c++也会强转 49 | if (typeof data_output == "boolean") { 50 | data_output = data_output ? 1 : 0; 51 | } 52 | // 万恶的NAN 53 | if (typeof data_output == "number" && isNaN(data_output)) { 54 | data_output = null; 55 | } 56 | // 超过0xffffffff 强制到0xffffffff 57 | if (typeof data_output == "number" && data_output > 0xffffffff) { 58 | data_output = 0xffffffff; 59 | } 60 | if (data_output && !Buffer.isBuffer(data_output) && Array.isArray(data_output)) { 61 | data_output = __1.ref.stringArray(data_output); 62 | } 63 | // 处理 负数 浮点 的逻辑 64 | return native.setRegistrValue(hive_value, folder_path, key_name, data_output, types); 65 | } 66 | exports.setRegistrValue = setRegistrValue; 67 | (async function main() { 68 | // console.time("hmc.getProcessCwd()->"); 69 | // console.log("hmc.getProcessCwd()->", await getProcessCwd2(process.pid)); 70 | // console.timeEnd("hmc.getProcessCwd()->"); 71 | // console.time("hmc.getProcessCwdSync()->"); 72 | // console.log("hmc.getProcessCwdSync()->", getProcessCwd2Sync(process.pid)); 73 | // console.timeEnd("hmc.getProcessCwdSync()->"); 74 | // console.time("hmc.getProcessCommand()->"); 75 | // console.log("hmc.getProcessCommand()->", await getProcessCommand2(process.pid)); 76 | // console.timeEnd("hmc.getProcessCommand()->"); 77 | // console.time("hmc.getProcessCommand()->"); 78 | // console.log("hmc.getProcessCommand()->", getProcessCommand2Sync(process.pid)); 79 | // console.timeEnd("hmc.getProcessCommand()->"); 80 | // const setLimitMouse = setLimitMouseRange(5000,1,1,1,500); 81 | // hmc.Auto.mouseHook.on("mouse",()=>{}); 82 | // hmc.Auto.mouseHook.start(); 83 | // 预设置对比 84 | // let _int64: bigint = native.getRegistrQword("HKEY_CURRENT_USER", "hmc_temp", "_int64"); 85 | // console.log("_int64-> %d", _int64, _int64 == BigInt(151162666161616)); 86 | // let _int32 = native.getRegistrDword("HKEY_CURRENT_USER", "hmc_temp", "_int32"); 87 | // console.log("_int32-> %d", _int32, _int32 == 789894594); 88 | // let _WIDE_CHAR = native.getStringRegKey("HKEY_CURRENT_USER", "hmc_temp", "_WIDE_CHAR"); 89 | // console.log("_WIDE_CHAR-> ", _WIDE_CHAR, _WIDE_CHAR == "宽字符中文 emoji🗺️6"); 90 | // let int32_buff = native.getRegistrBuffValue("HKEY_CURRENT_USER", "hmc_temp", "int32"); 91 | // console.log("int32_buff-> ", int32_buff); 92 | // let temp:any = [ 93 | // [native.setRegistrDword("HKEY_CURRENT_USER","hmc_temp","TEMP1",626641614), 94 | // native.getRegistrDword("HKEY_CURRENT_USER","hmc_temp","TEMP1")==626641614], 95 | // [native.setRegistrQword("HKEY_CURRENT_USER","hmc_temp","TEMP2",BigInt("6262235346436457641614")), 96 | // native.getRegistrQword("HKEY_CURRENT_USER","hmc_temp","TEMP2")==BigInt("6262235346436457641614")], 97 | // [native.setRegistrKey("HKEY_CURRENT_USER","hmc_temp","TEMP3","⚠️你正在尝试获取值,如果值长得像值 值又正巧等于值那么他就会是个正确的值⚠️⚠️⚠️⚠️⚠️⚠️⚠️12345567890🔄"), 98 | // native.getStringRegKey("HKEY_CURRENT_USER","hmc_temp","TEMP3")=="⚠️你正在尝试获取值,如果值长得像值 值又正巧等于值那么他就会是个正确的值⚠️⚠️⚠️⚠️⚠️⚠️⚠️12345567890🔄"], 99 | // [native.setRegistrKey("HKEY_CURRENT_USER","hmc_temp","TEMP4","⚠️你正在尝试获取值,如果值长得像值 值又正巧等于值那么他就会是个正确的值⚠️⚠️⚠️⚠️⚠️⚠️⚠️12345567890🔄"), 100 | // native.getStringRegKey("HKEY_CURRENT_USER","hmc_temp","TEMP4")=="⚠️你正在尝试获取值,如果值长得像值 值又正巧等于值那么他就会是个正确的值⚠️⚠️⚠️⚠️⚠️⚠️⚠️12345567890🔄"], 101 | // // [native.setRegistrKey("HKEY_CURRENT_USER","hmc_temp","TEMP4",Buffer.from("⚠️你正在尝试获取值,如果值长得像值 值又正巧等于值那么他就会是个正确的值⚠️⚠️⚠️⚠️⚠️⚠️⚠️12345567890🔄","utf-8")), 102 | // // native.getStringRegKey("HKEY_CURRENT_USER","hmc_temp","TEMP4")=="⚠️你正在尝试获取值,如果值长得像值 值又正巧等于值那么他就会是个正确的值⚠️⚠️⚠️⚠️⚠️⚠️⚠️12345567890🔄"], 103 | // native.createRegistrFolder("HKEY_CURRENT_USER\\hmc_temp"), 104 | // native.getRegistrFolderStat("HKEY_CURRENT_USER","hmc_temp"), 105 | // native.getRegistrValueStat("HKEY_CURRENT_USER","hmc_temp") 106 | // ]; 107 | // Buffer.from( +(new Date()),"binary") 108 | // console.log(temp); 109 | })().catch(console.error); 110 | // 调试中阻止进程退出 111 | if ((_a = require("node:inspector")) === null || _a === void 0 ? void 0 : _a.url()) { 112 | setInterval(function () { }, 500000); 113 | } 114 | -------------------------------------------------------------------------------- /source/测试/new-fun-promise.cc: -------------------------------------------------------------------------------- 1 | #include "./main.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace PromiseFunction 12 | { 13 | 14 | std::any resultSend = std::any(); 15 | std::vector arguments_list = {}; 16 | napi_value format_to_js_value(napi_env env, std::any result_any_data); 17 | std::any PromiseWorkFunc(std::vector arguments_list); 18 | 19 | class PromiseFunction 20 | { 21 | private: 22 | // 函数名称 23 | static constexpr std::atomic work = NULL; 24 | static constexpr std::atomic deferred = NULL; 25 | 26 | public: 27 | static void exports(napi_env env, napi_value exports, std::string name) 28 | { 29 | napi_value exported_function; 30 | 31 | napi_create_function(env, 32 | name.c_str(), 33 | name.length(), 34 | startWork, 35 | NULL, 36 | &exported_function); 37 | 38 | napi_set_named_property(env, exports, name.c_str(), exported_function); 39 | 40 | // 注册变量传递 41 | napi_wrap(env, exports, NULL, NULL, NULL, NULL); 42 | } 43 | 44 | static void exportsSync(napi_env env, napi_value exports, std::string name) 45 | { 46 | napi_value exported_function; 47 | 48 | napi_create_function(env, 49 | name.c_str(), 50 | name.length(), 51 | startSync, 52 | NULL, 53 | &exported_function); 54 | 55 | napi_set_named_property(env, exports, name.c_str(), exported_function); 56 | 57 | // 注册变量传递 58 | napi_wrap(env, exports, NULL, NULL, NULL, NULL); 59 | } 60 | 61 | protected: 62 | /** 63 | * @brief 处理数据更新 这里是异步的 64 | * 65 | * @param env 66 | * @param data 67 | */ 68 | static void asyncWorkFun(napi_env env, void* data) 69 | { 70 | resultSend = PromiseWorkFunc(arguments_list); 71 | } 72 | 73 | /** 74 | * @brief 运行结束的时候会执行此 这里是同步的 75 | * 76 | * @param env 77 | * @param status 78 | * @param data 79 | */ 80 | static void completeWork(napi_env env, napi_status status, void* data) 81 | { 82 | if (status != napi_ok) 83 | return; 84 | 85 | napi_resolve_deferred(env, deferred, format_to_js_value(env, resultSend)); 86 | 87 | // 清理与此运行关联的工作环境 88 | napi_delete_async_work(env, work); 89 | 90 | deferred._Storage._Value = NULL; 91 | work._Storage._Value = NULL; 92 | resultSend.reset(); 93 | resultSend = std::any(); 94 | arguments_list.clear(); 95 | arguments_list.resize(0); 96 | } 97 | 98 | static napi_value startWork(napi_env env, napi_callback_info info) 99 | { 100 | napi_value result, work_name, promise; 101 | napi_get_null(env, &result); 102 | 103 | std::string work_message = std::string(__FUNCTION__).append(" work_message -> "); 104 | 105 | // 上个函数还没结束 106 | if (work != NULL) 107 | { 108 | work_message.append("error < Promise workspace has not been released. > "); 109 | napi_throw_error(env, "TASK_CONFLICT", work_message.c_str()); 110 | return result; 111 | } 112 | 113 | // 创建一个字符串来描述这个异步操作。 114 | 115 | work_message.append("Node-API Deferred Promise from Async Work Item"); 116 | 117 | napi_create_string_utf8(env, work_message.c_str(), work_message.length(), &work_name); 118 | 119 | napi_async_work addon_napi_async_work = NULL; 120 | napi_deferred addon_deferred = NULL; 121 | 122 | // 创建一个延迟的promise对象,在完成时我们将解决它 123 | if (napi_create_promise(env, &addon_deferred, &promise) != napi_ok) 124 | { 125 | work_message.append("error < Promise Creation failed. > "); 126 | napi_throw_error(env, "Creation_failed", work_message.c_str()); 127 | return result; 128 | }; 129 | 130 | auto input = hmc_NodeArgsValue(env, info).get_values(); 131 | 132 | for (size_t i = 0; i < input.size(); i++) 133 | { 134 | arguments_list.push_back(input.at(i)); 135 | } 136 | 137 | // 创建一个异步工作项,传递插件数据,这将使 138 | // 工作线程访问上述创建的延迟的 promise对象 139 | if (napi_create_async_work(env, 140 | NULL, 141 | work_name, 142 | asyncWorkFun, 143 | completeWork, NULL, &addon_napi_async_work) != napi_ok) 144 | { 145 | work_message.append("error < Promise Creation work async failed. > "); 146 | napi_throw_error(env, "Creation_failed", work_message.c_str()); 147 | return result; 148 | }; 149 | 150 | // 添加进node的异步队列 151 | napi_queue_async_work(env, addon_napi_async_work); 152 | 153 | work._Storage._Value = addon_napi_async_work; 154 | deferred._Storage._Value = addon_deferred; 155 | 156 | return promise; 157 | } 158 | 159 | static napi_value startSync(napi_env env, napi_callback_info info) 160 | { 161 | napi_value result, work_name, promise; 162 | napi_get_null(env, &result); 163 | 164 | std::any resultSend = std::any(); 165 | std::vector arguments_list = {}; 166 | 167 | auto input = hmc_NodeArgsValue(env, info).get_values(); 168 | 169 | for (size_t i = 0; i < input.size(); i++) 170 | { 171 | arguments_list.push_back(input.at(i)); 172 | } 173 | 174 | try 175 | { 176 | std::any data = PromiseWorkFunc(arguments_list); 177 | return format_to_js_value(env, data); 178 | } 179 | catch (const std::exception& err) 180 | { 181 | napi_throw_error(env, "catch (const std::exception&)", err.what()); 182 | return result; 183 | } 184 | catch (...) 185 | { 186 | napi_throw_error(env, "catch (...)", ""); 187 | return result; 188 | } 189 | 190 | return result; 191 | } 192 | }; 193 | 194 | void exports(napi_env env, napi_value exports, std::string name) 195 | { 196 | (new PromiseFunction)->exports(env, exports, name.c_str()); 197 | } 198 | 199 | void exportsSync(napi_env env, napi_value exports, std::string name) 200 | { 201 | (new PromiseFunction)->exportsSync(env, exports, name.c_str()); 202 | } 203 | 204 | }; 205 | 206 | 207 | std::any PromiseFunction::PromiseWorkFunc(std::vector arguments_list) { 208 | std::any result = std::any(); 209 | return result; 210 | } 211 | 212 | 213 | napi_value PromiseFunction::format_to_js_value(napi_env env, std::any result_any_data) { 214 | napi_value result; 215 | napi_get_null(env, &result); 216 | 217 | if (!result_any_data.has_value()) { 218 | return result; 219 | } 220 | 221 | return result; 222 | } 223 | 224 | 225 | napi_value Init(napi_env env, napi_value exports) 226 | { 227 | 228 | PromiseFunction::exports(env, exports, "startThread"); 229 | PromiseFunction::exportsSync(env, exports, "startThreadSync"); 230 | 231 | return exports; 232 | } 233 | 234 | NAPI_MODULE(NODE_GYP_MODULE_NAME, Init); 235 | -------------------------------------------------------------------------------- /source/测试/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "@types/fs-extra": "^11.0.4", 4 | "@types/node": "^16.18.66" 5 | }, 6 | "dependencies": { 7 | "fs-extra": "^11.2.0", 8 | "hmc-shake": "^1.0.2", 9 | "hmc-win32": "^1.4.3", 10 | "jsonfm": "^1.0.2", 11 | "log4js": "^6.9.1" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /source/测试/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "skipLibCheck": true, 4 | /* Basic Options */ 5 | // "moduleResolution": "node", 6 | // "importHelpers": true, 7 | // "skipLibCheck": true, 8 | // "resolveJsonModule": true, 9 | // "noImplicitAny": false, 10 | "target": "ES2017" /* target用于指定编译之后的版本目标: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, 11 | "module": "commonjs" /* 用来指定要使用的模块标准: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, 12 | // "lib": [ "ES2021"] /* lib用于指定要包含在编译中的库文件 */, 13 | // "allowJs": true, /* allowJs设置的值为true或false,用来指定是否允许编译js文件,默认是false,即不编译js文件 */ 14 | // "checkJs": true, /* checkJs的值为true或false,用来指定是否检查和报告js文件中的错误,默认是false */ 15 | // "jsx": "preserve", /* 指定jsx代码用于的开发环境: 'preserve', 'react-native', or 'react'. */ 16 | // "declaration": true, /* declaration的值为true或false,用来指定是否在编译的时候生成相应的".d.ts"声明文件。如果设为true,编译每个ts文件之后会生成一个js文件和一个声明文件。但是declaration和allowJs不能同时设为true */ 17 | // "declarationMap": true, /* 值为true或false,指定是否为声明文件.d.ts生成map文件 */ 18 | "sourceMap": false /* sourceMap的值为true或false,用来指定编译时是否生成.map文件 */, 19 | // "outFile": "./", /* outFile用于指定将输出文件合并为一个文件,它的值为一个文件路径名。比如设置为"./dist/main.js",则输出的文件为一个main.js文件。但是要注意,只有设置module的值为amd和system模块时才支持这个配置 */ 20 | // "outDir": "", 21 | /* outDir用来指定输出文件夹,值为一个文件夹路径字符串,输出的文件都将放置在这个文件夹 */ 22 | // "rootDir": "./", /* 用来指定编译文件的根目录,编译器会在根目录查找入口文件,如果编译器发现以rootDir的值作为根目录查找入口文件并不会把所有文件加载进去的话会报错,但是不会停止编译 */ 23 | // "composite": true, /* 是否编译构建引用项目 */ 24 | // "incremental": true, /* 是否启用增量编译*/ 25 | //"tsBuildInfoFile": "./builds/Tsc-BuildInfoFile" /* 指定文件用来存储增量编译信息 */, 26 | "removeComments": false /* removeComments的值为true或false,用于指定是否将编译后的文件中的注释删掉,设为true的话即删掉注释,默认为false */, 27 | // "noEmit": true, /* 不生成编译文件,这个一般比较少用 */ 28 | // "importHelpers": true, /* importHelpers的值为true或false,指定是否引入tslib里的辅助工具函数,默认为false */ 29 | // "downlevelIteration": true, /* 当target为'ES5' or 'ES3'时,为'for-of', spread, and destructuring'中的迭代器提供完全支持 */ 30 | // "isolatedModules": true, /* isolatedModules的值为true或false,指定是否将每个文件作为单独的模块,默认为true,它不可以和declaration同时设定 */ 31 | 32 | // /* Strict Type-Checking Options */ 33 | "strict": true, 34 | /* strict的值为true或false,用于指定是否启动所有类型检查,如果设为true则会同时开启下面这几个严格类型检查,默认为false */ 35 | // "noImplicitAny": false, /* noImplicitAny的值为true或false,如果我们没有为一些值设置明确的类型,编译器会默认认为这个值为any,如果noImplicitAny的值为true的话。则没有明确的类型会报错。默认值为false */ 36 | // "strictNullChecks": true, /* strictNullChecks为true时,null和undefined值不能赋给非这两种类型的值,别的类型也不能赋给他们,除了any类型。还有个例外就是undefined可以赋值给void类型 */ 37 | // "strictFunctionTypes": true, /* strictFunctionTypes的值为true或false,用于指定是否使用函数参数双向协变检查 */ 38 | // "strictBindCallApply": true, /* 设为true后会对bind、call和apply绑定的方法的参数的检测是严格检测的 */ 39 | // "strictPropertyInitialization": true, /* 设为true后会检查类的非undefined属性是否已经在构造函数里初始化,如果要开启这项,需要同时开启strictNullChecks,默认为false */ 40 | // "noImplicitThis": true, /* 当this表达式的值为any类型的时候,生成一个错误 */ 41 | // "alwaysStrict": true, /* alwaysStrict的值为true或false,指定始终以严格模式检查每个模块,并且在编译之后的js文件中加入"use strict"字符串,用来告诉浏览器该js为严格模式 */ 42 | 43 | // /* Additional Checks */ 44 | // "noUnusedLocals": true, /* 用于检查是否有定义了但是没有使用的变量,对于这一点的检测,使用eslint可以在你书写代码的时候做提示,你可以配合使用。它的默认值为false */ 45 | // "noUnusedParameters": true, /* 用于检查是否有在函数体中没有使用的参数,这个也可以配合eslint来做检查,默认为false */ 46 | // "noImplicitReturns": true, /* 用于检查函数是否有返回值,设为true后,如果函数没有返回值则会提示,默认为false */ 47 | "noFallthroughCasesInSwitch": true /* 用于检查switch中是否有case没有使用break跳出switch,默认为false */, 48 | 49 | // /* Module Resolution Options */ 50 | // "moduleResolution": "node", /* 用于选择模块解析策略,有'node'和'classic'两种类型' */ 51 | // "baseUrl": "./", /* baseUrl用于设置解析非相对模块名称的基本目录,相对模块不会受baseUrl的影响 */ 52 | // "paths": {}, 53 | /* 用于设置模块名称到基于baseUrl的路径映射 */ 54 | // "rootDirs": [], 55 | /* rootDirs可以指定一个路径列表,在构建时编译器会将这个路径列表中的路径的内容都放到一个文件夹中 */ 56 | "typeRoots": ["./node_modules/@types", "@types"], 57 | /* typeRoots用来指定声明文件或文件夹的路径列表,如果指定了此项,则只有在这里列出的声明文件才会被加载 */ 58 | // "types": [], /* types用来指定需要包含的模块,只有在这里列出的模块的声明文件才会被加载进来 */ 59 | "allowSyntheticDefaultImports": true, 60 | /* 用来指定允许从没有默认导出的模块中默认导入 */ 61 | "esModuleInterop": true /* 通过为导入内容创建命名空间,实现CommonJS和ES模块之间的互操作性 */, 62 | "preserveSymlinks": true /* 不把符号链接解析为其真实路径,具体可以了解下webpack和nodejs的symlink相关知识 */, 63 | // /* Source Map Options */ 64 | // "sourceRoot": "", /* sourceRoot用于指定调试器应该找到TypeScript文件而不是源文件位置,这个值会被写进.map文件里 */ 65 | // "mapRoot": "", /* mapRoot用于指定调试器找到映射文件而非生成文件的位置,指定map文件的根路径,该选项会影响.map文件中的sources属性 */ 66 | "inlineSourceMap": false /* 指定是否将map文件的内容和js文件编译在同一个js文件中,如果设为true,则map的内容会以//# sourceMappingURL=然后拼接base64字符串的形式插入在js文件底部 */, 67 | "inlineSources": false /* 用于指定是否进一步将.ts文件的内容也包含到输入文件中 */ 68 | 69 | // /* Experimental Options */ 70 | // "experimentalDecorators": true, /* 用于指定是否启用实验性的装饰器特性 */ 71 | // "emitDecoratorMetadata": true, /* 用于指定是否为装饰器提供元数据支持,关于元数据,也是ES6的新标准,可以通过Reflect提供的静态方法获取元数据,如果需要使用Reflect的一些方法,需要引入ES2015.Reflect这个库 */ 72 | }, 73 | // "files": [], // files可以配置一个数组列表,里面包含指定文件的相对或绝对路径,编译器在编译的时候只会编译包含在files中列出的文件,如果不指定,则取决于有没有设置include选项,如果没有include选项,则默认会编译根目录以及所有子目录中的文件。这里列出的路径必须是指定文件,而不是某个文件夹,而且不能使用* ? **/ 等通配符 74 | "include": ["./"], // include也可以指定要编译的路径列表,但是和files的区别在于,这里的路径可以是文件夹,也可以是文件,可以使用相对和绝对路径,而且可以使用通配符,比如"./src"即表示要编译src文件夹下的所有文件以及子文件夹的文件 75 | "exclude": ["*node_modules/*"] // exclude表示要排除的、不编译的文件,它也可以指定一个列表,规则和include一样,可以是文件或文件夹,可以是相对路径或绝对路径,可以使用通配符 76 | // "extends": "", // extends可以通过指定一个其他的tsconfig.json文件路径,来继承这个配置文件里的配置,继承来的文件的配置会覆盖当前文件定义的配置。TS在3.2版本开始,支持继承一个来自Node.js包的tsconfig.json配置文件 77 | // "compileOnSave": true, // compileOnSave的值是true或false,如果设为true,在我们编辑了项目中的文件保存的时候,编辑器会根据tsconfig.json中的配置重新生成文件,不过这个要编辑器支持 78 | // "references": [], // 一个对象数组,指定要引用的项目 79 | } 80 | -------------------------------------------------------------------------------- /source/测试/不冲突的异步函数 Promise.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | namespace NapiPromise 6 | { 7 | struct EnvNextWorkData 8 | { 9 | napi_deferred deferred; 10 | napi_async_work work; 11 | int index; 12 | void * data; 13 | }; 14 | 15 | // async 16 | void ExecuteAsyncWork(napi_env env, void *data) 17 | { 18 | EnvNextWorkData *workData = (EnvNextWorkData *)data; 19 | 20 | 21 | } 22 | 23 | // 异步任务完成后的回调函数 24 | void ResolveWork(napi_env env, napi_status status, void *data) 25 | { 26 | EnvNextWorkData *workData = (EnvNextWorkData *)data; 27 | napi_value result; 28 | napi_get_undefined(env, &result); 29 | 30 | napi_resolve_deferred(env, workData->deferred, result); 31 | napi_delete_async_work(env, workData->work); 32 | delete workData; 33 | } 34 | 35 | // 启动异步任务的函数 36 | napi_value StartAsyncTask(napi_env env, napi_callback_info info) 37 | { 38 | napi_value promise; 39 | napi_value resourceName; 40 | napi_create_string_utf8(env, __FUNCSIG__, NAPI_AUTO_LENGTH, &resourceName); 41 | 42 | // 初始化异步工作的数据 43 | EnvNextWorkData *workData = new EnvNextWorkData(); 44 | workData->index = 5; 45 | 46 | napi_create_promise(env, &workData->deferred, &promise); 47 | napi_create_async_work(env, nullptr, resourceName, ExecuteAsyncWork, ResolveWork, workData, &workData->work); 48 | napi_queue_async_work(env, workData->work); 49 | return promise; 50 | } 51 | 52 | // 初始化模块 53 | napi_value Init(napi_env env, napi_value exports, const char *utf8name) 54 | { 55 | napi_value asyncTaskFunction; 56 | napi_create_function(env, nullptr, 0, StartAsyncTask, nullptr, &asyncTaskFunction); 57 | napi_set_named_property(env, exports, utf8name, asyncTaskFunction); 58 | } 59 | 60 | } 61 | 62 | // 注册模块 63 | napi_value Init(napi_env env, napi_value exports) 64 | { 65 | NapiPromise::Init(env, exports, "NapiPromise"); 66 | return exports; 67 | } 68 | 69 | NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) 70 | -------------------------------------------------------------------------------- /source/测试/不冲突的异步函数.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | typedef struct { 7 | int32_t input; // 输入参数 8 | int32_t result; // 计算结果 9 | napi_ref callback; // JavaScript 回调 10 | napi_async_work work; // N-API 异步工作 11 | } AsyncWorkData; 12 | 13 | 14 | void ExecuteTask(napi_env env, void* data) { 15 | AsyncWorkData* workData = (AsyncWorkData*)data; 16 | 17 | std::this_thread::sleep_for(std::chrono::seconds(2)); // 模拟异步任务(例如:IO操作) 18 | 19 | // 模拟异步任务,耗时计算 20 | int input = workData->input; 21 | workData->result = input * 2; // 假设任务是计算输入值的2倍 22 | } 23 | 24 | void CompleteTask(napi_env env, napi_status status, void* data) { 25 | napi_value result, callback, undefined; 26 | napi_status status_code; 27 | AsyncWorkData* workData = (AsyncWorkData*)data; 28 | 29 | // 创建返回值 30 | status_code = napi_create_int32(env, workData->result, &result); 31 | 32 | // 获取 undefined 值用于回调 33 | status_code = napi_get_undefined(env, &undefined); 34 | 35 | // 获取回调函数 36 | status_code = napi_get_reference_value(env, workData->callback, &callback); 37 | 38 | // 创建回调参数数组(第一个参数是错误,第二个是结果) 39 | napi_value argv[2]; 40 | napi_get_null(env, &argv[0]); // 没有错误 41 | argv[1] = result; 42 | 43 | // 调用 JavaScript 回调函数 44 | status_code = napi_call_function(env, undefined, callback, 2, argv, NULL); 45 | 46 | // 清理内存 47 | napi_delete_reference(env, workData->callback); 48 | napi_delete_async_work(env, workData->work); 49 | free(workData); 50 | } 51 | 52 | 53 | napi_value StartAsyncTask(napi_env env, napi_callback_info info) { 54 | size_t argc = 2; 55 | napi_value args[2]; 56 | napi_value resource_name; 57 | napi_status status; 58 | 59 | // 解析输入参数 60 | napi_get_cb_info(env, info, &argc, args, NULL, NULL); 61 | 62 | // 第一个参数是整数(输入值) 63 | int32_t input; 64 | napi_get_value_int32(env, args[0], &input); 65 | 66 | // 第二个参数是回调函数 67 | napi_value callback = args[1]; 68 | 69 | // 创建异步工作数据 70 | AsyncWorkData* workData = (AsyncWorkData*)malloc(sizeof(AsyncWorkData)); 71 | workData->input = input; 72 | napi_create_reference(env, callback, 1, &workData->callback); 73 | 74 | // 创建异步工作名称 75 | napi_create_string_utf8(env, "AsyncTask", NAPI_AUTO_LENGTH, &resource_name); 76 | 77 | // 创建异步工作 78 | napi_create_async_work(env, NULL, resource_name, ExecuteTask, CompleteTask, workData, &workData->work); 79 | 80 | // 将工作推入队列,开始执行异步任务 81 | napi_queue_async_work(env, workData->work); 82 | 83 | return NULL; 84 | } 85 | 86 | napi_value Init(napi_env env, napi_value exports) { 87 | napi_value asyncTaskFunction; 88 | napi_create_function(env, NULL, 0, StartAsyncTask, NULL, &asyncTaskFunction); 89 | napi_set_named_property(env, exports, "startAsyncTask", asyncTaskFunction); 90 | return exports; 91 | } 92 | 93 | NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) 94 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "skipLibCheck": true, 4 | /* Basic Options */ 5 | // "moduleResolution": "node", 6 | // "importHelpers": true, 7 | // "skipLibCheck": true, 8 | // "resolveJsonModule": true, 9 | // "noImplicitAny": false, 10 | "target": "ES2017" /* target用于指定编译之后的版本目标: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, 11 | "module": "commonjs" /* 用来指定要使用的模块标准: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, 12 | // "lib": [ "ES2021"] /* lib用于指定要包含在编译中的库文件 */, 13 | // "allowJs": true, /* allowJs设置的值为true或false,用来指定是否允许编译js文件,默认是false,即不编译js文件 */ 14 | // "checkJs": true, /* checkJs的值为true或false,用来指定是否检查和报告js文件中的错误,默认是false */ 15 | // "jsx": "preserve", /* 指定jsx代码用于的开发环境: 'preserve', 'react-native', or 'react'. */ 16 | // "declaration": true, /* declaration的值为true或false,用来指定是否在编译的时候生成相应的".d.ts"声明文件。如果设为true,编译每个ts文件之后会生成一个js文件和一个声明文件。但是declaration和allowJs不能同时设为true */ 17 | // "declarationMap": true, /* 值为true或false,指定是否为声明文件.d.ts生成map文件 */ 18 | "sourceMap": false /* sourceMap的值为true或false,用来指定编译时是否生成.map文件 */, 19 | // "outFile": "./", /* outFile用于指定将输出文件合并为一个文件,它的值为一个文件路径名。比如设置为"./dist/main.js",则输出的文件为一个main.js文件。但是要注意,只有设置module的值为amd和system模块时才支持这个配置 */ 20 | // "outDir": "", 21 | /* outDir用来指定输出文件夹,值为一个文件夹路径字符串,输出的文件都将放置在这个文件夹 */ 22 | // "rootDir": "./", /* 用来指定编译文件的根目录,编译器会在根目录查找入口文件,如果编译器发现以rootDir的值作为根目录查找入口文件并不会把所有文件加载进去的话会报错,但是不会停止编译 */ 23 | // "composite": true, /* 是否编译构建引用项目 */ 24 | // "incremental": true, /* 是否启用增量编译*/ 25 | //"tsBuildInfoFile": "./builds/Tsc-BuildInfoFile" /* 指定文件用来存储增量编译信息 */, 26 | "removeComments": false /* removeComments的值为true或false,用于指定是否将编译后的文件中的注释删掉,设为true的话即删掉注释,默认为false */, 27 | // "noEmit": true, /* 不生成编译文件,这个一般比较少用 */ 28 | // "importHelpers": true, /* importHelpers的值为true或false,指定是否引入tslib里的辅助工具函数,默认为false */ 29 | // "downlevelIteration": true, /* 当target为'ES5' or 'ES3'时,为'for-of', spread, and destructuring'中的迭代器提供完全支持 */ 30 | // "isolatedModules": true, /* isolatedModules的值为true或false,指定是否将每个文件作为单独的模块,默认为true,它不可以和declaration同时设定 */ 31 | 32 | // /* Strict Type-Checking Options */ 33 | "strict": true, 34 | /* strict的值为true或false,用于指定是否启动所有类型检查,如果设为true则会同时开启下面这几个严格类型检查,默认为false */ 35 | // "noImplicitAny": false, /* noImplicitAny的值为true或false,如果我们没有为一些值设置明确的类型,编译器会默认认为这个值为any,如果noImplicitAny的值为true的话。则没有明确的类型会报错。默认值为false */ 36 | // "strictNullChecks": true, /* strictNullChecks为true时,null和undefined值不能赋给非这两种类型的值,别的类型也不能赋给他们,除了any类型。还有个例外就是undefined可以赋值给void类型 */ 37 | // "strictFunctionTypes": true, /* strictFunctionTypes的值为true或false,用于指定是否使用函数参数双向协变检查 */ 38 | // "strictBindCallApply": true, /* 设为true后会对bind、call和apply绑定的方法的参数的检测是严格检测的 */ 39 | // "strictPropertyInitialization": true, /* 设为true后会检查类的非undefined属性是否已经在构造函数里初始化,如果要开启这项,需要同时开启strictNullChecks,默认为false */ 40 | // "noImplicitThis": true, /* 当this表达式的值为any类型的时候,生成一个错误 */ 41 | // "alwaysStrict": true, /* alwaysStrict的值为true或false,指定始终以严格模式检查每个模块,并且在编译之后的js文件中加入"use strict"字符串,用来告诉浏览器该js为严格模式 */ 42 | 43 | // /* Additional Checks */ 44 | // "noUnusedLocals": true, /* 用于检查是否有定义了但是没有使用的变量,对于这一点的检测,使用eslint可以在你书写代码的时候做提示,你可以配合使用。它的默认值为false */ 45 | // "noUnusedParameters": true, /* 用于检查是否有在函数体中没有使用的参数,这个也可以配合eslint来做检查,默认为false */ 46 | // "noImplicitReturns": true, /* 用于检查函数是否有返回值,设为true后,如果函数没有返回值则会提示,默认为false */ 47 | "noFallthroughCasesInSwitch": true /* 用于检查switch中是否有case没有使用break跳出switch,默认为false */, 48 | 49 | // /* Module Resolution Options */ 50 | // "moduleResolution": "node", /* 用于选择模块解析策略,有'node'和'classic'两种类型' */ 51 | // "baseUrl": "./", /* baseUrl用于设置解析非相对模块名称的基本目录,相对模块不会受baseUrl的影响 */ 52 | // "paths": {}, 53 | /* 用于设置模块名称到基于baseUrl的路径映射 */ 54 | // "rootDirs": [], 55 | /* rootDirs可以指定一个路径列表,在构建时编译器会将这个路径列表中的路径的内容都放到一个文件夹中 */ 56 | "typeRoots": ["./node_modules/@types", "@types"], 57 | /* typeRoots用来指定声明文件或文件夹的路径列表,如果指定了此项,则只有在这里列出的声明文件才会被加载 */ 58 | // "types": [], /* types用来指定需要包含的模块,只有在这里列出的模块的声明文件才会被加载进来 */ 59 | "allowSyntheticDefaultImports": true, 60 | /* 用来指定允许从没有默认导出的模块中默认导入 */ 61 | "esModuleInterop": true /* 通过为导入内容创建命名空间,实现CommonJS和ES模块之间的互操作性 */, 62 | "preserveSymlinks": true /* 不把符号链接解析为其真实路径,具体可以了解下webpack和nodejs的symlink相关知识 */, 63 | // /* Source Map Options */ 64 | // "sourceRoot": "", /* sourceRoot用于指定调试器应该找到TypeScript文件而不是源文件位置,这个值会被写进.map文件里 */ 65 | // "mapRoot": "", /* mapRoot用于指定调试器找到映射文件而非生成文件的位置,指定map文件的根路径,该选项会影响.map文件中的sources属性 */ 66 | "inlineSourceMap": false /* 指定是否将map文件的内容和js文件编译在同一个js文件中,如果设为true,则map的内容会以//# sourceMappingURL=然后拼接base64字符串的形式插入在js文件底部 */, 67 | "inlineSources": false /* 用于指定是否进一步将.ts文件的内容也包含到输入文件中 */ 68 | 69 | // /* Experimental Options */ 70 | // "experimentalDecorators": true, /* 用于指定是否启用实验性的装饰器特性 */ 71 | // "emitDecoratorMetadata": true, /* 用于指定是否为装饰器提供元数据支持,关于元数据,也是ES6的新标准,可以通过Reflect提供的静态方法获取元数据,如果需要使用Reflect的一些方法,需要引入ES2015.Reflect这个库 */ 72 | }, 73 | // "files": [], // files可以配置一个数组列表,里面包含指定文件的相对或绝对路径,编译器在编译的时候只会编译包含在files中列出的文件,如果不指定,则取决于有没有设置include选项,如果没有include选项,则默认会编译根目录以及所有子目录中的文件。这里列出的路径必须是指定文件,而不是某个文件夹,而且不能使用* ? **/ 等通配符 74 | "include": ["./"], // include也可以指定要编译的路径列表,但是和files的区别在于,这里的路径可以是文件夹,也可以是文件,可以使用相对和绝对路径,而且可以使用通配符,比如"./src"即表示要编译src文件夹下的所有文件以及子文件夹的文件 75 | "exclude": ["*node_modules/*"] // exclude表示要排除的、不编译的文件,它也可以指定一个列表,规则和include一样,可以是文件或文件夹,可以是相对路径或绝对路径,可以使用通配符 76 | // "extends": "", // extends可以通过指定一个其他的tsconfig.json文件路径,来继承这个配置文件里的配置,继承来的文件的配置会覆盖当前文件定义的配置。TS在3.2版本开始,支持继承一个来自Node.js包的tsconfig.json配置文件 77 | // "compileOnSave": true, // compileOnSave的值是true或false,如果设为true,在我们编辑了项目中的文件保存的时候,编辑器会根据tsconfig.json中的配置重新生成文件,不过这个要编辑器支持 78 | // "references": [], // 一个对象数组,指定要引用的项目 79 | } 80 | -------------------------------------------------------------------------------- /vkKey.d.ts: -------------------------------------------------------------------------------- 1 | export declare let KeyboardcodeComparisonTable: Map; 2 | export declare const KeyboardVKcodeComparisonEmenList: Array<[VK_key, VK_code | null, VK_keyCode, VK_VirtualKey] | [VK_key, VK_code | null, VK_keyCode, VK_VirtualKey, VK_Nickname]>; 3 | /** 4 | * 格式化键值码 5 | * @param key 6 | * @returns 7 | */ 8 | export declare function vkKey(key: any): number | null; 9 | export declare const KeyboardVKcodeEmenList: Array<[VK_key, VK_code | null, VK_keyCode, VK_VirtualKey] | [VK_key, VK_code | null, VK_keyCode, VK_VirtualKey, VK_Nickname]>; 10 | export type VK_key = string; 11 | export type VK_code = string; 12 | export type VK_keyCode = number; 13 | export type VK_VirtualKey = number; 14 | export type VK_Nickname = string[] | undefined; 15 | export declare const KeyboardcodeEmenList: Map; 16 | -------------------------------------------------------------------------------- /二次开发指南.md: -------------------------------------------------------------------------------- 1 | # **HMC-win32: 开发者指南** 2 | 3 | 4 | 5 | [![系统环境](https://camo.githubusercontent.com/91bbe03a05014538a00ae22090ebc9d1d2e4df79556c610b64cd7a5b11393e67/68747470733a2f2f636f732e6b6969632e746f702f6173736574732f757365642f3230323230343131323330313937322e737667)](https://camo.githubusercontent.com/91bbe03a05014538a00ae22090ebc9d1d2e4df79556c610b64cd7a5b11393e67/68747470733a2f2f636f732e6b6969632e746f702f6173736574732f757365642f3230323230343131323330313937322e737667) [![系统环境](https://camo.githubusercontent.com/b530fd09bb10cd8358d20c175ca0f0ea379164a40b1f5e6e78cd244ec29ad7b2/68747470733a2f2f636f732e6b6969632e746f702f6173736574732f757365642f3230323230343131323330313936392e737667)](https://camo.githubusercontent.com/b530fd09bb10cd8358d20c175ca0f0ea379164a40b1f5e6e78cd244ec29ad7b2/68747470733a2f2f636f732e6b6969632e746f702f6173736574732f757365642f3230323230343131323330313936392e737667) [![系统环境](https://camo.githubusercontent.com/b5bf5605474d333351ac4ccb3e24efbadbb34861127cfa1ca03e2e84043e7b93/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4e6f6465362e31342e322b2d4e6f64652d3937633430662e7376673f6c6f6e6743616368653d74727565)](https://camo.githubusercontent.com/b5bf5605474d333351ac4ccb3e24efbadbb34861127cfa1ca03e2e84043e7b93/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4e6f6465362e31342e322b2d4e6f64652d3937633430662e7376673f6c6f6e6743616368653d74727565) [![系统环境](https://camo.githubusercontent.com/a3fbbb53e5454025843bdd7e566abec7fb21bafbe1215fe88b990560aebb9606/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4e6f6465382e302b2d656c656374726f6e2d3937633430662e7376673f6c6f6e6743616368653d74727565)](https://camo.githubusercontent.com/a3fbbb53e5454025843bdd7e566abec7fb21bafbe1215fe88b990560aebb9606/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4e6f6465382e302b2d656c656374726f6e2d3937633430662e7376673f6c6f6e6743616368653d74727565) 6 | 7 | ### 开发工具: 8 | 9 | - **Visual Studio 2019** 必须 (编译器) 10 | - **TypeScript** 必须 (和esbuld 二选一也行) 11 | - **esbuild** 必须(esbuld单个可执行文件也行) 12 | - **node-gyp** 必须(有必须用到的头) 13 | 14 | 15 | 16 | ### 模块链: 17 | 18 | #### js 19 | 20 | 负责模块数据对传安全性处理 `hmc.ts` 文件是主逻辑 `hmc2.ts ` 是Beta版本(2.0)支持 21 | 22 | 路径为:`source\mian` 23 | 24 | ------------------------------ 25 | 26 | #### hmc-module 27 | 28 | HMC封装的核心库(2代),**代码规整性较好,可参考性高** 29 | 30 | 这是个独立的项目代码存在问题的话 提iss请到这里 https://github.com/kihlh/hmc-module 31 | 32 | 路径在: `source\hmc-module` 33 | 34 | --------------------------------------- 35 | 36 | #### **CPP (陈年代码)** 37 | 38 | 1.0也是整个模块的主心骨模块,从入坑c++时候上班摸鱼写的,代码比较松散,不过没炸过 我还是挺佩服的 39 | 40 | 路径在: `source\CPP` 41 | 42 | - 构建文件: source\CPP\binding.gyp 43 | 44 | - 打开到此目录然后执行 45 | 46 | ```shell 47 | # 64位 48 | node-gyp rebuild --msvs_version=2019 49 | 50 | #32位 51 | node-gyp rebuild --arch=ia32 --msvs_version=2019 52 | ``` 53 | 54 | - 编译出来的名称应该为:(64bit)bin\HMC_x64.node (32bit)bin\HMC_x86.node 55 | 56 | ---------------------------------------------- 57 | 58 | #### **HMC2.0** 59 | 60 | **代码非常简洁严格明** 但是需要搭配 hmc-module (因为是我近期填坑的),如果你需要自行开发可以从这里开始 61 | 62 | 路径在:`source\hmc-win32@2.0` 63 | 64 | - 构建文件: source\hmc-win32@2.0\source\cpp\binding.gyp 65 | 66 | - 打开到此目录 ( source\hmc-win32@2.0\source\cpp\) 然后执行 67 | 68 | ```shell 69 | # 64位 70 | node-gyp rebuild --msvs_version=2019 71 | 72 | #32位 73 | node-gyp rebuild --arch=ia32 --msvs_version=2019 74 | ``` 75 | 76 | - 编译出来的名称应该为:(64bit)bin\HMC@Beta_x64.node (32bit)bin\HMC@Beta_x86.node 77 | 78 | --------------------------------------------- 79 | 80 | #### **hmn-win32** 81 | 82 | hmc的网络处理模块但是已经分支为子模块了,项目链接在:https://github.com/kihlh/hmn-win32 83 | 84 | ------------------------------ 85 | 86 | #### **hmc-autoIt** 87 | 88 | 几乎不需要编辑定制,因为这个只是把autoItX接口转发了,功能齐全调用的是 autoIt 有独立模块 89 | 90 | 路径在:`source\hmc-autoIt` 91 | 92 | ----------------------------------------------------- 93 | 94 | ### 开发小诀窍: 95 | 96 | #### 快速编译的的秘籍: 97 | 98 | `node-gyp rebuild` 执行后会产生一个build文件夹,里面的`binding.sln`可以直接用vs打开,并且可以配置断点,只需要执行命令那边让启动指定的node和加载指定的启动命令 99 | 100 | 编译速度提升90% (预编译) 101 | 102 | 例如 : node.exe 命令行:debug.js 103 | 104 | ---------------------------------------- 105 | 106 | ### 107 | 108 | #### node-gyp配置文件解析: 109 | 110 | - sources :需要编译的cpp文件 后缀可以是 cc,CPP,C++ 111 | - AdditionalOptions:需要禁用的警告 112 | - include_dirs :头文件目录 113 | - libraries:lib文件路径 114 | - target_name :项目名称 不能有-*@#$%^&... 特殊字符 --------------------------------------------------------------------------------