【问题标题】:Autohotkey Simple ControlSend to Google ChromeAutohotkey Simple Control发送到谷歌浏览器
【发布时间】:2016-12-02 00:52:48
【问题描述】:

编辑工作版本

!j::
SetTitleMatchMode, 2

ControlGet, OutputVar, Hwnd,,Chrome_RenderWidgetHostHWND1, Google Chrome

ControlFocus,,ahk_id %outputvar%


ControlSend, , {Space} , Google Chrome

原帖:

DetectHiddenWindows, on
!j::
IfWinExist, ahk_exe chrome.exe
ControlSend, ahk_exe chrome.exe, {SPACE}
return

我想要的是能够在通过 chrome 播放的 youtube 视频上切换播放/暂停。 chrome 窗口不是活动窗口,而是显示在我的第二台显示器上。我尝试使用 WindowSpy 的 ahk_class Chrome_WidgetWin_1 并使用 ClassNN 进行 ControlClick:Chrome_RenderWidgetHostHWND1 但似乎没有正确发送 {SPACE} 或 CLICK 来暂停视频。

WindowSpy 信息(视频标题会不一致):

Calculus 2 Lecture 10.2: Introduction to Parametric Equations - YouTube - Google Chrome
ahk_class Chrome_WidgetWin_1
ahk_exe chrome.exe

Absolute:   -908, 634 (less often used)
Relative:   1012, 634 (default)
Client: 1012, 634 (recommended)

ClassNN:    Intermediate D3D Window1
Text:   
Color:  05070D (Red=05 Green=07 Blue=0D)
    x: 0    y: 0    w: 1920 h: 1080
Client: x: 0    y: 0    w: 1920 h: 1080

Chrome Legacy Window
Chrome Legacy Window

Chrome Legacy Window
Chrome Legacy Window

【问题讨论】:

    标签: google-chrome autohotkey


    【解决方案1】:

    请先查阅文档:https://autohotkey.com/docs/commands/ControlSend.htm

    ControlSend, Control, Keys, WinTitle
    

    当你有的时候

    ControlSend, ahk_exe chrome.exe, {SPACE}
    

    ahk_exe chrome.exe 被视为valid WinTitle 参数,NOT 为有效Control

    因此,你想要的是:

    ControlSend,,{SPACE},ahk_exe chrome.exe
    

    此外,您可以在ControlSend 文档中阅读:

    如果此 (Control) 参数为空白或省略,则目标窗口的最顶层 将使用控件。如果此参数为ahk_parent,则击键 将直接发送到目标窗口,而不是它的一个 控制

    所以如果上面的代码行不适合你,你可能想使用:

    ControlSend,ahk_parent,{SPACE},ahk_exe chrome.exe
    

    【讨论】:

      猜你喜欢
      • 2010-10-08
      • 2021-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-21
      • 2012-08-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多