I am working to make a script to interact with flash and in doing so I am forced to deal with non-existent objects. That is, at any point in time the object may or may not exist. I started out by writing a very rough conceptual program to make sure I could successfully timeout until objects exist and then click on them and through some effort I got that to work. However, I want modularity in the program and need to find a way to pass non-existent objects into a function that waits for the object to exist.
An example of what I mean -
This is the code that works:
This is the code that does not work - I get the error that the passed object does not exist
Furthermore, in this code, I get the error that the object does not exist and cannot pass it
Any tips would be much appreciated!
An example of what I mean -
This is the code that works:
tell application "System Events"
repeat
if UI element 1 of scroll area 1 of group 2 of window "Window-Name" of application process "Safari" exists then
exit repeat
else
delay 1
end if
end repeat
end tell
This is the code that does not work - I get the error that the passed object does not exist
Code:
on LoadObject(targetObject, targetName, loadThreshold)
set loadTime to 0
log_event("Loading " & targetName & "... " & loadTime)
repeat with loadTime from 0 to loadThreshold
try
if targetObject exists then
log_event("Loaded " & targetName)
return true
else
delay 1
log_event("Loading " & targetName & "... " & loadTime)
end if
end try
end repeat
log_event("Failed to load " & targetName)
return false
end LoadObject
Furthermore, in this code, I get the error that the object does not exist and cannot pass it
tell application "System Events"
set theElement to UI element 1 of scroll area 1 of group 2 of window "Window-Name" of application process "Safari"
end tell
Any tips would be much appreciated!