Skip to content

Commit

Permalink
refactor: Improve typing simulation with randomized keystroke interva…
Browse files Browse the repository at this point in the history
…l fix
  • Loading branch information
LyubomirT committed Aug 4, 2024
1 parent 7f2f165 commit acbcc04
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(self, text, interval, type_enter, chars_per_stroke, randomize_inter
self.mistake_percentage = mistake_percentage
self.running = True
self.keyboard = Controller()
print(f"TypingThread initialized with randomize_interval: {self.randomize_interval}") # Debug print

def run(self):
i = 0
Expand All @@ -35,9 +36,11 @@ def run(self):
i += self.chars_per_stroke

if self.randomize_interval:
current_interval = self.interval * random.uniform(0.4, 1.8)
current_interval = self.interval * random.uniform(0.1, 3)
print(f"Randomized interval: {current_interval}") # Debug print
else:
current_interval = self.interval
print(f"Fixed interval: {current_interval}") # Debug print

time.sleep(current_interval)
self.progress.emit(int(i / len(self.text) * 100))
Expand Down Expand Up @@ -97,6 +100,8 @@ def start_typing(self):
QMessageBox.critical(self, "Error", "Invalid input for delay, interval, chars per stroke, or mistake percentage.")
return

print(f"Starting typing with randomize_interval: {randomize_interval}") # Debug print

self.startButton.setEnabled(False)
self.stopButton.setEnabled(True)
if delay > 0:
Expand Down

0 comments on commit acbcc04

Please sign in to comment.