【问题标题】:autohotkey focus no title自动热键焦点没有标题
【发布时间】:2016-05-02 03:37:49
【问题描述】:

在软件安装过程中,我一直试图将焦点集中在 Windows 上。窗口没有标题。脚本一直失败。有人可以让我知道我的脚本是否有什么可以更改的吗?

这应该可以点击确定按钮:

 Sleep, 4000.
 Send, {control down}
 MouseClick, Left, 300, 185,
 Send, {Control up}

结果是它会在 Windows 开始菜单旁边打开 Google Chrome,而不是单击桌面中间打开窗口上的确定位置。

我的完整脚本如下:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
;#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Sleep, 1000 ;language selection and next.
Send, {tab}
Sleep, 500
Send, {tab}
Sleep, 500
Send, {tab}
Sleep, 500
Sleep, 2000
Send, {Enter}

Sleep, 1000 ;directory and installation.
Send, {tab}
Sleep, 500
Send, {tab}
Sleep, 500
Send, {tab}
Sleep, 500
Send, {tab}
Sleep, 500
Send, {tab}
Sleep, 5000
Send, {Enter}
Sleep, 500
Send, {tab}
Sleep, 5000 ;for installation wait time.
Send, {Enter}   ;finish.

Sleep, 7000
Run "myexecutable.exe"

Sleep, 4000 ;focus attempt 2.
Send, {control down}
MouseClick, Left, 300, 185,
Send, {Control up} ;for association OK.

【问题讨论】:

    标签: focus autohotkey


    【解决方案1】:

    您可以在相对模式下使用鼠标点击:

    CoordMode, Mouse, Window
    

    这将使点击的坐标相对于活动窗口而不是屏幕。

    因此,计算您需要点击的窗口位置的新坐标,并确保该窗口处于活动状态。

    要获取窗口句柄,请使用程序的可执行名称。例如激活一个窗口,而不是参数WinTitle使用ahk_exe和进程名称:

    WinActivate, ahk_exe myexecutable.exe
    

    【讨论】:

    • 感谢您的回复。实际问题是窗口没有“获取”焦点。它没有显示标题,也没有“隐藏”标题。我确实尝试了不同的方法来关注那个弹出窗口,但没有一个奏效。有趣的是,尝试相对于 SCREEN 的坐标有时会奏效,但在 97% 的情况下都失败了(使用完全相同的编码)。此外,当我将它作为一个独立的 sn-p 进行测试时,它的成功率更高(50%),为精确编码绘制坐标(空白窗口标题选项)。
    猜你喜欢
    • 2010-11-09
    • 1970-01-01
    • 2012-10-13
    • 1970-01-01
    • 2013-08-02
    • 2012-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多