Skip to content

Commit

Permalink
BH3_Hotkey.ahk
Browse files Browse the repository at this point in the history
  • Loading branch information
Spr-Aachen committed May 4, 2022
1 parent c9bea26 commit e1b2fb0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 97 deletions.
95 changes: 32 additions & 63 deletions BH3_Hotkey.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SwitchIME(dwLayout) ; 该段用于管理输入法,请勿删改
F1:: ; 暂停/ 启用程序——若想正常使用鼠标请按该键或按住ALT键
Suspend, Toggle
WinSet, AlwaysOnTop, Off, A
SetTimer, ViewControlTemp, Off
SetTimer, ViewControl, Off
SendInput, {Click, Up Middle}
SwitchIME(0x04090409) ; 切换至"中文(中国) 简体中文-美式键盘"
;Send, #{Space} ; [未启用命令行] 微软拼音用户可用该命令
Expand All @@ -82,7 +82,7 @@ Return

F3:: ; 重启程序以呼出操作说明界面
Suspend, Off
SetTimer, ViewControlTemp, Off
SetTimer, ViewControl, Off
SendInput, {Click, Up Middle}
Reload
Return
Expand All @@ -92,7 +92,7 @@ If (A_IsSuspended=0)
{
Suspend, On
WinSet, AlwaysOnTop, Off, A
SetTimer, ViewControlTemp, Off
SetTimer, ViewControl, Off
Send, {Click, Up Middle}
SwitchIME(0x04090409) ; 切换至"中文(中国) 简体中文-美式键盘"
;Send, #{Space} ; [未启用命令行] 微软拼音用户可用该命令
Expand All @@ -111,7 +111,7 @@ If (A_IsSuspended=0)
{
Suspend, On
WinSet, AlwaysOnTop, Off, A
SetTimer, ViewControlTemp, Off
SetTimer, ViewControl, Off
SendInput, {Click, Up Middle}
SwitchIME(0x04090409) ; 切换至"中文(中国) 简体中文-美式键盘"
;Send, #{Space} ; [未启用命令行] 微软拼音用户可用该命令
Expand All @@ -130,20 +130,13 @@ Return
ViewControl:
If WinActive("ahk_exe BH3.exe")
{
CoordMode, Window
WinGetPos, X, Y, Width, Height, ahk_exe BH3.exe ; 获取崩坏3游戏窗口参数(同样适用于非全屏)
MouseMove, Width/2, Height/2, 0 ; [建议保持数值] 使鼠标回正,居中于窗口
SendInput, {Click, Down Middle}
}
Return

ViewControlTemp:
If WinActive("ahk_exe BH3.exe")
{
Threshold = 1
MouseGetPos, x1, y1
Sleep, 1
MouseGetPos, x2, y2
If (x1<x2)
If (abs(x1-x2)>Threshold or abs(y1-y2)>Threshold)
SendInput, {Click, Down Middle}
Else If (x1<x2)
{
SendInput, {e Down}
Sleep, 1
Expand Down Expand Up @@ -199,6 +192,8 @@ If WinActive("ahk_exe BH3.exe")
SendInput, {q Up}{n Up}
Return
}
Else
SendInput, {Click, Up Middle}
}
Return

Expand All @@ -213,24 +208,28 @@ If WinActive("ahk_exe BH3.exe")
SendInput, {d Down}{a Up}{s Up}{w Up}
KeyWait, e, U
SendInput, {d Up}
Return
}
Else If (x1>x2)
{
SendInput, {a Down}{d Up}{s Up}{w Up}
KeyWait, e, U
SendInput, {a Up}
Return
}
Else If (y1<y2)
{
SendInput, {s Down}{a Up}{w Up}{d Up}
KeyWait, e, U
SendInput, {s Up}
Return
}
Else If (y1>y2)
{
SendInput, {w Down}{a Up}{s Up}{d Up}
KeyWait, e, U
SendInput, {w Up}
Return
}
}
Return
Expand All @@ -241,15 +240,16 @@ MButton:: ; 点击鼠标中键以激活视角跟随
M_Toggle:=!M_Toggle
If (M_Toggle)
{
SetTimer, ViewControlTemp, Off
SetTimer, ViewControl, -99 ; [[可调校数值]] 设定视角跟随命令的每执行间隔时间(ms)
CoordMode, Window
WinGetPos, X, Y, Width, Height, ahk_exe BH3.exe ; 获取崩坏3游戏窗口参数(同样适用于非全屏)
MouseMove, Width/2, Height/2, 0 ; [建议保持数值] 使鼠标回正,居中于窗口
SetTimer, ViewControl, 0, 0 ; [[可调校数值]] 设定视角跟随命令的每执行间隔时间(ms)
ToolTip, 视角跟随已激活, 0, 999 ; [可调校数值]
Sleep 999 ; [可调校数值]
ToolTip
}
Else
{
SetTimer, ViewControlTemp, Off
SetTimer, ViewControl, Off
SendInput, {Click, Up Middle}
ToolTip, 视角跟随已关闭, 0, 999 ; [可调校数值]
Expand All @@ -258,68 +258,37 @@ Else
}
Return

LButton:: ; 点按鼠标左键以发动普攻
Send, {j Down}
If (M_Toggle)
{
If GetKeyState("LButton", "P")
{
SetTimer, ViewControl, Off
SetTimer, ViewControlTemp, 0 ; [[可调校数值]] 设定视角跟随命令的每执行间隔时间(ms)
}
}
KeyWait, LButton, U
Send, {j Up}
SetTimer, ViewControlTemp, Off
Return

q:: ; 按下键盘Q键以发动必杀技
Send, {i Down}
If (M_Toggle)
{
If GetKeyState("q", "P")
{
SetTimer, ViewControl, Off
SetTimer, ViewControlTemp, 0 ; [[可调校数值]] 设定视角跟随命令的每执行间隔时间(ms)
}
}
KeyWait, q, U
Send, {i Up}
SetTimer, ViewControlTemp, Off
Return

e:: ; 按下键盘E键以发动武器技/ 后崩坏书必杀技,长按E键进入瞄准模式时可用鼠标键操控准心
Send, {u Down}
If (M_Toggle)
{
If GetKeyState("e", "P")
{
SetTimer, ViewControl, Off
SetTimer, AimControlTemp, 0 ; [[可调校数值]] 设定视角跟随命令的每执行间隔时间(ms)
SetTimer, ViewControl, Off
}
}
KeyWait, e, U
Send, {u Up}
SetTimer, AimControlTemp, Off
Return

z::l ; 按下键盘Z键以发动人偶技

LShIft:: ; 按下键盘左侧ShIft键以发动闪避/冲刺
Send, {k Down}
If (M_Toggle)
{
If GetKeyState("q", "P")
{
SetTimer, ViewControl, Off
SetTimer, ViewControlTemp, 0 ; [[可调校数值]] 设定视角跟随命令的每执行间隔时间(ms)
}
SetTimer, AimControlTemp, Delete
SetTimer, ViewControl, On
}
Return

LShIft:: ; 按下键盘左侧ShIft键以发动闪避/冲刺
SendEvent, {k Down}
KeyWait, LShIft, U
Send, {k Up}
SetTimer, ViewControlTemp, Off
SendEvent, {k Up}
Return

z::l ; 按下键盘Z键以发动人偶技

q::i ; 按下键盘Q键以发动必杀技

LButton::j ; 点按鼠标左键以发动普攻

RButton::k ; 点按鼠标右键以发动闪避/冲刺

*!LButton::LButton ; 按住ALT以正常使用鼠标左键
Expand Down
52 changes: 18 additions & 34 deletions BH3_Hotkey_Simplified.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ SwitchIME(dwLayout) ; 该段用于管理输入法,请勿删改
F1:: ; 暂停/ 启用程序——若想正常使用鼠标请按该键或按住ALT键
Suspend, Toggle
WinSet, AlwaysOnTop, Off, A
SetTimer, ViewControlTemp, Off
SetTimer, ViewControl, Off
SendInput, {Click, Up Middle}
SwitchIME(0x04090409) ; 切换至"中文(中国) 简体中文-美式键盘"
;Send, #{Space} ; [未启用命令行] 微软拼音用户可用该命令
Expand All @@ -78,7 +78,7 @@ Return

F3:: ; 重启程序以呼出操作说明界面
Suspend, Off
SetTimer, ViewControlTemp, Off
SetTimer, ViewControl, Off
SendInput, {Click, Up Middle}
Reload
Return
Expand All @@ -88,11 +88,11 @@ If (A_IsSuspended=0)
{
Suspend, On
WinSet, AlwaysOnTop, Off, A
SetTimer, ViewControlTemp, Off
SetTimer, ViewControl, Off
Send, {Click, Up Middle}
SwitchIME(0x04090409) ; 切换至"中文(中国) 简体中文-美式键盘"
;Send, #{Space} ; [未启用命令行] 微软拼音用户可用该命令
If (A_IsSuspended=1)
If (A_IsSuspended)
ToolTip, 暂停中, 0, 999 ; [可调校数值]
Sleep 99 ; [可调校数值]
Send, #{Tab}
Expand All @@ -107,11 +107,11 @@ If (A_IsSuspended=0)
{
Suspend, On
WinSet, AlwaysOnTop, Off, A
SetTimer, ViewControlTemp, Off
SetTimer, ViewControl, Off
SendInput, {Click, Up Middle}
SwitchIME(0x04090409) ; 切换至"中文(中国) 简体中文-美式键盘"
;Send, #{Space} ; [未启用命令行] 微软拼音用户可用该命令
If (A_IsSuspended=1)
If (A_IsSuspended)
ToolTip, 暂停中, 0, 999 ; [可调校数值]
Sleep 99 ; [可调校数值]
Send, !{Tab}
Expand All @@ -126,20 +126,13 @@ Return
ViewControl:
If WinActive("ahk_exe BH3.exe")
{
CoordMode, Window
WinGetPos, X, Y, Width, Height, ahk_exe BH3.exe ; 获取崩坏3游戏窗口参数(同样适用于非全屏)
MouseMove, Width/2, Height/2, 0 ; [建议保持数值] 使鼠标回正,居中于窗口
SendInput, {Click, Down Middle}
}
Return

ViewControlTemp:
If WinActive("ahk_exe BH3.exe")
{
Threshold = 1
MouseGetPos, x1, y1
Sleep, 1
MouseGetPos, x2, y2
If (x1<x2)
If (abs(x1-x2)>Threshold or abs(y1-y2)>Threshold)
SendInput, {Click, Down Middle}
Else If (x1<x2)
{
SendInput, {e Down}
Sleep, 1
Expand Down Expand Up @@ -195,6 +188,8 @@ If WinActive("ahk_exe BH3.exe")
SendInput, {q Up}{n Up}
Return
}
Else
SendInput, {Click, Up Middle}
}
Return

Expand All @@ -204,15 +199,16 @@ MButton:: ; 点击鼠标中键以激活视角跟随
M_Toggle:=!M_Toggle
If (M_Toggle)
{
SetTimer, ViewControlTemp, Off
SetTimer, ViewControl, -99 ; [[可调校数值]] 设定视角跟随命令的每执行间隔时间(ms)
CoordMode, Window
WinGetPos, X, Y, Width, Height, ahk_exe BH3.exe ; 获取崩坏3游戏窗口参数(同样适用于非全屏)
MouseMove, Width/2, Height/2, 0 ; [建议保持数值] 使鼠标回正,居中于窗口
SetTimer, ViewControl, 0, 0 ; [[可调校数值]] 设定视角跟随命令的每执行间隔时间(ms)
ToolTip, 视角跟随已激活, 0, 999 ; [可调校数值]
Sleep 999 ; [可调校数值]
ToolTip
}
else
Else
{
SetTimer, ViewControlTemp, Off
SetTimer, ViewControl, Off
SendInput, {Click, Up Middle}
ToolTip, 视角跟随已关闭, 0, 999 ; [可调校数值]
Expand All @@ -221,19 +217,7 @@ else
}
Return

LButton:: ; 点按鼠标左键以发动普攻
Send, {j Down}
If (M_Toggle)
{
If GetKeyState("LButton", "P")
{
SetTimer, ViewControl, Off
SetTimer, ViewControlTemp, 0 ; [[可调校数值]] 设定视角跟随命令的每执行间隔时间(ms)
}
}
KeyWait, LButton, U
Send, {j Up}
Return
LButton::j ; 点按鼠标左键以发动普攻

*!LButton::LButton ; 按住ALT以正常使用鼠标左键

Expand Down

0 comments on commit e1b2fb0

Please sign in to comment.