122 lines
2.8 KiB
AutoHotkey
122 lines
2.8 KiB
AutoHotkey
#Requires AutoHotkey v2.0
|
|
#SingleInstance Force
|
|
|
|
; Ctrl -> Mac Command for NetEase UU Remote only.
|
|
; Default target found on this machine:
|
|
; C:\Program Files\Netease\GameViewer\GameViewer.exe
|
|
|
|
SendMode "Input"
|
|
SetTitleMatchMode 2
|
|
|
|
global MapEnabled := true
|
|
global MapWholeCtrlKey := true
|
|
|
|
A_TrayMenu.Delete()
|
|
A_TrayMenu.Add("Toggle mapping (Shift+F12)", ToggleMapping)
|
|
A_TrayMenu.Add("Copy active window info (Shift+F11)", CopyActiveWindowInfo)
|
|
A_TrayMenu.Add()
|
|
A_TrayMenu.Add("Exit", (*) => ExitApp())
|
|
|
|
ShowHint("UU Mac Ctrl mapping is on")
|
|
|
|
#HotIf IsUURemoteActive() && MapWholeCtrlKey
|
|
LCtrl::LWin
|
|
RCtrl::RWin
|
|
#HotIf
|
|
|
|
; Safer fallback mode if full Ctrl remapping ever conflicts with the Windows shell.
|
|
; Change MapWholeCtrlKey above to false to use only these common Mac shortcuts.
|
|
#HotIf IsUURemoteActive() && !MapWholeCtrlKey
|
|
^a::MacCmd("a")
|
|
^c::MacCmd("c")
|
|
^f::MacCmd("f")
|
|
^n::MacCmd("n")
|
|
^o::MacCmd("o")
|
|
^p::MacCmd("p")
|
|
^q::MacCmd("q")
|
|
^s::MacCmd("s")
|
|
^t::MacCmd("t")
|
|
^v::MacCmd("v")
|
|
^w::MacCmd("w")
|
|
^x::MacCmd("x")
|
|
^z::MacCmd("z")
|
|
^+z::MacCmdShift("z")
|
|
^Tab::MacCmd("{Tab}")
|
|
^+Tab::MacCmdShift("{Tab}")
|
|
^Space::MacCmd("{Space}")
|
|
#HotIf
|
|
|
|
+F12::ToggleMapping()
|
|
+F11::CopyActiveWindowInfo()
|
|
|
|
IsUURemoteActive() {
|
|
global MapEnabled
|
|
|
|
if !MapEnabled
|
|
return false
|
|
|
|
hwnd := WinExist("A")
|
|
if !hwnd
|
|
return false
|
|
|
|
try {
|
|
exe := WinGetProcessName("ahk_id " hwnd)
|
|
title := WinGetTitle("ahk_id " hwnd)
|
|
className := WinGetClass("ahk_id " hwnd)
|
|
} catch {
|
|
return false
|
|
}
|
|
|
|
if RegExMatch(exe, "i)^(GameViewer|GameViewerClient|GameViewer64|UURemote|NeteaseUU.*)\.exe$")
|
|
return true
|
|
|
|
return InStr(title, "UU远程")
|
|
|| InStr(title, "网易UU")
|
|
|| InStr(title, "GameViewer")
|
|
|| InStr(className, "GameViewer")
|
|
}
|
|
|
|
MacCmd(key) {
|
|
Send("{LWin down}" . key . "{LWin up}")
|
|
}
|
|
|
|
MacCmdShift(key) {
|
|
Send("{LWin down}{Shift down}" . key . "{Shift up}{LWin up}")
|
|
}
|
|
|
|
ToggleMapping(*) {
|
|
global MapEnabled
|
|
MapEnabled := !MapEnabled
|
|
ShowHint("UU Mac Ctrl mapping is " . (MapEnabled ? "on" : "off"))
|
|
}
|
|
|
|
CopyActiveWindowInfo(*) {
|
|
hwnd := WinExist("A")
|
|
if !hwnd {
|
|
ShowHint("No active window found")
|
|
return
|
|
}
|
|
|
|
try {
|
|
title := WinGetTitle("ahk_id " hwnd)
|
|
exe := WinGetProcessName("ahk_id " hwnd)
|
|
className := WinGetClass("ahk_id " hwnd)
|
|
} catch as err {
|
|
ShowHint("Could not read active window: " . err.Message)
|
|
return
|
|
}
|
|
|
|
info := "Title: " . title . "`n"
|
|
. "Process: " . exe . "`n"
|
|
. "Class: " . className . "`n"
|
|
. "AHK target: ahk_exe " . exe . " ahk_class " . className
|
|
|
|
A_Clipboard := info
|
|
ShowHint("Active window info copied to clipboard")
|
|
}
|
|
|
|
ShowHint(text) {
|
|
ToolTip(text)
|
|
SetTimer(() => ToolTip(), -1800)
|
|
}
|