2

在 Autohotkey 中,有没有办法检测什么 gui 控件具有焦点,以便我显示一个带有基本工具提示的文本框。

我想将鼠标悬停或使用键盘导航并在多行文本框中显示将存储在工具提示中的内容。

我不想有工具提示。

4

3 回答 3

1
OnMessage(0x0200, "WM_MOUSEMOVE") ; WM_MOUSEMOVE 0x0200

Return

WM_MOUSEMOVE(wParam, lParam)
{
 global Control_Name
  X := lParam & 0xFFFF
  Y := lParam >> 16
 MouseGetPos, , , , Control_Name
 Tooltip, %Control_Name%, (x+150), (y+150)
}

Esc::ExitApp
于 2020-04-17T10:08:14.253 回答
0

知道了!;-)

我观察鼠标是否移动,或者控件是否具有焦点并在文本框中显示一些存储的值

#Persistent
SetTimer, WatchCursor, 100
return

WatchCursor:
MouseGetPos, mx, my, id, mouseControl
ControlGetFocus, currentFocus, A

if (SubStr(mouseControl,1,6)= "Button" OR SubStr(currentFocus,1,6)= "Button")
    butIDkey := SubStr(currentFocus,7,2)
    butIDmouse := SubStr(mouseControl,7,2)

    if (SubStr(mouseControl,1,6)= "Button" && lastmx <> mx && lastmy <> my)
        butID := butIDmouse 

    if (butIDkey <> lastControl) 
        butID := butIDkey

    lastControl :=  butIDkey
    lastmx := mx
    lastmy := my

    GuiControl,TemplateEngine:, MyTooltip,  % Value%butID%
}
return
于 2012-12-17T18:13:48.387 回答
0

ControlGetFocus用于获取名称。请参阅下面的示例代码

a::
ControlGetFocus, OutputVar, A
if ErrorLevel
    MsgBox, The target window doesn't exist or none of its controls has input focus.
else
    MsgBox, Control with focus = %OutputVar%
于 2012-12-17T17:14:09.457 回答