Re: UI Scripting, Safari and text field
Re: UI Scripting, Safari and text field
- Subject: Re: UI Scripting, Safari and text field
- From: "Timothy K. Wilkinson" <email@hidden>
- Date: Fri, 09 Jan 2004 10:20:26 -0500
I'm using GUI scripting because I've never JavaScripted in my life and don't
have the time at the moment to learn it.
Having said that I'm certainly not adverse to using it and I thank you very
much for your code. I can't seem to get it to work but I think it's more my
inabilities then the code.
Here is a code block that I've gotten to work. It's a little ugly but it
does get the job done for now (beware of line breaks):
--begin script --
tell application "Safari"
activate
end tell
tell application "System Events"
tell process "Safari"
set the clipboard to "some text"
set the_id to the clipboard
select text field 1 of scroll area 1 of group 2 of window "Add new
user"
click menu item "Paste" of menu "Edit" of menu bar item "Edit" of
menu bar 1
end tell
end tell
--end script--
I'll keep playing with different things but for now problem solved.
Thanks to everyone who responded.
Tim Wilkinson
ITC-ACHS
University of Virginia
email@hidden
>
From: Joshua See <email@hidden>
>
Date: Fri, 9 Jan 2004 08:22:11 -0600
>
To: "Timothy K. Wilkinson" <email@hidden>
>
Cc: AS lists <email@hidden>
>
Subject: Re: UI Scripting, Safari and text field
>
>
On Thursday, January 8, 2004, at 01:21 PM, Timothy K. Wilkinson wrote:
>
> I'm trying to use the UI Scripting to set a text field of a web page
>
> to a
>
> certain value.
>
>
>
> Using PreFab's UI Browser I came up with this script:
>
>
>
> tell application "System Events"
>
> tell process "Safari"
>
> set value of text field 1 of scroll area 1 of group 2 of
>
> window "Add
>
> new user" to "some text"
>
> end tell
>
> end tell
>
>
>
> This works on the surface. It puts the text into the field on the web
>
> page
>
> and everything seems fine. However when you click on the field the
>
> text
>
> disappears. If you don't select the field but just click the submit
>
> button
>
> then a blank value is submitted.
>
>
>
> What step am I missing to make that value stick in the web page?
>
Um, why script the GUI?
>
>
tell application "Safari"
>
set targetwin to some window whose name is "Add new user"
>
do JavaScript "document.forms[0].elements[0].value='some text';" in
>
targetwin
>
-- or document.formname.fieldname.value
>
end tell
>
>
Note that the first line in the tell block is "some"what whimsical, but
>
in real life you want to encase it in a try block in case no windows
>
matched, and add an if/then statement to throw an error on multiple
>
matches.
>
--
>
Sincerely,
>
Joshua See
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.