Applescript/Applescript Studio help

Hi all,

I’m a new Applescripter and am working on a small GUI interface to a Unix app. I know some Perl but I’m still a little dumbfounded on how to get at data in AS. I’ve built a GUI with three text input boxes (NSTextField according to “Show Info”). I’ve put these boxes inside a “NSTabViewItem”. The Applescript names I assigned are username, password, other. I’m trying to get the value of the text field with the following AS code:

set theUserName to contents of text field "username" of "Unix App GUI" as text

Although the script compiles, I get errors when clicking the “Action” button in the “on clicked theObject” subroutine.

I’m also trying to check to see if a checkbox is checked with the following:


set useMotionEvents to contents of button "motion" as boolean

if (useMotionEvents) then <blah blah>...

I get an error that the value can’t be of type boolean.

If anyone can point me in the right direction, I would really appreciate it.

Thanks,
Charles


Hmmm… Untested, but it should be anything such as:

set varName to contents of text field "whatever" of tab group "whatever" of window "whatever"

You can target these items by name or index.
And the same syntax may work for the checkbox… Untested, too, but “contents” of the checkbox property should be already a boolean, so you don’t need re-coerce it.

Tell us!

I did finally get to the data in the text field.


tell window of theObject
set theVar to contents of text field "whatever" of tab view item "whatever" of tab view "tabs" as text
end tell

This is a big learning curve for me as it is nothing like Perl :slight_smile:

Thanks,
Charles