How to use the pyperclip.paste function in pyperclip

To help you get started, we’ve selected a few pyperclip examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github crew102 / reprexpy / tests / test_reprexpy.py View on Github external
def test_output_to_clipboard():
    _reprex_basic('x = "hi there"; print(x)')
    assert pyperclip.paste() == '```python\nx = "hi there"; ' \
                                'print(x)\n#> hi there\n```'
github asweigart / codebreaker / codebreaker_unit_tests.py View on Github external
def test_transpositionEncryptProgram(self):
        proc = subprocess.Popen('c:\\python32\\python.exe transpositionEncrypt.py', stdout=subprocess.PIPE)
        procOut = proc.communicate()[0].decode('ascii')

        # encrypting 'Common sense is not so common.' with key 8
        self.assertEqual(procOut, 'Cenoonommstmme oo snnio. s s c|\n')
        self.assertEqual(pyperclip.paste().decode('ascii'), 'Cenoonommstmme oo snnio. s s c')
github JamesHopbourn / Apple-Automation / Python Script / Clipboard to Reminders.py View on Github external
#!/usr/local/bin/python3
#-*- coding:utf-8 -*-
#  Clipboard to Reminders.py
#  Clipboard to Reminders
#
#  Created by James Hopbourn on 2019/12/11.
#  Copyright © 2019 James Hopbourn. All rights reserved.

import os
import pyperclip
clipboard = pyperclip.paste()

list = clipboard.split('\n')
name = list[0]
list.remove(list[0])
body = '\n'.join(list)

cmd = """osascript -e 'tell application "Reminders"
	make new reminder at list "Drafts" with properties {name:"namehere", body:"bodyhere"}
end tell'"""
cmd = cmd.replace("namehere", name)
cmd = cmd.replace("bodyhere", body)

def addreminders():
     os.system(cmd)
addreminders()
github ex2tron / MyLibsAndSamples / 008.列出目录中特定后缀的所有文件 / list_specific_postfix_file.py View on Github external
ret.append(filename)
    else:
        for item in os.listdir(folder):
            # 如果是文件夹,则跳过
            if os.path.isdir(os.path.join(folder, item)):
                continue
            if postfix == '*':
                ret.append(item)
            elif os.path.splitext(item)[1] == postfix:
                ret.append(item)

    return ret


# 要操作的文件夹
folder_path = pyperclip.paste()
# 后缀名
postfix = sys.argv[1]
# 是否包含子目录
is_contain_subfolders = False if len(sys.argv) < 3 else bool(sys.argv[2])

result = get_file_names(folder_path, postfix=postfix,
                        is_contain_subfolders=is_contain_subfolders)
for item in result:
    print(item)
github honix / Pyno / pyno / codeEditor.py View on Github external
if symbol == key.TAB:
            self.change = True
            self.document.insert_text(self.caret.position, '  ')
            self.caret.position += 2

        elif modifiers & key.MOD_CTRL and symbol == key.ENTER:
            print('Reload code')
            self.update_node()

        elif modifiers & key.MOD_CTRL:
            if symbol == key.C and self.caret.mark:
                self.copy_text()
            elif symbol == key.V:
                start = min(self.caret.position, self.caret.mark or self.caret.position)
                end = max(self.caret.position, self.caret.mark or self.caret.position)
                text = pyperclip.paste()
                self.document.delete_text(start, end)
                self.document.insert_text(self.caret.position, text)
                self.caret.position += len(text)
                self.caret.mark = self.caret.position
            elif symbol == key.X and self.caret.mark:
                start, end = self.copy_text()
                self.document.delete_text(start, end)
                self.caret.mark = self.caret.position

        elif symbol == key.BACKSPACE or symbol == key.DELETE:
            self.change = True
github asweigart / pyperclip / src / pyperclip / __main__.py View on Github external
import pyperclip
import sys

if len(sys.argv) > 1 and sys.argv[1] in ('-c', '--copy'):
    pyperclip.copy(sys.stdin.read())
elif len(sys.argv) > 1 and sys.argv[1] in ('-p', '--paste'):
    sys.stdout.write(pyperclip.paste())
else:
    print('Usage: python -m pyperclip [-c | --copy] | [-p | --paste]')
    print()
    print('When copying, stdin will be placed on the clipboard.')
    print('When pasting, the clipboard will be written to stdout.')
github voussoir / else / Toolbox / contentreplace.py View on Github external
def contentreplace_argparse(args):
    filenames = glob.glob(args.filename_glob)

    if args.clip_prompt:
        replace_from = input('Ready from')
        if not replace_from:
            replace_from = pyperclip.paste()
        replace_to = input('Ready to')
        if not replace_to:
            replace_to = pyperclip.paste()
    else:
        replace_from = codecs.decode(args.replace_from, 'unicode_escape')
        replace_to = codecs.decode(args.replace_to, 'unicode_escape')

    for filename in filenames:
        contentreplace(
            filename,
            replace_from,
            replace_to,
            autoyes=args.autoyes,
        )
github mcnemesis / globalclipboard / clipclients / python / clip_client / clip_client.py View on Github external
if self.session_key is None:
                #try to login then...
                r = requests.request('post',"%s/register" % self._conf['server']['url'], data = {'email' : self.creds['email'] , 'password' : self.creds['password'] })
                rj = r.json
                if r.ok and rj['status'] == 200:
                    logging.info("Registration Successfull: %s" % rj['payload'])
                    #since's we've just registered... give user 1 min to complete registration before using clip client again
                    t = Timer(60,self.run_clipclient) 
                else:
                    logging.error("Registration Not Completed : %s" % rj['payload'])
                    #possibly, registration not complete yet or activation not yet done. delay for like 2 min now before trying again
                    t = Timer(120,self.run_clipclient) 
            else:
                #we have session key, so...
                #check if there's anything here on the clipboard that needs to be copied over...
                current_local_clip = pyperclip.paste()

                if (self._current_action_mode == ActionMode.RECEIVE_SEND ) or (self._current_action_mode == ActionMode.SEND_ONLY):
                    if self.local_clipboard != current_local_clip:
                        #there's new stuff on the local clip to copy over...
                        #First, secure the paste...
                        secure_local_clip = self.encrypt_clip(current_local_clip,self.encryption_conf)
                        #then send
                        r = requests.request('post',"%s/paste" % self._conf['server']['url'], data = {'session' : self.session_key , 'paste' : secure_local_clip })
                        rj = r.json
                        if r.ok and rj['status'] == 200:
                            logging.debug('Copying to Global Clipboard Successful : %s' % rj['payload'])
                            self.local_clipboard = current_local_clip
                            t = Timer(10,self.run_clipclient) 
                        else:
                            try:
                                print secure_local_clip
github mozilla / iris_firefox / iris / api / core / environment.py View on Github external
def get_clipboard():
        """Return the content copied to clipboard."""
        return pyperclip.paste()