您可以使用#IfWinActive 更改热键或热字串,但不能创建脚本。
您需要检测窗口变化,并采取行动。
#SingleInstance
#installKeybdHook
#Persistent
Gui +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,Hwnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return
ShellMessage( wParam )
{
If (wParam = 4 or wParam = 32772) ; Without VMware Player running: wParam = 4, with VMware Player running: wParam = 32772
{
IfWinActive ahk_class VMPlayerFrame
{
SendInput, {Ctrl down}g{Ctrl up}
}
}
}
Return
; Hotkey {Win}+g launches Chrome
#g::Run "C:\Users\%A_Username%\AppData\Local\Google\Chrome\Application\chrome.exe"
; Hotkeys {Ctrl}+Nr gives you fractures
^2::
Send, ½
TrayTip, For 2 Squared,press Ctrl + Shift 2,1,1
Return
^3::
Send, ¾
TrayTip, For 3 Cubed,press Ctrl + Shift 3,1,1
Return
^4::Send, ¼
; HotKeys {Shift}+{Ctrl}+Nr gives you the power
+^0::Send, °
+^1::Send, ¹
+^2::Send, ² ; Shift Control 2@
+^3::Send, ³ ; Shift Control 3#
; Hotstrings mvge, mvgd or mvgf will give you my salutations in various languages.
:*:mvge::Regards,{Enter}{Enter}Robert Ilbrink
:*:mvgd::Mit freundlichen Grüßen,{Enter}{Enter}Robert Ilbrink
:*:mvgf::Salutions,{Enter}{Enter}Robert Ilbrink