Skip to content
  • English Deutsch

benjamin-abt.com

Performance is a feature | Cloud - AI - Azure - .NET - Sustainability

  • Home
  • Blog
  • Portfolio
    • Overview
    • Workshops & Training
    • Publications
  • Contact
  • Home
  • Blog

Create an anti-idle App for Microsoft Teams with .NET

Create an anti-idle App for Microsoft Teams with .NET
February 17, 2025 3 min read BEN ABT
Csharp .NET

Anti-idle apps for Microsoft Teams and the like are a dime a dozen, but how about creating your own? In this article, I’ll show you how to create an anti-idle app for Microsoft Teams using .NET and C#.

Idle Detection

Idle detection is as simple as it is annoying: it simply reacts to user input. If the user does not look at the screen for a while, the status is set to “absent”. But you are not always really absent, sometimes you are just sitting in front of your computer and writing something down on a piece of paper, but Teams thinks you are lying in bed and sets you to absent.

Anti-Idle

The Anti-Idle app is a small application that simulates a user input at regular intervals. This can be a mouse click or a keyboard input. In our case, we simply use the Windows API to send a new position for the mouse cursor.

The application

First we need a .NET console application whose project settings we set as follows:

XML
 1<Project Sdk="Microsoft.NET.Sdk">
 2
 3  <PropertyGroup>
 4    <OutputType>Exe</OutputType>
 5    <TargetFramework>net8.0-windows</TargetFramework>
 6    <ImplicitUsings>enable</ImplicitUsings>
 7    <Nullable>enable</Nullable>
 8    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
 9  </PropertyGroup>
10
11</Project>

This defines that we want to create a console application for .NET 8. More precisely, specifically for Windows, as in our case we need to address the Windows API directly.

Now we only need the code that moves the cursor at regular intervals, whereby I have decided to reset the cursor to the original point after setting the cursor.

C#
 1using System.Runtime.InteropServices;
 2
 3namespace BenjaminAbt.AntiIdleApp;
 4
 5internal partial class Program
 6{
 7    // Import the Windows API functions to control the mouse position
 8    [LibraryImport("user32.dll")]
 9    [return: MarshalAs(UnmanagedType.Bool)]
10    public static partial bool SetCursorPos(int X, int Y);
11
12    [LibraryImport("user32.dll")]
13    [return: MarshalAs(UnmanagedType.Bool)]
14    public static partial bool GetCursorPos(out POINT lpPoint);
15
16    // Structure to store the mouse position
17    public struct POINT
18    {
19        public int X;
20        public int Y;
21    }
22
23    public static async Task Main(string[] args)
24    {
25        Console.WriteLine("Anti Idle is running. Press CTRL+C to exit.");
26
27        // Create a PeriodicTimer that ticks every 1 minute (60 seconds)
28        using PeriodicTimer timer = new(TimeSpan.FromMinutes(1));
29
30        // Loop that waits for each tick of the timer
31        while (await timer.WaitForNextTickAsync())
32        {
33            // Get the current mouse position
34            if (GetCursorPos(out POINT currentPos))
35            {
36                // Move the mouse cursor 1 pixel to the right
37                SetCursorPos(currentPos.X + 1, currentPos.Y);
38
39                // Short delay to ensure the movement is registered
40                await Task.Delay(50);
41
42                // Move the mouse back to the original position
43                SetCursorPos(currentPos.X, currentPos.Y);
44            }
45        }
46    }
47}

Our Microsoft Teams anti-idle app is ready.

The complete code is available at https://github.com/BenjaminAbt/dotnet-anti-idle-app .

Related articles

Production Rate Limiting in ASP.NET Core

Nov 3, 2026 - 16 min read

Production Rate Limiting in ASP.NET Core

Most ASP.NET Core rate-limiting examples stop after registering a fixed window. That is enough to demonstrate the middleware, but it is not …

The Big Decimal Bugfix with .NET 11

Nov 2, 2026 - 11 min read

The Big Decimal Bugfix with .NET 11

For more than two decades, (decimal)1.23 returned 1.23m. It looked correct, it passed every test and it was a polite lie.

Distroless, Chiseled or Alpine: Choosing a .NET Base Image

Oct 27, 2026 - 10 min read

Distroless, Chiseled or Alpine: Choosing a .NET Base Image

Distroless, Chiseled and Alpine are often compared as three equivalent Linux distributions. They are not. Alpine is a distribution built …


BEN ABT

BEN ABT

Ben is Chief Engineering Officer and Principal Software Engineer at Medialesson.de, with a strong focus on .NET and Microsoft Azure. In his professional role, he designs and builds highly scalable platforms for hybrid and cloud-based scenarios. He also advises companies and C-levels on migrating to the sovereign cloud.

He runs myCSharp.de, the largest and most active German-speaking C# community forum, actively contributes to both his own and external open-source projects and regularly shares his knowledge through his blog, at community events, conferences and as a writer for technical magazines.

Let's Work Together

Looking for an experienced Platform Architect or Engineer for your next project? Whether it's cloud migration, platform modernization or building new solutions from scratch - I'm here to help you succeed.

New Platforms

Modernization

Training & Consulting

Contact Me
X Facebook LinkedIn WhatsApp
Back Next Blog Post

Open for work!

Contact Me
BEN ABT BEN ABT Software Engineer · Microsoft MVP Passionate about .NET, Azure, performance optimization and sustainable software engineering.

Medialesson GmbH Logo

Microsoft MVP Logo

Recent posts

View all
Production Rate Limiting in ASP.NET Core

Production Rate Limiting in ASP.NET Core

Nov 3, 2026
The Big Decimal Bugfix with .NET 11

The Big Decimal Bugfix with .NET 11

Nov 2, 2026
Distroless, Chiseled or Alpine: Choosing a .NET Base Image

Distroless, Chiseled or Alpine: Choosing a .NET Base Image

Oct 27, 2026
Stop Using nginx as Your Default Static File Server in Docker

Stop Using nginx as Your Default Static File Server in …

Oct 24, 2026
Containerizing .NET in 2026 Without a Dockerfile

Containerizing .NET in 2026 Without a Dockerfile

Oct 20, 2026

Tags

.NET (195) Csharp (99) ASP.NET Core (49) Azure (41) DevOps (17) Docker (15) Microsoft (14) EF Core (11) Microsoft MVP (11) Security (11) AI (10) GitHub (10) GitHub Copilot (10) ASP.NET (9) Synology (9) .NET 11 (8) Architecture (8) Raspberry (8) Azure Functions (7) Cloudflare (7)
benjamin-abt.com

About BEN

Benjamin Abt is a Software Engineer, Platform Architect and Microsoft MVP specializing in .NET, Azure, cloud architecture, performance optimization and sustainable software development.

Connect

  • Follow me on GitHub
  • Follow me on LinkedIn
  • Follow me on Mastodon
  • Microsoft MVP profile
  • Follow SchwabenCode on GitHub
  • Follow me on X

Quick Links

  • Portfolio
  • Blog
  • Workshops & Training
  • Publications
  • Get in Touch
  • Sitemap
Open for Work

© Copyright Benjamin Abt & SchwabenCode | 2011 - 2026

Content licensed under CC BY 4.0 unless otherwise noted.

  • Impressum
  • Privacy
  • Contact