pyautogui compare result CTRL + V

0

I have the following code

import pyautogui

pyautogui.moveTo(612, 269)
pyautogui.doubleClick()
copiar = pyautogui.hotkey('ctrl', 'c')
colar = pyautogui.hotkey('ctrl', 'v')
resultado = colar
print(resultado)

but my print is returning "None". I know I could show the result of CTRL + V directly, but I want to do a repeat structure with the conditional

carregando = 'carregada '
pyautogui.moveTo(612, 269)
pyautogui.doubleClick()
copiar = pyautogui.hotkey('ctrl', 'c')
colar = pyautogui.hotkey('ctrl', 'v')
resultado = colar
if copiar == carregando:
  copiar = pyautogui.hotkey('ctrl', 'c')
    
asked by anonymous 24.11.2017 / 18:22

1 answer

0

Looking at the hotkey method of the pyautogui class you can verify that it does not return anything , so your above comparison will not work.

I suggest taking the value that was copied to Clipboard and comparing whether it was loaded or not.

Using the Tkinter (Python 2) or tkinter (Python 3) library

import tkinter as tk
r = tk.Tk()
dado_copiado = r.clipboard_get()

Or using the win32clipboard library

import win32clipboard
dado_copiado = win32clipboard.GetClipboardData()
    
24.11.2017 / 20:41