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

ios - Memory not freeing up after popping viewcontroller using ARC -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -