Created
January 15, 2015 14:25
-
-
Save yene/5d5f97f9740bf57e1684 to your computer and use it in GitHub Desktop.
call pasteboard on mac os x from go
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
| package main | |
| /* | |
| #cgo CFLAGS: -x objective-c | |
| #cgo LDFLAGS: -framework Cocoa | |
| #import <Cocoa/Cocoa.h> | |
| int | |
| StartApp(void) { | |
| [NSAutoreleasePool new]; | |
| [NSApplication sharedApplication]; | |
| NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard]; | |
| [pasteBoard declareTypes:[NSArray arrayWithObjects:NSStringPboardType, nil] owner:nil]; | |
| [pasteBoard setString: @"test2" forType:NSStringPboardType]; | |
| NSArray *classes = [[NSArray alloc] initWithObjects:[NSString class], nil]; | |
| NSDictionary *options = [NSDictionary dictionary]; | |
| NSArray *copiedItems = [pasteBoard readObjectsForClasses:classes options:options]; | |
| if (copiedItems != nil) { | |
| NSLog(@"%@", copiedItems[0]); | |
| } | |
| return 0; | |
| } | |
| */ | |
| import "C" | |
| func main() { | |
| C.StartApp() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment