I'm very new to AppleScript and I'm trying to do this. I have an Safari process running on my machine. I wish I could go to the running safari and stimulate an enter key event.
Is it possible to do so?
The code I'm trying is:
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
set safRunning to is_running("Safari")
if safRunning then
run script "tell application \"Safari\"
key code 36
end tell"
return "Running"
else
return "Not running"
end if
Inside the run script
the key code 36
(for stimulating enter) is giving me error:
error "Expected end of line but found identifier." number -2741
Any guesses where I'm making mistake?
Best Answer
The "System Events" must to the key pressing.
for example:
I don't know, what the key pressing is for, so now has no effect.
A working example, where the download list is shown and then by pressing "space" the list is cleared: