0

I'm stuck on trying to activate a window in OSX from node using nodobjc.

Here's what I have:

var $ = require('nodobjc');
$.framework('Cocoa');

//found window is returned from CGWindowListCopyWindowInfo left out for brevity's sake
const app = $.NSRunningApplication('runningApplicationWithProcessIdentifier',foundWindow.kCGWindowOwnerPID);

app('activateWithOptions', 'NSApplicationActivateAllWindows');

app is holding a pointer to the correct process id and app name if I console.log(app) I see something like:

<NSRunningApplication: 0x103f14540 (com.apple.calculator - 9274)>

Now according to other questions around the place in obj-c you would get an app object back and call activateWithOptions and NSApplicationActivateAllWindows being the option. Apple docs here:

https://developer.apple.com/documentation/appkit/nsapplication.activationoptions

When I run this, however nothing happens. I can basically send in what I want instead of NSApplicationActivateAllWindows and nothing happens. I've tried the other options available, same thing.

How can I get the application to activate and come to the foreground?

Cœur
  • 37,241
  • 25
  • 195
  • 267
kbcool
  • 695
  • 6
  • 18
  • Did you try no options `0`? – Willeke Mar 23 '18 at 09:51
  • I got so frustrated with this I tried passing in random strings and then numbers. It turns out passing in the number 27 works! Definitely not the answer so I'll leave it open but it seems to consistently work. I am guessing the options are integers but there's no mapping of their values online so I have no idea what 27 means – kbcool Apr 18 '18 at 10:27

0 Answers0