Skip to content

Commit

Permalink
get window
Browse files Browse the repository at this point in the history
  • Loading branch information
nathfavour committed Jul 19, 2024
1 parent 27908ea commit d08fe24
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/playwright-report/
/blob-report/
/playwright/.cache/
/venv/
13 changes: 13 additions & 0 deletions gui/getwindow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pygetwindow as gw

def print_active_window_title():
try:
active_window = gw.getActiveWindow()
if active_window:
print(f"Active window title: {active_window.title}")
else:
print("No active window detected.")
except Exception as e:
print(f"An error occurred: {e}")

print_active_window_title()
22 changes: 22 additions & 0 deletions gui/mouse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pyautogui
import random
import time

def move_mouse_randomly(duration_seconds):
end_time = time.time() + duration_seconds
while time.time() < end_time:
# Get the size of the primary monitor.
screen_width, screen_height = pyautogui.size()

# Generate a random position within the screen bounds.
x = random.randint(0, screen_width)
y = random.randint(0, screen_height)

# Move the mouse to the random position.
pyautogui.moveTo(x, y, duration=0.1)

# Wait a bit before moving again to make the movements noticeable.
time.sleep(0.5)

# Example usage: Move the mouse randomly for 10 seconds.
move_mouse_randomly(10)
Empty file added requirements.txt
Empty file.

0 comments on commit d08fe24

Please sign in to comment.