Hello. I keep getting this error when I try to grab some text from an application using gui scripting:
Whts the matter?
thanks,
elictricocean
Hello. I keep getting this error when I try to grab some text from an application using gui scripting:
Whts the matter?
thanks,
elictricocean
Compile those classes in a separate script to see the more-friendly enumeration (if one exists):
tell application "System Events"
«class sttx»
«class pcap»
end tell
«class sttx» is System Events’ static text and «class pcap» is System Events’ application process.
When I compile this code in Script Editor, it is automatically rewritten with the official vocabulary terms:
tell application "System Events"
{pcap:«class pcap»,sttx:«class sttx»} --> {pcap:application process, sttx:static text}
end tell
Somewhere in your script you have some code that trying to access static text “cool string” of window “Inspector” of application process “New Application” inside a tell block that is targeted at the System Events application. The actual code may look different from this “. of . of . of .” syntax because you can also do the same element traversal with tell blocks (tell application process “New Application” to tell window “Inspector” to get static text “cool string”) or it can be done with the possessive reference form (application process “New Application”'s window “Inspector”'s static text “cool string”). And any of those forms can be broken up into multiple stages so that the final reference might be only foo’s static text s where foo is the window object and s is the string with value cool string.
Unfortunately I cannot provide any clues as to why this particular access is failing. Seeing some or all of the code that is causing this error might help folks diagnose the problem. You might try poking at the application with Accessibility Inspector from the Mac OS X developer tools (/Developer/Applications/Utilities/Accessibility Tools/Accessibility Inspector.app) or some other UI inspecting tool (I hear Prefab’s UI Browser is nice) to see what is going on in the GUI of “New Application”.
Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari 3.0.4 (523.12)
Operating System: Mac OS X (10.4)
yes I am just calling
Try this:
tell application "System Events"
tell application process "New Application"
-- I assume your code was in a tell block like this code is.
set info to static text of window "Inspector" -- info is a list of every top-level static text UI element of the window
set tName to the item 1 of info -- tName now holds the first (top-level) static text object from the window
-- If you want the string that the static text UI element is displaying use "value of tName" or maybe "name of tName".
-- To see all the properties of the object: "return properties of tName"
if value of tName contains "word" then -- the "contains" operator expects a list, record or string as the first argument, which is what your error messages is about.
-- Do something
end if
end tell
end tell
Summary: Since tName is a static text object (not a string object), you will need to use value of to get the string that the static text object is displaying.
You can also put all the references together in the conditional’s text expression like this (assuming the appropriate tell context): if value of first static text of window “Inspector” contains ..
Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari 3.0.4 (523.12)
Operating System: Mac OS X (10.4)