0

当程序从交互模式变为非交互模式时,我正在尝试启用或禁用窗口中的所有控件。我怎样才能要求一个窗口给我它的所有内容?

every control of window "mainWindow"

不工作,也不

contents of window "mainWindow"

实际上,我根本找不到任何好的文档来与界面生成器中的菜单项进行交互。诸如如何设置弹出窗口和按钮的内容等。

谢谢

我目前的做法是:

property onlineControls: {"maxLength", "speed", "accelerationSlider", "accelerationField", "showInfo"} --and so on, listing all the controls by name

on enableControls(theList, enableState)
    tell window "mainWindow"
        repeat with theControl in theList
            set the enabled of control theControl to enableState
        end repeat
    end tell

enableControls(onlineControls, true)

我已经列出了几个控件列表,这些控件可以根据程序所处的状态打开或关闭。但它必须是硬编码的,我认为这不是最好的方法。

4

3 回答 3

2
tell application "System Events"
    tell process "Adium"
        get entire contents of window 1
    end tell
end tell

这个脚本会给你 Adium 前窗口的所有内容:窗口按钮、窗口工具栏、工具栏按钮等。享受 =]

于 2010-05-11T01:10:55.443 回答
0

我还没有找到一种方法来获取窗口中的所有控件,但这里有一个与弹出按钮的菜单交互的示例:

tell menu of popup button "somePopupButton" of window "mainWindow"
    delete every menu item
    repeat with i in someItems
        make new menu item at end of menu items ¬
            with properties {title:i, enabled:true}
    end repeat
end tell
于 2010-03-25T04:20:08.500 回答
0

是与“BoB1990”相同的脚本,有可能取回由获取窗口的全部内容提供的信息,您可以在字符串中观察或修改列出的所有项目:

tell application "System Events" to tell process "Adium" 

    set this_info to {} 

    try

    display alert ((get entire contents of window (x as integer)))      

    on error errMsg set theText to errMsg 

    set this_info to do shell script " echo " & theText & " | sed 's#System Events got an error: Can’t make ##g;s# into type string.##g'"

    end try 

    set info to {} 

    set info to do shell script " echo " & this_info 

    display alert (info) 

    end tell
于 2016-11-07T06:53:40.300 回答