Ignoring Application Responses in JavaScript for Automation?

Hello. My title says it all, except for an answer. Anyone know one?

Hi.

I’d guess from the JXA release notes that the syntax would be something like:

I’ve not tried it though.

As I tested, passing event modifier {ignoring: ‘application responses’} doesn’t ignore application responses. I tested using following JXA script,


TextEdit = Application('TextEdit')
path = Path('/Users/123/Desktop/foo.rtf')

aResult = TextEdit.open(path, {ignoring: 'application responses'})

which returns result → Application(“TextEdit”).documents.byName(“foo.rtf”)

If {ignoring: ‘application responses’} worked, then TextEdit would not be able to return the result (document “foo.rtf”)

Here is equivalent AppleScript code, which opens the file, but doesn’t return the result (and this is correct behaviour) when ignoring application responses.


set |TextEdit| to application "TextEdit"
set |path| to "/Users/123/Desktop/foo.rtf"

ignoring application responses
	tell |TextEdit| to set aResult to open |path|
end ignoring

@KniazidisR

Try this instead.


result = TextEdit.open({path}, {ignoring: 'application responses'})

Should still open the “TextEdit.app”, but the script will return ‘null’, which is the equivalent of “missing value” in ‘JavaScript’

Regards Mark

I tried this syntax as well, among other testings. It opens the “TextEdit.app”, the script returns ‘null’, which is the equivalent of “missing value” in ‘JavaScript’, but the rtf on the indicated path is not open. Instead, TextEdit opens choose file dialog…

I think this is another JXA bug that I know has been abandoned by the developers. For this reason I also avoid using it. It’s a pity for the rest of the users who are used to using JXA.

@KniazidisR

On my “High Sierra” boot partition at the moment, and the code opens a new “Untitled” document for me on that OS, and returns ‘null’, so different results from the same code to your “Catalina” system.

JXA was half baked when it was introduced, and it hasn’t got any better over the years.
It was introduced because “Apple” wanted to dump “AppleScript”, but was never popular.

Regards Mark

Would there be any point filing a bug report with Apple? If so, how would I go about it? --Jonathan

@drjlevi6,

It’s always best to showcase specific examples so that you don’t get ignored. You can just copy post #3 or link to the entire topic. In addition, somewhere on this site @Shane Stanley already posted a link where it is better to contact about bugs. Perhaps some user will show it to you again.

Hi KniazidisR.

Thanks for looking into this. It seems to be yet another thing in JXA that doesn’t actually work. Looking back over my brief foray into JXA a couple of years ago, the only thing I can find which does work is to run the equivalent AppleScript code from within the JXA code using the StandardAdditions run script command. (Tested in Mojave. Success is judged from ‘null’ appearing in Script Editor’s Result pane fractionally before the document opens. The result’s different and slightly later when ‘ignoring’ is changed to ‘considering’.):

var app = Application.currentApplication();
app.includeStandardAdditions = true;

var appName = `TextEdit`;
var filePath = app.pathTo(`desktop`, {as: `text`}) + `foo.rtf`;

var runScriptText = `on run params
	set {appName, filePath} to params
	ignoring application responses
		tell app appName to (open file filePath)
	end
end`;

app.runScript(runScriptText, { withParameters: [appName, filePath], in: `AppleScript`});