I’m writing a bunch of actions for automator and one of them needs to create a new window and pass it values to two different text fields. The actions are written in python, but I can write the window in applescript. The trouble is I have no idea how to do this. Is there any simple way to pass values into fields of a window created in interface builder. app(‘Finder’).window(‘MyCustomWIndow’).text_fields[1].value.set(someValue) doesn’t work, nor does the equivalent applescript. Any help would be greatly appreciated.
Please note that I am using Xcode 4 on Lion, and I am using python 2.7.
Al
Model: Mac Pro dual hex core
Browser: Safari 534.51.22
Operating System: Mac OS X (10.7)
In your app delegate script, you’d have a property to the window:
property mainWindow : missing value
and that’s connected to the window in IB. And then you have a property for the text field, connected the same way:
property someTextField : missing value
Then you can tell the text field to set it’s value:
tell someTextField to setStringValue_(“some text”)
Or you could also bind the value of the field to a variable. And then you just set the variable, but remember to use “my” because that is the same as using KVC properly.
property boundVariableOfTextField : “initial value”
…
set my boundVariableOfTextField to theNewVariable
Will I have to call app delegate from my main.command script, or will this run when I instantiate my automator action in automator? I’m creating shell script actions, and so would need to append a delegate script inside my project.
Sorry I overlooked the “automator action” part. I am not sure, I’ve never made one of them. I’m not sure how much is involved, or how a delegate even fits into the project.