Created
May 26, 2010 11:06
-
-
Save atr000/414349 to your computer and use it in GitHub Desktop.
ScreenFrame.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This is a free command line utility made by ief2. | |
You are allowed to use it for personal use, publishing | |
or usage in self-made applications. | |
Developer's Site: | |
http://developerief2.site11.com | |
*/ | |
#import <Foundation/Foundation.h> | |
#import <AppKit/AppKit.h> | |
int main (int argc, const char * argv[]) { | |
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
// -s screen number | |
// -v visible frame | |
/* ========== ARGUMENTS ========== */ | |
// retreive arguments | |
int screenNumber = [[NSUserDefaults standardUserDefaults] integerForKey:@"s"]; | |
BOOL visibleFlag = [[NSUserDefaults standardUserDefaults] boolForKey:@"v"]; | |
// check arguments | |
if(!screenNumber) { | |
printf("Screen number was not defined (-s)\n"); | |
return 1; | |
} else if(screenNumber > [[NSScreen screens] count]) { | |
printf("Screen does not exist at given index\n"); | |
return 1; | |
} | |
/* ========== GET FRAME ========== */ | |
NSRect screenFrame; | |
screenNumber -= 1; | |
if(visibleFlag == YES) | |
screenFrame = [[[NSScreen screens] objectAtIndex:screenNumber] visibleFrame]; | |
else | |
screenFrame = [[[NSScreen screens] objectAtIndex:screenNumber] frame]; | |
/* ========== RETURN RESULT ========== */ | |
printf("x:%i y:%i width:%i height:%i\n", | |
(int)screenFrame.origin.x, | |
(int)screenFrame.origin.y, | |
(int)screenFrame.size.width, | |
(int)screenFrame.size.height); | |
[pool drain]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment