Last active
October 31, 2021 15:24
-
-
Save z404/1f47b5cebb861030deed41b61d8ccecd to your computer and use it in GitHub Desktop.
Clickable Enter key using tkinter and pynput
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pynput.keyboard import Key, Controller | |
from tkinter import * | |
import time | |
keyboard = Controller() | |
top = Tk() | |
# top.geometry("200x100") | |
def func(): | |
keyboard.press(Key.alt) | |
keyboard.press(Key.tab) | |
keyboard.release(Key.alt) | |
keyboard.release(Key.tab) | |
time.sleep(0.4) | |
keyboard.press(Key.enter) | |
keyboard.release(Key.enter) | |
b = Button(top, text="Return", command=func) | |
b.pack() | |
top.attributes('-topmost', True) | |
top.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment