-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathF12.py
More file actions
executable file
·36 lines (30 loc) · 1.02 KB
/
Copy pathF12.py
File metadata and controls
executable file
·36 lines (30 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pygame
import subprocess
import sys
# Initialize Pygame
pygame.init()
pygame.display.set_caption('Key Listener')
screen = pygame.display.set_mode((200, 100))
font = pygame.font.Font(None, 36)
running = True
process = None
while running:
screen.fill((0, 0, 0)) # Clear the screen
text = font.render("Press F12 to run script", True, (0, 255, 0)) # Green text
screen.blit(text, (10, 10))
pygame.display.update() # Update the display
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_F12:
if process is None or process.poll() is not None:
process = subprocess.Popen([sys.executable, '/home/aounit1/Desktop/AO/ops1.py'])
else:
print("Script is already running")
elif event.key == pygame.K_q:
running = False
pygame.quit()
if process is not None:
process.terminate()
process.wait()