0

当我切换到 VMWare Player 时,我正在尝试向它发送输入。这样就不必按下Ctrl-g并让 VMWare 获取我的输入。以下是我想出的脚本,但它没有做任何事情。错过了什么?

#IfWinActive ahk_class VMPlayerFrame
{
    SendInput, {Ctrl down}g{Ctrl up}
}                                                                               return
4

1 回答 1

1

您可以使用#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
于 2013-03-14T06:19:20.693 回答