Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to bring back "wait for new paste." #272

Open
PVER-Programz opened this issue Feb 17, 2025 · 1 comment
Open

Need to bring back "wait for new paste." #272

PVER-Programz opened this issue Feb 17, 2025 · 1 comment

Comments

@PVER-Programz
Copy link

The pyperclip had pyperclip.waitForNewPaste(). It is not available now. please bring it back.

@aker-pc
Copy link

aker-pc commented Feb 22, 2025

Image
This might be the answer you're looking for. You can refer old pyperclip to meet your needs.

def waitForPaste(timeout=None):
    """This function call blocks until a non-empty text string exists on the
    clipboard. It returns this text.

    This function raises PyperclipTimeoutException if timeout was set to
    a number of seconds that has elapsed without non-empty text being put on
    the clipboard."""
    startTime = time.time()
    while True:
        clipboardText = paste()
        if clipboardText != '':
            return clipboardText
        time.sleep(0.01)

        if timeout is not None and time.time() > startTime + timeout:
            raise PyperclipTimeoutException('waitForPaste() timed out after ' + str(timeout) + ' seconds.')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants