[Pythonmac-SIG] Re: Pythonmac-SIG] AppScripting Safari
has
hengist.podd at virgin.net
Wed Jan 14 06:08:40 EST 2004
John Weeks wrote:
>I am experimenting with AppScripting and Safari and I have a question
>about how to translate the "do JavaScript" command into the form
>AppScripting expects.
From the manual:
======= Notes on Identifier Mangling =======
Because aete resources do not specify C-style identifiers, appscript
applies the following name mangling rules to convert
AppleScript-style identifiers to Python-compatible format:
- Characters a-z, A-Z, 0-9 and underscores are preserved.
- Spaces and hyphens are replaced with underscores.
- All other characters are converted to 0X00-style hexadecimal representations.
- Names that match Python keywords or words reserved by appscript
have an underscore appended.
So in this case:
do JavaScript "document.readyState" in document 1
becomes:
safari.do_JavaScript('document.readyState', in_=safari.documents[0])
-------
Of course, the easiest thing is to use doc() to get the correct
terms; which brings us to:
>As I was trying to solve the problem with AppScripting and Safari, I
>tried to get the AppScripting doc function to work.
>[...]
>But I am getting an error.
>
>TypeError: Template() takes at least 2 arguments (1 given)
My bad: the HTMLTemplate API has changed since AppScripting 0.3.1 was
released. You'll need to use HTMLTemplate 0.2.0 for now.
Any other problems/questions, please fire away.
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
More information about the Pythonmac-SIG
mailing list