Skip to content

Instantly share code, notes, and snippets.

@pudquick
Created January 30, 2021 00:37
Show Gist options
  • Save pudquick/62b9cf82175b80ae5ee8b8fb8ad892ea to your computer and use it in GitHub Desktop.
Save pudquick/62b9cf82175b80ae5ee8b8fb8ad892ea to your computer and use it in GitHub Desktop.
Get / Set shared Find Pasteboard state on macOS via pyobjc
from AppKit import NSPasteboard, NSFindPboard, NSStringPboardType, NSString
def get_fboard():
fboard = NSPasteboard.pasteboardWithName_(NSFindPboard)
if NSStringPboardType in fboard.types():
return fboard.stringForType_(NSStringPboardType)
def set_fboard(findstr):
fboard = NSPasteboard.pasteboardWithName_(NSFindPboard)
fboard.declareTypes_owner([NSStringPboardType], None)
fboard.setString_forType_(NSString.stringWithString_(findstr), NSStringPboardType)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment