python - Failed to copy-paste after automatically pasting to the clipboard selected text -


i wanted write program paste selected text automatically (for example, no need use ctrl+c copy), clipboard. program looks this:

import pyautogui import win32con import win32clipboard import time  def get_clipboard():     data = ""     try:         win32clipboard.openclipboard()     except:          r = ""     try:                     data = win32clipboard.getclipboarddata()     except:         r = ""     try:         win32clipboard.closeclipboard()     except:         r = ""     return data     while true:      time.sleep(1) try:     pyautogui.hotkey("ctrl","c")     except:     continue x = get_clipboard() if x == "":     print ("no word in clipboard!") else:             print (x) 

as can see, used autohotkey combination paste selected text clipboard. causes failing normal copy-paste using. if want paste selected text mouse, pasted blank because program empty clipboard.

my question how correct this? or there other way send selected text somewhere in memory can reach automatically?

any appreciated.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -