Re: Accessing a web page menu
Re: Accessing a web page menu
- Subject: Re: Accessing a web page menu
- From: julifos <email@hidden>
- Date: Thu, 13 Mar 2003 10:36:38 +0100
>
I would like to control a web menu (i.e. select a value of a pulldown
>
menu). I can't figure this out with the dictionary of iCab or Safari
>
(and Explorer is worse).
I'd say you can't access web page elements through UI scripting (but I'm not
sure).
Working with IE, this will return a comma-delimited list of contents of a
pop-up (I used
http://www.macscripter.net/):
########################################
tell application "Internet Explorer" to set options_ to (do script
"x=document.forms[0].elements[0].options.length;
var options_ = []
for(i=0;i<x;i++){
options_[i]=document.forms[0].elements[0].options[i].value;
}
options_")
set AppleScript's text item delimiters to ","
set options_ to options_'s text items
set AppleScript's text item delimiters to {""}
options_
--> {"#", "
http://macscripter.net", "#", "search.t", "#",
"
http://bbs.applescript.net/search.php", "
http://bbs.applescript.net", "#",
"
http://www.osaxen.com/index.php", "script-builder.t",
"
http://www.applemods.com", "
http://www.osaxen.com/studio", "#",
"dialog_studio.html", "tools.html", "#", "unscripted.html", "faq.html",
"magazine.html", "books.html", "swag.html", "badges.html", "aslinks.html",
"#", "hl.html", "upload.t"}
########################################
Through iCab, the javascript way is a little more tricky:
########################################
tell application "iCab"
set javascript_code to "function kk() {
x=document.forms[0].elements[0].options.length;
options_ = []
for(i=0;i<x;i++){
options_[i] = document.forms[0].elements[0].options[i].value;
}
options_ = options_.join(',');
z=window.open(options_,'','width=10,height=10');
}
kk()"
GetURL "javascript:" & javascript_code & ""
delay 1
set popup_options to item 1 of (GetWindowInfo -1)
close first window
set first_fake_item to (URL of first window)
end tell
set AppleScript's text item delimiters to ","
set popup_options to popup_options's text items
set AppleScript's text item delimiters to {""}
set item 1 of popup_options to (items ((first_fake_item's length) + 1) thru
-1 of (item 1 of popup_options) as text)
popup_options
--> {"#", "
http://macscripter.net", "#", "search.t", "#",
"
http://bbs.applescript.net/search.php", "
http://bbs.applescript.net", "#",
"
http://www.osaxen.com/index.php", "script-builder.t",
"
http://www.applemods.com", "
http://www.osaxen.com/studio", "#",
"dialog_studio.html", "tools.html", "#", "unscripted.html", "faq.html",
"magazine.html", "books.html", "swag.html", "badges.html", "aslinks.html",
"#", "hl.html", "upload.t"}
########################################
To access web page elements, I allways recommend the javascript way, and IE
is the most powerful in this task (let's see if the new Omniweb does the
homework, too).
JJ
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com
_______________________________________________
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.