Help With conversion

Mac OSX specific forum
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

Help With conversion

Post by spacebuddy »

Hi All,

I am trying to convert this code to PB.

int getActiveWindowOSX(){
NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init];
NSApplication *myApp;
myApp=[NSApplication sharedApplication];
NSWindow *myWindow = [myApp keyWindow];
[pool release];
// return *NSWindow;
}

This code should give me the foreground window running.

In PB I tried.

Import C""
Define myApp,NSWindow
myApp=CocoaMessage(0,0,"NSApplication sharedApplication")
EndImport


MSWIndow=CocoaMessage(0,myApp, "KeyWindow",0)

MSWindow always comes back with 0, something I did is wrong :(
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Help With conversion

Post by wilbert »

With PB 5.10

Code: Select all

KeyWindowID = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "keyWindow")
Debug KeyWindowID
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

Re: Help With conversion

Post by spacebuddy »

I was so close, thanks Wilbert :D
Post Reply