Mouse mover in python

Mouse mover in python

Mouse mover in python

Views: 36
0 0
Read Time:1 Minute, 17 Second

Hi All, I recently came across one really really boring issue that is how to keep the monitor always turned on while away avoiding the stand-by and consequently close the VPN connection. I’m probably the laziest person of the entire planet (or galaxy) and for avoiding to go and search on google or in the system settings, I just implemented my programmatic way of keeping the mouse moving randomly, so that I can avoid to afford the enormous task of clicking on the “Connect to VPN” button. I found then this beautiful library that can help me control the mouse using python with just few lines of code. Holy grail for my laziness!!

I found this library pyautogui (https://pyautogui.readthedocs.io/en/latest/)

PyAutoGUI lets your Python scripts control the mouse and keyboard to automate interactions with other applications. The API is designed to be simple. PyAutoGUI works on Windows, macOS, and Linux, and runs on Python 2 and 3.

And it does what is said! I created this script that I keep running while on lunch break, so my computer will not go in stand-by, my VPN will not quit and all my terminal sessions will still be opened!!

Ejoy

import pyautogui
import time

from random import randint, seed

seed(3)

# get the screen resolution
x, y = pyautogui.size()

while True:
	pyautogui.moveTo(randint(0, y), randint(0, x), duration = 1)
	time.sleep(1)

Hope this will solve your exact same problem! If not would be interesting hearing from you what actually solved.

fce70581d3812712df039a05e6d32a7d Mouse mover in python

About Post Author

brewedbrilliance.net

Experienced software architect with a spasmodic passion for tech, software, programming. With more than 20years of experience I've decided to share all my knowledge in pills through this blog. Please feel free to contact me if there is any topic that you would love to cover
happy Mouse mover in python
Happy
0 %
sad Mouse mover in python
Sad
0 %
excited Mouse mover in python
Excited
0 %
sleepy Mouse mover in python
Sleepy
0 %
angry Mouse mover in python
Angry
0 %
surprise Mouse mover in python
Surprise
0 %

Share this content:

Experienced software architect with a spasmodic passion for tech, software, programming. With more than 20years of experience I've decided to share all my knowledge in pills through this blog. Please feel free to contact me if there is any topic that you would love to cover

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x