|
9 | 9 | from tkinter import messagebox, simpledialog, filedialog
|
10 | 10 | from tkinter import ttk
|
11 | 11 | from tkinter import font
|
| 12 | +import webbrowser |
12 | 13 |
|
13 | 14 | # Constants for the unified stop hotkey
|
14 | 15 | STOP_HOTKEY = {Key.esc}
|
@@ -198,28 +199,38 @@ def play_loop(self):
|
198 | 199 | previous_time = 0
|
199 | 200 | total_time = self.events[-1]['time'] if self.events else 0
|
200 | 201 | print("Starting playback iteration...")
|
| 202 | + |
| 203 | + # Calculate start time for this iteration |
| 204 | + start_time = time.perf_counter() |
| 205 | + |
201 | 206 | for event in self.events:
|
202 | 207 | if not self.playing:
|
203 | 208 | print("Playback interrupted by user.")
|
204 | 209 | break
|
205 |
| - delay = (event['time'] - previous_time) / self.speed |
206 |
| - if delay > 0: |
207 |
| - print(f"Sleeping for {delay:.4f} seconds before executing event.") |
208 |
| - # Implement a shorter sleep interval to allow quicker interruption |
209 |
| - start_sleep = time.time() |
210 |
| - while time.time() - start_sleep < delay: |
211 |
| - if not self.playing: |
212 |
| - print("Playback interrupted during sleep.") |
213 |
| - return |
214 |
| - time.sleep(0.01) # Sleep in small intervals to check for stop |
215 |
| - else: |
216 |
| - print(f"No delay needed before executing event: {event}") |
217 |
| - self.execute_event(event) |
218 |
| - previous_time = event['time'] |
219 |
| - # Update progress |
220 |
| - if self.progress_callback and total_time > 0: |
221 |
| - progress = (previous_time / total_time) * 100 |
222 |
| - self.progress_callback(progress) |
| 210 | + |
| 211 | + # Calculate when this event should occur relative to start time |
| 212 | + target_time = start_time + (event['time'] / self.speed) |
| 213 | + current_time = time.perf_counter() |
| 214 | + |
| 215 | + # If we're ahead of schedule, wait until the right moment |
| 216 | + if current_time < target_time: |
| 217 | + sleep_time = target_time - current_time |
| 218 | + if sleep_time > 0: |
| 219 | + # Use shorter sleep intervals for more precise timing |
| 220 | + while time.perf_counter() < target_time and self.playing: |
| 221 | + remaining = target_time - time.perf_counter() |
| 222 | + if remaining > 0.01: |
| 223 | + time.sleep(0.001) # Small sleep interval for better precision |
| 224 | + |
| 225 | + # Execute the event |
| 226 | + if self.playing: # Check again in case we were stopped during sleep |
| 227 | + self.execute_event(event) |
| 228 | + previous_time = event['time'] |
| 229 | + # Update progress |
| 230 | + if self.progress_callback and total_time > 0: |
| 231 | + progress = (previous_time / total_time) * 100 |
| 232 | + self.progress_callback(progress) |
| 233 | + |
223 | 234 | if self.loop and self.playing:
|
224 | 235 | print("Completed one loop. Restarting playback...")
|
225 | 236 | else:
|
@@ -540,9 +551,9 @@ def create_regular_widgets(self):
|
540 | 551 | self.help_button = tk.Button(additional_frame, text="Help", command=self.show_help, width=10, bg="#1abc9c", fg="white", font=("Helvetica", 10, "bold"))
|
541 | 552 | self.help_button.pack(side="right", padx=5)
|
542 | 553 |
|
543 |
| - # About Button |
544 |
| - self.about_button = tk.Button(additional_frame, text="About", command=self.show_about, width=10, bg="#e74c3c", fg="white", font=("Helvetica", 10, "bold")) |
545 |
| - self.about_button.pack(side="right", padx=5) |
| 554 | + # GitHub Button |
| 555 | + self.github_button = tk.Button(additional_frame, text="GitHub", command=lambda: webbrowser.open('https://github.com/techcow2/autowiz'), width=10, bg="#333333", fg="white", font=("Helvetica", 10, "bold")) |
| 556 | + self.github_button.pack(side="right", padx=5) |
546 | 557 |
|
547 | 558 | # Exit Button
|
548 | 559 | self.exit_button = tk.Button(additional_frame, text="Exit", command=self.on_closing, width=10, bg="#e74c3c", fg="white", font=("Helvetica", 10, "bold"))
|
@@ -857,39 +868,6 @@ def show_help(self):
|
857 | 868 | width=10, bg="#4CAF50", fg="white", font=("Helvetica", 10, "bold"))
|
858 | 869 | ok_button.pack(pady=(0, 10))
|
859 | 870 |
|
860 |
| - def show_about(self): |
861 |
| - about_window = tk.Toplevel(self) |
862 |
| - about_window.title("About - AutoWiz") |
863 |
| - about_window.geometry("400x350") # Increased height to accommodate button |
864 |
| - about_window.configure(bg="#f0f0f0") |
865 |
| - # Center the about window |
866 |
| - self.center_child_window(about_window, 400, 350) |
867 |
| - about_window.transient(self) |
868 |
| - about_window.grab_set() |
869 |
| - |
870 |
| - # Create a frame with padding for content |
871 |
| - content_frame = tk.Frame(about_window, bg="#f0f0f0", padx=20, pady=20) |
872 |
| - content_frame.pack(fill="both", expand=True) |
873 |
| - |
874 |
| - about_label = tk.Label(content_frame, text="About AutoWiz", font=("Helvetica", 16, "bold"), bg="#f0f0f0") |
875 |
| - about_label.pack(pady=(0, 10)) |
876 |
| - |
877 |
| - about_text = ( |
878 |
| - "AutoWiz v1.2\n\n" |
879 |
| - "AutoWiz is a powerful automation tool designed to record and playback keyboard and mouse actions.\n\n" |
880 |
| - "Developed by: TechRay Apps LLC\n" |
881 |
| - |
882 |
| - "© 2024 AutoWiz. All rights reserved." |
883 |
| - ) |
884 |
| - about_label = tk.Label(content_frame, text=about_text, justify="center", bg="#f0f0f0", |
885 |
| - font=("Helvetica", 10), wraplength=360) |
886 |
| - about_label.pack(pady=(0, 20)) |
887 |
| - |
888 |
| - # Add Okay button |
889 |
| - ok_button = tk.Button(content_frame, text="Okay", command=about_window.destroy, |
890 |
| - width=10, bg="#4CAF50", fg="white", font=("Helvetica", 10, "bold")) |
891 |
| - ok_button.pack(pady=(0, 10)) |
892 |
| - |
893 | 871 | def show_disclaimer(self):
|
894 | 872 | """Show the disclaimer window if not already agreed."""
|
895 | 873 | disclaimer_window = tk.Toplevel(self)
|
|
0 commit comments