Erro:
Warning (from warnings module):
File "C:\Users\tiago.pereira\Desktop\python\kivy\kivy_teste.py", line 43
pythoncom.PumpMessages()
RuntimeWarning: coroutine 'Keyboard' was never awaited
TypeError: an integer is required (got type coroutine)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\tiago.pereira\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyHook\HookManager.py", line 348, in KeyboardSwitch
event = KeyboardEvent(msg, vk_code, scan_code, ascii, flags, time, hwnd, win_name)
SystemError: <class 'pyHook.HookManager.KeyboardEvent'> returned a result with an error set
Codigo:
import pythoncom,pyHook
import threading
import ctypes,sys,asyncio
import cv2
import tkinter as tk
from tkinter import *
#kivy.require('1.9.0')
#def popup():
# popup = Popup(content=Label(text="I am popup"))s
# popup.open()
first = True
async def Keyboard(event):
print(event.GetKey())
if event.GetKey() == 'Lcontrol':
ctypes.windll.user32.LockWorkStation()
elif event.GetKey() == 'Next':
sys.exit(0)
else:
await picture
return False
async def picture():
cap = cv2.VideoCapture(0)
ret,frame = cap.read() # return a single frame in variable `frame`
cv2.imwrite('C:/Users/tiago.pereira/desktop/c1.png',frame)
cap.release()
hm = pyHook.HookManager()
hm.KeyDown = Keyboard
#hm.MouseAll = Mouse
hm.HookKeyboard()
#hm.HookMouse()
pythoncom.PumpMessages()
HookManager.KeyDown
suporta uma funçãoasync
?