DEV Community

kayYOLO
kayYOLO

Posted on

17

[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.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

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

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay