Last active
August 20, 2023 01:24
-
-
Save zyr17/19b14710d4de3e3b1603a31d15faddc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; save it as GB18030 ;;; | |
;;; 你用GB18030保存或者打开了吗 ;;; | |
;;;;;; RapidHotkey ;;;;;; | |
RapidHotkey(keystroke, times="2", delay=0.2, IsLabel=0) | |
{ | |
Pattern := Morse(delay*1000) | |
If (StrLen(Pattern) < 2 and Chr(Asc(times)) != "1") | |
Return | |
If (times = "" and InStr(keystroke, """")) | |
{ | |
Loop, Parse, keystroke,"" | |
If (StrLen(Pattern) = A_Index+1) | |
continue := A_Index, times := StrLen(Pattern) | |
} | |
Else if (RegExMatch(times, "^\d+$") and InStr(keystroke, """")) | |
{ | |
Loop, Parse, keystroke,"" | |
If (StrLen(Pattern) = A_Index+times-1) | |
times := StrLen(Pattern), continue := A_Index | |
} | |
Else if InStr(times, """") | |
{ | |
Loop, Parse, times,"" | |
If (StrLen(Pattern) = A_LoopField) | |
continue := A_Index, times := A_LoopField | |
} | |
Else if (times = "") | |
continue := 1, times := 2 | |
Else if (times = StrLen(Pattern)) | |
continue = 1 | |
If !continue | |
Return | |
Loop, Parse, keystroke,"" | |
If (continue = A_Index) | |
keystr := A_LoopField | |
Loop, Parse, IsLabel,"" | |
If (continue = A_Index) | |
IsLabel := A_LoopField | |
hotkey := RegExReplace(A_ThisHotkey, "[\*\~\$\#\+\!\^]") | |
IfInString, hotkey, %A_Space% | |
StringTrimLeft, hotkey,hotkey,% InStr(hotkey,A_Space,1,0) | |
backspace := "{BS " times "}" | |
keywait = Ctrl|Alt|Shift|LWin|RWin | |
Loop, Parse, keywait, | | |
KeyWait, %A_LoopField% | |
If ((!IsLabel or (IsLabel and IsLabel(keystr))) and InStr(A_ThisHotkey, "~") and !RegExMatch(A_ThisHotkey | |
, "i)\^[^\!\d]|![^\d]|#|Control|Ctrl|LCtrl|RCtrl|Shift|RShift|LShift|RWin|LWin|Alt|LAlt|RAlt|Escape|BackSpace|F\d\d?|" | |
. "Insert|Esc|Escape|BS|Delete|Home|End|PgDn|PgUp|Up|Down|Left|Right|ScrollLock|CapsLock|NumLock|AppsKey|" | |
. "PrintScreen|CtrlDown|Pause|Break|Help|Sleep|Browser_Back|Browser_Forward|Browser_Refresh|Browser_Stop|" | |
. "Browser_Search|Browser_Favorites|Browser_Home|Volume_Mute|Volume_Down|Volume_Up|MButton|RButton|LButton|" | |
. "Media_Next|Media_Prev|Media_Stop|Media_Play_Pause|Launch_Mail|Launch_Media|Launch_App1|Launch_App2")) | |
Send % backspace | |
If (WinExist("AHK_class #32768") and hotkey = "RButton") | |
WinClose, AHK_class #32768 | |
If !IsLabel | |
Send % keystr | |
else if IsLabel(keystr) | |
Gosub, %keystr% | |
Return | |
} | |
Morse(timeout = 400) { ;by Laszo -> http://www.autohotkey.com/forum/viewtopic.php?t=16951 (Modified to return: KeyWait %key%, T%tout%) | |
tout := timeout/1000 | |
key := RegExReplace(A_ThisHotKey,"[\*\~\$\#\+\!\^]") | |
IfInString, key, %A_Space% | |
StringTrimLeft, key, key,% InStr(key,A_Space,1,0) | |
If Key in Shift,Win,Ctrl,Alt | |
key1:="{L" key "}{R" key "}" | |
Loop { | |
t := A_TickCount | |
KeyWait %key%, T%tout% | |
Pattern .= A_TickCount-t > timeout | |
If(ErrorLevel) | |
Return Pattern | |
If key in Capslock,LButton,RButton,MButton,ScrollLock,CapsLock,NumLock | |
KeyWait,%key%,T%tout% D | |
else if Asc(A_ThisHotkey)=36 | |
KeyWait,%key%,T%tout% D | |
else | |
Input,pressed,T%tout% L1 V,{%key%}%key1% | |
If (ErrorLevel="Timeout" or ErrorLevel=1) | |
Return Pattern | |
else if (ErrorLevel="Max") | |
Return | |
} | |
} | |
;;;;;; RapidHotkey ;;;;;; | |
; check window title and path | |
; F1:: | |
; WinGetTitle, Title, A | |
; WinGet, Path, ProcessPath, A | |
; MsgBox, The active window is "%Title%", path is "%Path%". | |
; return | |
hwndBeforeDict := | |
$Escape:: | |
if WinActive("ahk_exe 百度翻译.exe") | |
{ | |
; MsgBox, in baidu translate | |
Send, ^+!q | |
Sleep, 250 | |
; MsgBox, "%hwndBeforeDict%" | |
if hwndBeforeDict { | |
; MsgBox, have last active "%hwndBeforeDict%" | |
; WinGet, lastid, IDLast | |
; MsgBox, have last id "%lastid%" | |
; Winactivate, ahk_id %hwndBeforeDict% | |
; Send, !{Tab} | |
} | |
} | |
else{ | |
Send, {Escape} | |
} | |
return | |
CapsLock:: | |
GoSub, $Escape | |
return | |
+ScrollLock::^+!F9 | |
ScrollLock::Media_Play_Pause | |
+F10::Suspend, Toggle | |
;;;;;; volume change, music prev and next ;;;;;; | |
;F7:VolumeDown, F8:VolumeUp, F87:prev, F78:next | |
pf7 := False | |
pf8 := False | |
F7:: | |
Send {Volume_Down} | |
pf7 := True | |
if (pf8) | |
{ | |
;MsgBox, "you try to prev", %pf7% %pf8% | |
Send {Media_Prev} | |
} | |
return | |
F7 Up:: | |
pf7 := False | |
return | |
F8:: | |
Send {Volume_Up} | |
pf8 := True | |
if (pf7){ | |
;MsgBox, "you try to next", %pf7% %pf8% | |
Send {Media_Next} | |
} | |
return | |
F8 Up:: | |
pf8 := False | |
return | |
F9::Volume_Mute | |
;;;;;; volume change, music prev and next ;;;;;; | |
~RControl::RapidHotkey("Dictionary""Search", 2, 0.2, 1) | |
Dictionary: | |
WinGet, hwndBeforeDict, ID, A | |
Send +!q | |
SetKeyDelay, 150 | |
return | |
Search: | |
Send ^c | |
;SetKeyDelay, 150 | |
EnvGet, browserpath, FIREFOX_PATH | |
Run "%browserpath%firefox.exe" "https://www.baidu.com/baidu?wd=%clipboard%" | |
return | |
;;;;;; YuanShen Change Hotkey ;;;;;; | |
SendMode Input | |
;#ifWinActive ahk_class UnityWndClass | |
;#ifWinActive ahk_exe YuanShen.exe ; || WinActive("ahk_exe YuanShen.exe") | |
;#ifWinActive ahk_exe "Genshin Impact Cloud Game.exe" | |
#If WinActive("ahk_exe YuanShen.exe") || WinActive("ahk_exe Genshin Impact Cloud Game.exe")|| WinActive("ahk_exe StarRail.exe") | |
{ | |
LAlt:: | |
while GetKeyState("LAlt", "P") | |
{ | |
Send g | |
Sleep 100 | |
} | |
return | |
f:: | |
while GetKeyState("f", "P") | |
{ | |
Send g | |
Sleep 100 | |
} | |
return | |
`::LAlt | |
;NumpadSub::Suspend, Toggle | |
NumLock:: | |
baseX := 1926 | |
baseY := 1109 | |
WinGetPos, , , Width, Height, A | |
scaleX := Width / baseX | |
scaleY := Height / baseY | |
if scaleX / scaleY > 1.1 || scaleY / scaleX > 1.1 | |
{ | |
MsgBox, "resolution is not 16:9, fail" | |
return | |
} | |
addArtX := 1248 * scaleX | |
addArtY := 900 * scaleY | |
btnX := 1720 * scaleX | |
btnY := 1045 * scaleY | |
dogX := 364 * scaleX | |
dogY := 215 * scaleY | |
dogDeltaX := 142 * scaleX | |
;MsgBox, "%Width% %Height% %scaleX% %scaleY%" | |
MouseMove, addArtX, addArtY | |
Click, 1 | |
Loop, 6 | |
{ | |
MouseMove, dogX, dogY | |
Click, 1 | |
dogX := dogX + dogDeltaX | |
} | |
MouseMove, btnX, btnY | |
Click, 1 | |
return | |
NumpadSub:: | |
baseX := 1926 | |
baseY := 1109 | |
WinGetPos, , , Width, Height, A | |
scaleX := Width / baseX | |
scaleY := Height / baseY | |
if scaleX / scaleY > 1.1 || scaleY / scaleX > 1.1 | |
{ | |
MsgBox, "resolution is not 16:9, fail" | |
return | |
} | |
allX := 1760 * scaleX | |
allY := 795 * scaleY | |
btnX := 1720 * scaleX | |
btnY := 1045 * scaleY | |
confirmX := 980 * scaleX | |
confirmY := 855 * scaleY | |
;MsgBox, "%Width% %Height% %scaleX% %scaleY%" | |
MouseMove, allX, allY | |
Click, 1 | |
MouseMove, btnX, btnY | |
Click, 1 | |
MouseMove, confirmX, confirmY | |
return | |
NumpadAdd:: | |
baseX := 1926 | |
baseY := 1109 | |
WinGetPos, , , Width, Height, A | |
scaleX := Width / baseX | |
scaleY := Height / baseY | |
if scaleX / scaleY > 1.1 || scaleY / scaleX > 1.1 | |
{ | |
MsgBox, "resolution is not 16:9, fail" | |
return | |
} | |
btnX := 1720 * scaleX | |
btnY := 1045 * scaleY | |
slideX1 := 1170 * scaleX | |
slideX2 := 1200 * scaleX | |
slideY := 625 * scaleY | |
confirmX := 1185 * scaleX | |
confirmY := 800 * scaleY | |
;MsgBox, "%Width% %Height% %scaleX% %scaleY%" | |
MouseMove, btnX, btnY | |
Click, 1 | |
MouseClickDrag, L, slideX1, slideY, slideX2, slideY | |
MouseMove, confirmX, confirmY | |
return | |
NumpadEnter:: | |
Click, 1 | |
return | |
\:: | |
Click, 1 | |
return | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment