Activate window in NodObjC

时间:2018-03-23 00:22:42

标签: objective-c node.js cocoa nodobjc

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?

0 个答案:

没有答案
相关问题