From 51aec71921532e1b048126318856d2a21b86b181 Mon Sep 17 00:00:00 2001 From: thc282 Date: Tue, 12 Nov 2024 22:52:13 +0800 Subject: [PATCH] v1 implementation --- README.md | 39 +++++++++------- ZZZHKeys.ahk | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+), 16 deletions(-) create mode 100644 ZZZHKeys.ahk diff --git a/README.md b/README.md index b7d46e6..f86aff2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 絕區零按鍵映射 [模仿崩壞3模式] +# 絕區零/原神按鍵映射 [模仿崩壞3模式] @@ -6,31 +6,38 @@
English
-一個 絕區零 的快捷鍵映射 \ +一個 絕區零(主)/原神 的快捷鍵映射 \ 這只是一個按鍵輔助工具, 非任何作弊引擎/插件 -## 功能 (`Alt+N` 手動啟動/關閉) -| 按鍵 | 代替鍵 | -|:-:|:-| +## 功能 (`Alt+N` 手動啟用/關閉) +| 按鍵 | 絕區零 | 原神 | +|:-:|:-:|:-:| |Q| 視角向左移 | |E| 視角向右移 | -|U| E 特殊技 | -|I| Q 終結技 | -|J| LClk 攻擊 | -|K| RClk/LShft 閃避 | -|L| MClk 取消連攜技/鎖定 | +|N| 視角向上移 | +|M| 視角向下移 | +|U| E 特殊技 | 通用[元素戰技] | +|I| Q 終結技 | 通用[元素爆發] | +|J| LClk 攻擊 | 通用 | +|K| RClk/LShft 閃避 | 通用 | +|L| MClk 取消連攜技/鎖定 | 重設視野/元素視野[長按] | + +特殊按鍵 +| 按鍵 | 代替鍵 | +|:-:|:-| +|Alt+N| 啟用/暫停映射 | +|Ctrl+Alt+E| 終結插件運作 | *** ## 如何安裝 ❓ -1. 到 [版本列表]() 找一個合適版本 +1. 到 [版本列表](https://github.com/thc282/ZZZHKeys/releases) 找一個合適版本 或 -直接 [下載v1]() -2. 解壓 & 雙擊 ZZZHKeys.exe 運行 -> 壓縮檔裡已提供快捷鍵清單 -3. ~你可以隨時在Windows的圖示列表(tray menu)退出插件~ +直接 [下載](https://github.com/thc282/ZZZHKeys/releases/download/v1.0.0/ZZZHKeys.exe) +2. 雙擊 ZZZHKeys.exe 運行 +3. 你可以隨時使用Ctrl+Alt+E退出插件 *** ## ❗❗ 注意 ❗❗ - +暫時沒有 *** ## ⚠️ 宇宙免責聲明 diff --git a/ZZZHKeys.ahk b/ZZZHKeys.ahk new file mode 100644 index 0000000..452aa9a --- /dev/null +++ b/ZZZHKeys.ahk @@ -0,0 +1,127 @@ +#Requires AutoHotkey v2.0 + +; https://stackoverflow.com/questions/43298908/how-to-add-administrator-privileges-to-autohotkey-script +#SingleInstance Force +;@Ahk2Exe-UpdateManifest 1 +full_command_line := DllCall("GetCommandLine", "str") +if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)")) +{ + try + { + if A_IsCompiled + Run '*RunAs "' A_ScriptFullPath '" /restart' + else + Run '*RunAs "' A_AhkPath '" /restart "' A_ScriptFullPath '"' + } + ExitApp +} + +SendMode "Event" +GroupAdd "HoYoGame", "ahk_exe GenshinImpact.exe" +GroupAdd "HoYoGame", "ahk_exe ZenlessZoneZero.exe" + +/* + ========================================================== + 檢測 + ========================================================== +*/ +;立刻檢測是否前台 +CheckActive +;每5秒檢測是否前台 +SetTimer CheckActive, 5000 + +CheckActive(){ + if WinWaitActive('ahk_group HoYoGame',,5){ + Suspend false + Settimer MoveCursor, 16 + }else{ + Suspend true + } +} + +/* +========================================================== +主要 +========================================================== +*/ +#HotIf WinActive("ahk_group HoYoGame") + ; 按Alt+N暫停所有熱鍵, 再次Alt+N啟動 + #SuspendExempt + ~!n:: + { + Suspend + ToolTip a_isSuspended ? "插件已暫停":"插件運作中" + SetTimer CheckActive, (A_IsSuspended) == 1 ? 0 : 5000 + Settimer MoveCursor, (A_IsSuspended) == 1 ? 0 : 16 + Sleep 3000 + ToolTip + } + + ; 按Alt+R重載腳本 + !r::Reload + + ; 按Ctrl+Alt+E退出腳本 + ^!e::{ + MsgBox "ZZZHKeys 已停止(Terminated)",'ZZZHKeys.exe' , 'OK' + ExitApp + } + #SuspendExempt false + + + ;以下是映射設定 + j::LButton ;攻擊(滑鼠左鍵) + k::RButton ;閃避(滑鼠右鍵) + l::MButton ;取消(滑鼠中鍵) + + u::e ;小技能 + i::q ;終結技 + + ; mouse speed variables + global FORCE := 1.8 + global RESISTANCE := 0.982 + + global VELOCITY_X := 0 + global VELOCITY_Y := 0 + + $e::return + $q::return + n::return + m::return + + Accelerate(velocity, pos, neg) { + If (pos == 0 && neg == 0) { + Return 0 + } + ; smooth deceleration :) + Else If (pos + neg == 0) { + Return velocity * 0.666 + } + ; physicszzzzz + Else { + Return velocity * RESISTANCE + FORCE * (pos + neg) + } + } + + SetTimer MoveCursor, 16 + MoveCursor() { + global + if(!WinActive("ahk_group HoYoGame")) + SetTimer MoveCursor, 0 + ToolTip VELOCITY_X "," VELOCITY_Y, 0, 0 + LEFT := 0 + DOWN := 0 + UP := 0 + RIGHT := 0 + + UP := UP - GetKeyState("n", "P") + LEFT := LEFT - GetKeyState("q", "P") + DOWN := DOWN + GetKeyState("m", "P") + RIGHT := RIGHT + GetKeyState("e", "P") + + VELOCITY_X := Accelerate(VELOCITY_X, LEFT, RIGHT) + VELOCITY_Y := Accelerate(VELOCITY_Y, UP, DOWN) + + DllCall("mouse_event", "UInt", 0x0001, "UInt", VELOCITY_X, "UInt", 0) + DllCall("mouse_event", "UInt", 0x0001, "UInt", 0, "UInt", VELOCITY_Y) + } +#HotIf \ No newline at end of file