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.
- Python 3.8+ installed
- Git installed
- A Code Editor (VS Code, PyCharm, etc.)
-
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 -
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 -
Install Dependencies Install the required Python packages listed in requirements.txt:
pip install -r requirements.txt
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.
- 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...).
- 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.
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.
Once configured, run the application using the following command:
python main.pyYou should see output indicating the server is running, for example: Uvicorn running on http://192.168.1.15:8000.
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.
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.
- 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.
- 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).
- Button Mode: Click the Right button at the bottom of the screen.
- Button Mode: Click the Middle button (the small button usually located between the Left and Right buttons).
- 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.
- 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.
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).
This project is licensed under the Apache License 2.0. See the LICENSE file for details.