示例#1
0
def _to_clipboard(s):
    'Mac only'
    from AppKit import NSPasteboard, NSArray
    pb = NSPasteboard.generalPasteboard()
    pb.clearContents()
    a = NSArray.arrayWithObject_(s)
    pb.writeObjects_(a)
示例#2
0
def _to_clipboard(s):
    'Mac only'
    from AppKit import NSPasteboard, NSArray
    pb = NSPasteboard.generalPasteboard()
    pb.clearContents()
    a = NSArray.arrayWithObject_(s)
    pb.writeObjects_(a)
示例#3
0
def copy_ip(item):
    """Copies IP to clipboard"""
    from AppKit import NSPasteboard, NSArray

    pb = NSPasteboard.generalPasteboard()
    pb.clearContents()
    a = NSArray.arrayWithObject_(item)
    pb.writeObjects_(a)
示例#4
0
def copyToClipboard():
    try:
        word = b64decode(alfred.argv(2))
        pb = NSPasteboard.generalPasteboard()
        pb.clearContents()
        a = NSArray.arrayWithObject_(word)
        pb.writeObjects_(a)
        alfred.exit('已拷贝地址到剪切板')
    except Exception, e:
        alfred.log(e)
        alfred.exit('出错啦')
示例#5
0
文件: __main__.py 项目: sspiff/narvi
	def _macosx(self, text):
		#
		# taken from: http://stackoverflow.com/a/3555675
		#
		from AppKit import NSPasteboard, NSArray
		pb = NSPasteboard.generalPasteboard()
		pb.clearContents()
		a = NSArray.arrayWithObject_(text)
		pb.writeObjects_(a)
		def clearit():
			pb.clearContents()
		return clearit
示例#6
0
def _copy_to_clipboard(arg):
    arg = str(globals().get(arg) or arg)

    if sys.platform == 'darwin':
        pb = NSPasteboard.generalPasteboard()
        pb.clearContents()
        a = NSArray.arrayWithObject_(arg)
        pb.writeObjects_(a)
    elif sys.platform.startswith('linux'):
        p = Popen(['xsel', '-pi'], stdin=PIPE)
        p.communicate(input=arg)

    print 'Copied to clipboard!'
示例#7
0
    def launchAppByBundlePath(bundlePath, arguments=[]):
        """ launchAppByBundlePath - Launch app with a given bundle path
            Return True if succeed
        """
        bundleUrl = NSURL.URLWithString_(bundlePath)
        workspace = AppKit.NSWorkspace.sharedWorkspace()
        arguments_strings = map(lambda a: NSString.stringWithString_(str(a)), arguments)
        arguments = NSDictionary.dictionaryWithDictionary_(
            {AppKit.NSWorkspaceLaunchConfigurationArguments: NSArray.arrayWithArray_(arguments_strings)}
        )

        return workspace.launchApplicationAtURL_options_configuration_error_(
            bundleUrl, AppKit.NSWorkspaceLaunchAllowingClassicStartup, arguments, None
        )
示例#8
0
def share_path(path, access_token):
    api_client = client.DropboxClient(access_token)
    try:
        url = api_client.share(path)['url']

        pb = NSPasteboard.generalPasteboard()
        pb.clearContents()
        a = NSArray.arrayWithObject_(url)
        pb.writeObjects_(a)

        print 'Link copied to clipboard'

    except rest.ErrorResponse, e:
        print e.user_error_msg or str(e)
示例#9
0
def write_text(text, paste=False):
    '''send text formatted exactly as written to active window.  will use
       pbpaste clipboard to paste the text instead of typing it.'''

    logging.debug("text = %s paste = %s" % (text, paste))
    if text:
        # get current clipboard contents
        pb = NSPasteboard.generalPasteboard()
        classes = NSArray.arrayWithObject_(objc.lookUpClass('NSString'))
        options = NSDictionary.dictionary()
        items = NSArray(pb.readObjectsForClasses_options_(classes, options))

        # copy our text to clipboard
        a = NSArray.arrayWithObject_(text)
        pb.clearContents()
        pb.writeObjects_(a)

        # paste
        key_press('v', 'super')
        pause(500)

        # return original text to clipboard
        pb.clearContents()
        pb.writeObjects_(items)
示例#10
0
   def launchAppByBundlePath(bundlePath, arguments=[]):
        ''' launchAppByBundlePath - Launch app with a given bundle path
            Return True if succeed
        '''
        bundleUrl = NSURL.fileURLWithPath_(bundlePath)
        workspace = AppKit.NSWorkspace.sharedWorkspace()
        arguments_strings = map(lambda a: NSString.stringWithString_(str(a)), arguments)
        arguments = NSDictionary.dictionaryWithDictionary_({
            AppKit.NSWorkspaceLaunchConfigurationArguments: NSArray.arrayWithArray_(arguments_strings)
          })

        return workspace.launchApplicationAtURL_options_configuration_error_(
          bundleUrl,
          AppKit.NSWorkspaceLaunchAllowingClassicStartup,
          arguments,
          None)
示例#11
0
 def copy_result(self, sender):
     from string import strip
     from AppKit import NSPasteboard, NSArray
     
     s = u""
     
     results = self.w.font_list.getSelection()
     
     for i in results:
         s += self.w.font_list.get()[i]["Font"] + "\n\n"
         s += self.w.font_list.get()[i]["Result"] + "\n\n\n"
     
     pb = NSPasteboard.generalPasteboard()
     pb.clearContents()
     a = NSArray.arrayWithObject_(s.strip("\n"))
     pb.writeObjects_(a)
示例#12
0
    def save_image_to_clipboard(self, url):
        pb = NSPasteboard.generalPasteboard()
        pb.clearContents()

        if url.startswith('http'):
            img = Image.open(urllib.request.urlopen(url))
        else:
            img = Image.open(url)

        img_bytes = io.BytesIO()
        img.save(img_bytes, format='PNG')
        imgNsData = NSData.alloc().initWithBytes_length_(
            img_bytes.getvalue(), img_bytes.tell())
        imgNsImage = NSImage.alloc().initWithData_(imgNsData)
        array = NSArray.arrayWithObject_(imgNsImage)
        pb.writeObjects_(array)
        return
 def copy_(self, sender):
     text = None
     selection = self.selectedRowIndexes()
     item = selection.firstIndex()
     if item != NSNotFound:
         object = self.itemAtRow_(item)
         if isinstance(object, BlinkContact):
             text = '%s <%s>' % (
                 object.name,
                 object.uri) if object.name != object.uri else object.uri
         elif isinstance(object, BlinkGroup):
             text = '%s' % object.name
     if text:
         pb = NSPasteboard.generalPasteboard()
         pb.declareTypes_owner_(
             NSArray.arrayWithObject_(NSStringPboardType), self)
         pb.setString_forType_(text, NSStringPboardType)
示例#14
0
def _copy_to_clipboard(arg):
    import sys

    if sys.platform == 'darwin':
        from AppKit import NSPasteboard, NSArray
    elif sys.platform.startswith('linux'):
        from subprocess import Popen, PIPE
    else:
        raise ImportError("Clip magic only works on osx or linux!")

    arg = str(globals().get(arg) or arg)

    if sys.platform == 'darwin':
        pb = NSPasteboard.generalPasteboard()
        pb.clearContents()
        a = NSArray.arrayWithObject_(arg)
        pb.writeObjects_(a)
    elif sys.platform.startswith('linux'):
        p = Popen(['xsel', '-pi'], stdin=PIPE)
        p.communicate(input=arg)

    print('Copied to clipboard!')
示例#15
0
def copy_to_clipboard(text):
    from AppKit import NSPasteboard, NSArray
    pb = NSPasteboard.generalPasteboard()
    pb.clearContents()
    a = NSArray.arrayWithObject_(text)
    pb.writeObjects_(a)
示例#16
0
 def put_text(self, text):
     self.pasteboard.clearContents()
     self.pasteboard.writeObjects_(NSArray.arrayWithObject_(text))
示例#17
0
import base64
import sys
from AppKit import NSPasteboard, NSArray

pb = NSPasteboard.generalPasteboard()
pb.clearContents()
encoded = base64.urlsafe_b64encode(str(sys.argv[1]))
pb.writeObjects_(NSArray.arrayWithObject_(encoded))
示例#18
0
def copy_to_clipboard(text):
  from AppKit import NSPasteboard, NSArray
  pb = NSPasteboard.generalPasteboard()
  pb.clearContents()
  a = NSArray.arrayWithObject_(text)
  pb.writeObjects_(a)
def clipboard(link):
    pb = NSPasteboard.generalPasteboard()
    pb.clearContents()
    array = NSArray.arrayWithObject_(link)
    pb.writeObjects_(array)
示例#20
0
def set_clipboard(url_list):
    pb = NSPasteboard.generalPasteboard()
    pb.clearContents()
    for url in url_list:
        a = NSArray.arrayWithObject_(url)
        pb.writeObjects_(a)
示例#21
0
f = CurrentFont()

sets = []
features = ""

for g in f.keys():
    if "." in g:
        if "ss" in g.split(".")[1] and g.split(".")[1] not in sets:
            sets.append(g.split(".")[1])

sets.sort()

for set in sets:
    features += "feature %s {\n" % set
    for g in f:
        if set in g.name:
            base = g.name.split(".")[0]
            suffix = g.name.split(".")[1]
            features += "sub %s by %s;\n" % (base, g.name)
    features += "} %s;\n\n" % set

if features != "":
    p = NSPasteboard.generalPasteboard()
    p.clearContents()
    a = NSArray.arrayWithObject_(features)
    p.writeObjects_(a)
    mojo.UI.Message('Stylistic sets features copied to your clipboard')

if features == "":
    mojo.UI.Message("Could not find properly named glyphs.")
示例#22
0
def sendToClipboard(content):
    pb = NSPasteboard.generalPasteboard()
    pb.clearContents()
    c = NSArray.arrayWithObject_(content)
    pb.writeObjects_(c)
示例#23
0
def set_clipboard(url_list):
    pb = NSPasteboard.generalPasteboard()
    pb.clearContents()
    for url in url_list:
        a = NSArray.arrayWithObject_(url)
        pb.writeObjects_(a)
示例#24
0
 def save_text_to_clipboard(self, text):
     pb = NSPasteboard.generalPasteboard()
     pb.clearContents()
     a = NSArray.arrayWithObject_(text)
     pb.writeObjects_(a)
     return
示例#25
0
                  help="Specify whether to use special characters",
                  default=False,
                  action='store_true')

(options, args) = parser.parse_args()
strSpecial = '!@#$%^&*()'
char_set = string.ascii_uppercase + string.ascii_lowercase + string.digits


def f_pwGen(size=8, chars=char_set):
    return ''.join(random.choice(chars) for x in range(int(options.pwLength)))


def f_pwGenSpecial(size=8, chars=char_set + strSpecial):
    return ''.join(random.choice(chars) for x in range(int(options.pwLength)))


print 'Password length: ', options.pwLength
print 'Special Characters?: ', options.pwSpecial
print 'Generated Password: '
if (options.pwSpecial):
    myPass = f_pwGenSpecial(int(options.pwLength), )
    a = NSArray.arrayWithObject_(myPass)
    print myPass
    pb.writeObjects_(a)
else:
    myPass = f_pwGen(int(options.pwLength), )
    a = NSArray.arrayWithObject_(myPass)
    print myPass
    pb.writeObjects_(a)