DEV Community

kayYOLO
kayYOLO

Posted on

[Python]Keep MS Teams status active

Microsoft Teams will auto-offline without action from your mouse and keyboard for a while. So we can use Python to control the mouse and keyboard to keep moving.
Clicknium is a Python Library that can control your mouse and keyboard.

install

pip install clicknium

Python script

from time import sleep
import math
from clicknium import clicknium as cc
def circle():
    a,b = cc.mouse.position()
    w = 20  
    m = (2*math.pi)/w 
    r = 200      

    while 1:    
        for i in range(0, w+1):
            x = int(a+r*math.sin(m*i))  
            y = int(b+r*math.cos(m*i))
            cc.mouse.move(x,y)
            sleep(0.2)

if __name__ == "__main__":
    circle()
Enter fullscreen mode Exit fullscreen mode

The above code will keep moving your mouse along a circle. You can stop it by `Ctrl+C.

There are a lot of things that you can use Clicknium to achieve and it is quite easy. It can control the mouse and keyboard, automate desktop applications and web browsers. Follow the Clicknium quick start and turn your routine work into an automation workflow.

Top comments (1)

Collapse
 
0asa profile image
Vincent Botta

Here is a more "portable" version just in case:

import pyautogui
import math

def circle():
    a,b = pyautogui.position()
    w = 20
    m = (2*math.pi)/w
    r = 200      

    while 1:
        for i in range(w+1):
            x = int(a+r*math.sin(m*i))  
            y = int(b+r*math.cos(m*i))
            pyautogui.moveTo(x, y, duration = 0.2)

if __name__ == "__main__":
    try:
        circle()
    except KeyboardInterrupt as e:
        print("Keep up the good work... ;-)")
Enter fullscreen mode Exit fullscreen mode