📜  youtube 背景 ahk - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:06.527000             🧑  作者: Mango

代码示例1
;play/pause youtube video in background (Chrome)
#Persistent
#NoEnv
#SingleInstance, Force
DetectHiddenWindows, On
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 2
controlID         := 0
return

#IfWinNotActive, ahk_exe dragon.exe

ctrl & space::
    ControlGet, controlID, Hwnd,,Chrome_RenderWidgetHostHWND1, Google Chrome
    ControlFocus,,ahk_id %controlID%
    IfWinExist, YouTube    
{
        ControlSend, Chrome_RenderWidgetHostHWND1, k , Google Chrome
        return
    }
    ControlSend, , ^1, Google Chrome
    Loop
{
        IfWinExist, YouTube
        {
            break
        }
        ControlSend, ,{Control Down}{Tab}{Control Up}, Google Chrome
        Sleep, 150
    }
    Sleep, 50
    ControlSend, Chrome_RenderWidgetHostHWND1, k , Google Chrome
return
#IfWinNotActive