Skip to content

Commit

Permalink
v1 implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
thc282 committed Nov 12, 2024
1 parent a051162 commit 496e5b3
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 16 deletions.
39 changes: 23 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
# 絕區零按鍵映射 [模仿崩壞3模式]
# 絕區零/原神按鍵映射 [模仿崩壞3模式]
<table>
<tr>
<td valign="center"><a href="README_ENG.md"><img src="https://github.com/jdecked/twemoji/blob/main/assets/svg/1f1fa-1f1f8.svg" width="16"/>English</a></td>
<td valign="center"><img src="https://github.com/jdecked/twemoji/blob/main/assets/svg/1f1f9-1f1fc.svg" width="16"/>繁中</a></td>
</tr>
</table>

一個 絕區零 的快捷鍵映射 \
一個 絕區零(主)/原神 的快捷鍵映射 \
這只是一個按鍵輔助工具, 非任何作弊引擎/插件

## 功能 (`Alt+N` 手動啟動/關閉)
| 按鍵 | 代替鍵 |
|:-:|:-|
## 功能 (`Alt+N` 手動啟用/關閉)
| 按鍵 | 絕區零 | 原神 |
|:-:|:-:|:-:|
|<kbd>Q</kbd>| 視角向左移 |
|<kbd>E</kbd>| 視角向右移 |
|<kbd>U</kbd>| <kbd>E</kbd> 特殊技 |
|<kbd>I</kbd>| <kbd>Q</kbd> 終結技 |
|<kbd>J</kbd>| <kbd>LClk</kbd> 攻擊 |
|<kbd>K</kbd>| <kbd>RClk</kbd>/<kbd>LShft</kbd> 閃避 |
|<kbd>L</kbd>| <kbd>MClk</kbd> 取消連攜技/鎖定 |
|<kbd>N</kbd>| 視角向上移 |
|<kbd>M</kbd>| 視角向下移 |
|<kbd>U</kbd>| <kbd>E</kbd> 特殊技 | 通用[元素戰技] |
|<kbd>I</kbd>| <kbd>Q</kbd> 終結技 | 通用[元素爆發] |
|<kbd>J</kbd>| <kbd>LClk</kbd> 攻擊 | 通用 |
|<kbd>K</kbd>| <kbd>RClk</kbd>/<kbd>LShft</kbd> 閃避 | 通用 |
|<kbd>L</kbd>| <kbd>MClk</kbd> 取消連攜技/鎖定 | 重設視野/元素視野[長按] |

特殊按鍵
| 按鍵 | 代替鍵 |
|:-:|:-|
|<kbd>Alt</kbd>+<kbd>N</kbd>| 啟用/暫停映射 |
|<kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>E</kbd>| 終結插件運作 |
***
## 如何安裝 ❓
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. 你可以隨時使用<kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>E</kbd>退出插件

***
## ❗❗ 注意 ❗❗

暫時沒有

***
## ⚠️ 宇宙免責聲明
Expand Down
126 changes: 126 additions & 0 deletions ZZZHKeys.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#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
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

0 comments on commit 496e5b3

Please sign in to comment.