A Windows 11 application that switches virtual desktops when your mouse hits the screen edges, similar to many X11 window managers.
- Edge Detection: Move mouse to left/right screen edge to switch desktops
- Debouncing: Prevents accidental rapid switching (500ms cooldown)
- Logging: Debug output shows all operations for troubleshooting
- Graceful Shutdown: Handles Ctrl+C for clean exit
The program continuously monitors your mouse position. When the mouse cursor reaches within 5 pixels of the left or right screen edge, it simulates the keyboard shortcut Ctrl+Win+Left or Ctrl+Win+Right to switch virtual desktops.
- Windows 11 (or Windows 10 with virtual desktop support)
- GCC compiler (MinGW or Cygwin)
build.batgcc edge_desktop_switcher.c -o edge_desktop_switcher.exe -lgdi32 -luser32Simply run the executable:
edge_desktop_switcher.exeThe program will:
- Start monitoring mouse position
- Print status messages to console
- Switch desktops when mouse hits edges
- Run until you press Ctrl+C
You can modify these constants in edge_desktop_switcher.c:
EDGE_THRESHOLD(default: 5) - Pixels from edge to trigger switchDEBOUNCE_MS(default: 500) - Milliseconds before allowing another switchPOLL_INTERVAL_MS(default: 50) - Mouse polling interval
The program uses:
- GetCursorPos() - Monitor mouse position
- SendInput() - Simulate keyboard shortcuts
- Win32 API - System metrics and input handling
Since Windows doesn't expose a public API for virtual desktop switching, the program simulates the native keyboard shortcuts that Windows 11 uses.
Desktop not switching?
- Verify you have multiple virtual desktops created in Windows 11
- Check that Ctrl+Win+Arrow works manually
- Look at console output for debug messages
Switches too often?
- Increase
DEBOUNCE_MSvalue - Increase
EDGE_THRESHOLDfor larger trigger zone
Not detecting edge?
- Reduce
EDGE_THRESHOLDvalue - Check console for mouse position logs
This is free and unencumbered software released into the public domain.