首页 > 解决方案 > 如何动态更新自动热键 GUI 元素

问题描述

我已经使用 AHK 创建了一个 GUI。我将 Id 和描述存储为键值对。我想在用户输入带有存储在关联数组中的相应 desc 的 ID 时更新 Desc。如何动态更新 GUI?

^h::

oKeys := []
oValues := []
oArray := {}


if (WinExist("ahk_id " hwndgui)) {
    Gui, Destroy
    return
}

gui, add, text,, Type:
Gui, Add, DropDownList,vType, TSO|PAX|DVI 
gui, add, text,, ID:
Gui, Add, Edit, vId
gui, add, text,, Partial|Complete:
Gui, Add, DropDownList,vPartial, Partial||Complete
gui, add, text,, Left-Behind:
Gui, Add, DropDownList,vLeft, False||True
gui, add, text,, XFR-Type:
Gui, Add, DropDownList,vXFR, Standard||Contact|Theft
gui, add, text,, DESC:
Gui, Add, Edit, vDesc , oArray[(TypeId)]
Gui, Add, Button, Default gOK, OK

Gui, Show, Hide

Gui, +LastFound
hwndgui:=WinExist()
OK:
Gui, Submit

oKeys.Push((TypeId))
oValues.Push((Desc))
Loop, % oKeys.Length()
oArray[oKeys[A_Index]] := oValues[A_Index]
    

if WinExist("labelImg")
    WinActivate  ; Uses the last found window.
    Send, ^a
    Send, %Type%_%Id%_%Partial%_%Desc%
    for vKey, vValue in oArray
    vOutput .= vKey " " vValue "`r`n"
    MsgBox, % vOutput
    
Gui, Show
return

标签: autohotkey

解决方案


推荐阅读