interface-builderapplescript-studio

Applescript studio - how do I get every control in a window


I'm trying to enable or disable all the control in a window as the programme changes from interactive to non-interactive mode. How can I ask a window to give me all its contents?

every control of window "mainWindow"

doesn't work, nor does

contents of window "mainWindow"

Actually, I haven't been able to find any good documentation for interacting with menu items from interface builder at all. Things like how to set the contents of popups, and buttons and so on.

thanks

The way I do it at the moment is:

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)

I've made several lists of controls tht get turned on or off depending on the state the programme is in. But it has to be hard coded, which I don't see as being the best way.


Solution

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

    This script will give you as result all contents of front window of Adium: butons of window, tool bars of window, buttons of tool bars, etc. Enjoy =]