I want m_listener to start only when I press f6
and if I clicked F7, it stopped.
f6 it again to continue.
My issue is that when I click f7 it totally stops the listener and on_x_y_click never run again if i clicked f6
import pynput
import easygui
from pynput import *
def on_x_y_click(x, y, button, pressed):
print((x, y, button, pressed))
def on_release(key):
print(key)
if key == keyboard.Key.f6:
m_listener.join()
elif key == keyboard.Key.f7:
m_listener.stop()
elif key == keyboard.Key.esc:
# Stop listeners
m_listener.stop()
return False
# Collect events until released
with keyboard.Listener(on_release=on_release) as k_listener, \
mouse.Listener(on_click=on_x_y_click) as m_listener:
k_listener.join()
m_listener.join()