This Python script monitors the clipboard for any changes and logs the clipboard content along with a timestamp to a JSON file.
- Python 3.x
pypercliplibraryscrcpy(for Android device screen mirroring)
You can install the required library using pip:
pip install pyperclipYou can install scrcpy by following the instructions on the scrcpy GitHub page.
-
Run the script:
python app/main.py
-
Monitor the clipboard:
- The script will start monitoring the clipboard for any changes.
- When the clipboard content changes, it will append the new content along with a timestamp to
app/clipboard_history.json.
-
Stop the script:
- Press
Ctrl+Cto stop monitoring.
- Press
app/main.py: The main script that monitors the clipboard and logs changes.app/clipboard_history.json: The JSON file where clipboard history is stored.
- Monitors the clipboard for changes.
- If the clipboard content changes, it calls
append_to_json()to log the new content. - Runs indefinitely until interrupted by
Ctrl+C.
- Appends the given content along with a timestamp to
app/clipboard_history.json. - If the file does not exist or is empty, it creates a new JSON array.
Here is an example of what the app/clipboard_history.json file might look like after running the script:
[
{
"timestamp": "2023-10-01T12:34:56.789123",
"content": "First clipboard content"
},
{
"timestamp": "2023-10-01T12:35:10.123456",
"content": "Second clipboard content"
}
]- The script checks the clipboard every 500 milliseconds.
- Ensure you have write permissions to the
app/clipboard_history.jsonfile or the directory where it is located.
This project is licensed under the MIT License.