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.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

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

Okay