-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemulator.py
More file actions
49 lines (41 loc) · 1.49 KB
/
Copy pathemulator.py
File metadata and controls
49 lines (41 loc) · 1.49 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
37
38
39
40
41
42
43
44
45
46
47
48
49
import tkinter as tk
from tkinter import messagebox
import pyautogui
import time
import threading
# Function to simulate a barcode scan
def simulate_scan():
barcode_data = entry.get() # Get data from the barcode entry box
try:
delay = float(delay_entry.get()) # Get delay time in seconds
except ValueError:
messagebox.showwarning("Warning", "Please enter a valid delay time.")
return
if barcode_data:
# Start a separate thread to avoid freezing the Tkinter GUI
threading.Thread(target=type_barcode, args=(barcode_data, delay)).start()
else:
messagebox.showwarning("Warning", "Please enter a barcode to scan.")
def type_barcode(barcode_data, delay):
time.sleep(delay) # Wait specified seconds before simulating barcode scan
pyautogui.write(barcode_data)
pyautogui.press('enter')
# Initialize main window
window = tk.Tk()
window.title("Barcode Scanner Emulator")
window.geometry("300x250")
# Create an entry box for barcode input
entry_label = tk.Label(window, text="Enter Barcode:")
entry_label.pack(pady=5)
entry = tk.Entry(window, width=30)
entry.pack(pady=5)
# Create an entry box for delay input
delay_label = tk.Label(window, text="Enter Delay (seconds):")
delay_label.pack(pady=5)
delay_entry = tk.Entry(window, width=10)
delay_entry.pack(pady=5)
# Create a button to simulate the scan
scan_button = tk.Button(window, text="Simulate Scan", command=simulate_scan)
scan_button.pack(pady=10)
# Run the main loop
window.mainloop()