Skip to content

Commit

Permalink
feat(python): simulate_activity
Browse files Browse the repository at this point in the history
  • Loading branch information
jofaval committed Apr 24, 2023
1 parent 3a22e0d commit c23e21a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This project won't have versioning per se. But it's format is based in the [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## 2023-04-25

### Added

- Python utility to simulate mouse movement activity (multi-platform).

## 2023-04-03

### Added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ An easy and fast to develop in language that's proven to be very useful, special
- [github-repository-created_at.py](./python/github-repository-created_at.py), utility to sort by date public github repos from a user.
- [postman-to-markdown.py](./python/postman-to-markdown.py), utility to transform a postman collection to a markdown doc.
- [get_words_from_pdf.py](./python/get_words_from_pdf.py), CLI script to get words from a pdf and retrieve (total words and read time).
- [simulate_activity.py](./python/simulate_activity.py), Utility to simulate mouse movement activity (multi-platform).

## Javascript

Expand Down
1 change: 1 addition & 0 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
- [github-repository-created_at.py](./github-repository-created_at.py)
- [postman-to-markdown.py](./postman-to-markdown.py)
- [get_words_from_pdf.py](./get_words_from_pdf.py)
- [simulate_activity.py](./simulate_activity.py)
37 changes: 37 additions & 0 deletions python/simulate_activity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
Simulate activity on a PC so it doesn't get suspended
"""
import random
import time

import pyautogui

SECONDS_TO_SLEEP_IN_BETWEEN: int = 1*60


def custom_random(variance: int, negative_range: bool = True) -> int:
"""Custom random number generation"""
max_number = variance
min_number = 0

if negative_range:
max_number /= 2
min_number -= (variance / 2)
return random.randint(min_number, max_number)


def start():
"""
Main entrypoint
@source https://stackoverflow.com/questions/1181464/controlling-mouse-with-python
"""
while True:
print("moving mouse...")
pyautogui.moveRel(custom_random(20), custom_random(20), .2)
print("mouse moved!")
time.sleep(SECONDS_TO_SLEEP_IN_BETWEEN)


if __name__ == "__main__":
start()
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyautogui==0.9.53

0 comments on commit c23e21a

Please sign in to comment.