AutoHotkey的 - 当被点击窗口中的某个按钮触发脚本 [英] Autohotkey - Trigger script when a certain button was clicked in a window

查看:3758
本文介绍了AutoHotkey的 - 当被点击窗口中的某个按钮触发脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道实际的按钮的手感。我想检查是否被点击和按钮,如果是的话,将触发AutoHotkey的脚本。

I know the actual button's handle. What I would like to check if that button was clicked and if so that would trigger an autohotkey script.

在此先感谢!

推荐答案

您是对的。您可以使用它来代替ImgSearch。

You are right. You can use this instead of ImgSearch.

ControlGetPos, x, y, w, h, button1, ahk_class CalcFrame
MsgBox, %x% %y% %w% %h%
return

所以,你会在每次鼠标点击后运行ControlGetPos(只有当目标窗口的标题是活动的),然后比较实际的鼠标坐标与按钮的点击区域。

So you would have to run the ControlGetPos after each mouse click (only when the target window title is active) and then compare the actual mouse coordinates with the button click area.

下面是一些code的计算器:

Here is some code for the calculator:

#SingleInstance Force
#Persistent

#IfWinActive, ahk_class CalcFrame
    ~LButton::
    MouseGetPos, MouseX, MouseY
    ControlGetPos, ButtonX, ButtonY, ButtonW, ButtonH, button1, ahk_class CalcFrame
    ButtonX2:=ButtonX + ButtonW
    ButtonY2:=ButtonY + ButtonH
    if MouseX between %ButtonX% and %ButtonX2%
    {
        if MouseY between %ButtonY% and %ButtonY2%
        {
            MsgBox, You pressed the MC button
        }
    }
    Return
#IfWinActive

这篇关于AutoHotkey的 - 当被点击窗口中的某个按钮触发脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆