Skip to content

akarshit-1609/Remote_Mouse_and_Keyboard_built_in_Python_FastAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI LAN Server Remote Mouse and Keyboard

Logo

This is a Python FastAPI application designed specifically to be hosted on a local machine and accessed by other devices (phones, tablets) connected to the same Local Area Network (WiFi or Ethernet).

You can turns your mobile device into a wireless mouse and keyboard to control host computer.

Note: This project is intended for LAN usage. It is configured to accept connections from external devices on the network, not just the local machine.


Prerequisites

  • Python 3.8+ installed
  • Git installed
  • A Code Editor (VS Code, PyCharm, etc.)

Installation Guide

  1. Clone the Repository Open your terminal or command prompt and run the following command to download the project:

    git clone https://github.com/akarshit-1609/Remote_Mouse_and_Keyboard_built_in_Python_FastAPI.git
    cd Remote_Mouse_and_Keyboard_built_in_Python_FastAPI
  2. Create a Virtual Environment (Recommended) It is best practice to run this project in a virtual environment.

    Windows:

    python -m venv venv
    .\venv\Scripts\activate

    macOS / Linux:

    python3 -m venv venv
    source venv/bin/activate
  3. Install Dependencies Install the required Python packages listed in requirements.txt:

    pip install -r requirements.txt

Configuration: Setting the IP Address

Crucial Step: Before running the application, you must configure the server to run on your specific LAN IP address so other devices can find it.

1. Find your LAN IP Address

  • Windows: Open Command Prompt and type ipconfig. Look for "IPv4 Address" (e.g., 192.168.1.15).
  • macOS/Linux: Open Terminal and type ifconfig or ip a. Look for the inet address under your active connection (usually starts with 192.168... or 10.0...).

2. Update the Python File

  • Open the main entry file (main.py) in your code editor.
  • Locate the uvicorn.run command at the bottom of the file.
  • Change the host parameter to your LAN IP address found in the previous step.

Example Change:

Change this:

    if __name__ == "__main__":
        uvicorn.run(app, host="0.0.0.0", port=8000)

    To this (replace with your actual IP):
    if __name__ == "__main__":
        # REPLACE '192.168.1.X' WITH YOUR ACTUAL IP ADDRESS
        uvicorn.run(app, host="192.168.1.x", port=8000)

Pro Tip: You can also set host="0.0.0.0" to allow connection from any available network interface on your computer.

Running the Server

Once configured, run the application using the following command:

python main.py

You should see output indicating the server is running, for example: Uvicorn running on http://192.168.1.15:8000.

Accessing from Another Device

Do not try to access this via localhost on your host device.

  • Ensure your second device (Phone) is connected to the same WiFi or Ethernet network as the host computer.
  • Open a web browser (Chrome, Safari, etc.) on the second device.
  • Type the IP address and port configured earlier into the address bar: http://192.168.1.x:8000
  • Now your device (mobile, tablet) become a wireless mouse, keyboard.

How to use

Here is the guide on how to use a Remote Mouse and Keyboard on your mobile device.

These application typically function in two modes: Touchpad Mode (gestures) and Mouse Mode (visible buttons). Below are the instructions for the features.

1. Move Cursor

  • Gesture: Place one finger inside the touchpad on the mobile screen and drag it. The mouse cursor on your computer will follow your finger's movement.

2. Left Click

  • Gesture: Tap the touchpad once with one finger.
  • Button Mode: If you see the three buttons at the bottom, click the Left button (usually the largest one on the left).

3. Right Click

  • Button Mode: Click the Right button at the bottom of the screen.

4. Middle Click (Scroll Wheel Click)

  • Button Mode: Click the Middle button (the small button usually located between the Left and Right buttons).

5. Scroll (Up & Down)

  • Gesture: Place two fingers together inside the touchpad on the mobile screen and drag them up or down simultaneously. This works like the scroll wheel on a physical mouse.

6. Keyboard

  • How to find: Look for a Keyboard icon on the top.
  • Action: Tap the icon to open your phone's keyboard. Anything you type on your phone will appear on your computer screen.

Tips: Refresh webpage if not working.

Troubleshooting

If the site does not load on the other device:

  • Firewall: Check if your Windows Firewall or Antivirus is blocking the connection. You may need to allow the Python executable through the firewall.
  • Network: Confirm both devices are definitely on the same network (e.g., ensure one isn't on Guest WiFi or Mobile Data).

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

About

This project turns your mobile device into a wireless mouse and keyboard to control host computer.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages