0
Error:
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
Code:
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()
And the
HookManager.KeyDown
supports a functionasync
?– Woss
https://stackoverflow.com/questions/3673769/pyhook-pythoncom-stop-working-after-too-much-keys-pressed-python so I read yes
– Tiago Pereira
I didn’t see where this question refers to coroutines (async). There thread is used, which is a completely different concept. I recommend that you review the module documentation.
– Woss