1

I would like to use JavaScript for automation (mac JXA) to make a NSWindow and show it to the user.

I tried following this example, but it crashes when I run it in the Script Editor app.

Then I tried to make my own using barebones. As a start I just want a window with a title in it.

ObjC.import("Cocoa")

var window = $.NSWindow.alloc.init
window.setContentSize($.NSMakeSize(500, 500))
window.title = "hello world"
window.makeKeyAndOrderFront(window)

When I try to run this in Script Editor the app crashes right away. It appears to be crashing when I try to initialize the NSWindow Object.

Am I doing something wrong?

DerrickHo328
  • 4,664
  • 7
  • 29
  • 50

1 Answers1

1

I followed this guide and they say you have to save it as an application and run it as an application.

Heres a clip where they mention it in the article. enter image description here

DerrickHo328
  • 4,664
  • 7
  • 29
  • 50