Skip to content

Instantly share code, notes, and snippets.

@yene
Created January 15, 2015 14:25
Show Gist options
  • Save yene/5d5f97f9740bf57e1684 to your computer and use it in GitHub Desktop.
Save yene/5d5f97f9740bf57e1684 to your computer and use it in GitHub Desktop.
call pasteboard on mac os x from go
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