Skip to main content

A collection of functions to operate with a KeePass-database

Project description

KeePass AutoType Helper

This Python script allows you to retrieve credentials from a KeePass database and automatically type them into applications or fields using a custom AutoType sequence.

It integrates with:

  • pykeepass — to read entries from a KeePass database (.kdbx).
  • pywinauto — to send keystrokes and control windows.
  • dynamicinputbox — to prompt for KeePass database password interactively.

Features

  • Prompt for KeePass database password in a secure dialog.
  • Retrieve a full KeePass entry or just username/password.
  • Support for {USERNAME}, {PASSWORD}, {URL}, {NOTES}, and {TITLE} placeholders in AutoType sequences.
  • Handle special keys ({ENTER}, {TAB}, {F1}, etc.).
  • Handle delays ({DELAY 1000} for 1 second pause).
  • Support virtual key codes ({VKEY 0x41} for A).
  • Handle modifier keys ({CTRL}, {ALT}, {SHIFT}, {WIN}).

Requirements

Install dependencies via pip:

pip install pykeepass pywinauto dynamicinputbox

Usage

1. Prepare your KeePass database

Make sure your KeePass .kdbx file exists (default: ~/Pwd_Db.kdbx).

Add entries with:

  • Title (used to look up the entry).
  • Username and Password fields.
  • AutoType sequence (e.g., {USERNAME}{TAB}{PASSWORD}{ENTER}). This is optional for the entry, but needed for the use_KeePass_sequence method.

2. Import and use in Python

from keepass_autotype import get_credentials, use_KeePass_sequence

Retrieve only username & password

username, password = get_credentials( "My Entry Title" )

Retrieve full entry and auto-type it

use_KeePass_sequence( "My Entry Title" )

Default values

Database file: Pwd_Db.kdbx

Database path: ~ (home directory)

These can be replaced with: get_credentials("My Entry Title", file="Custom.kdbx", path="/path/to/db")

AutoType Sequence Syntax

Supported placeholders:

  • {USERNAME} — Entry's username.
  • {PASSWORD} — Entry's password.
  • {URL} — Entry's URL.
  • {NOTES} — Entry's notes.
  • {TITLE} — Entry's title.

Special commands:

  • {ENTER}, {TAB}, {ESC}, {F1} ... {F12}, {UP}, {DOWN}, {LEFT}, {RIGHT}.
  • {DELAY 1000} — Pause for 1000ms.
  • {VKEY 0x41} — Press virtual key (hex code).
  • {CTRL}, {ALT}, {SHIFT}, {WIN} — Press and hold modifier.
  • {CTRLUP}, {ALTUP}, {SHIFTUP}, {WINUP} — Release modifier.

Example

In KeePass, set the entry's AutoType sequence to:

{USERNAME}{TAB}{PASSWORD}{ENTER}

Then in Python:

use_KeePass_sequence("My Entry Title")

The script will:

  • Prompt for your KeePass database password.
  • Retrieve the username and password from the given entry.
  • Automatically type them into the currently focused application.

Security Notice

This script sends keystrokes to the active window — make sure the correct window is focused before running.

The KeePass database password is entered via a masked prompt but is kept in memory during runtime.

Use responsibly in trusted environments.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keepassfunctions-1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keepassfunctions-1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file keepassfunctions-1.0.tar.gz.

File metadata

  • Download URL: keepassfunctions-1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for keepassfunctions-1.0.tar.gz
Algorithm Hash digest
SHA256 e4b3cc06584b41fa4b02e490f483424fdd9ab5b0041d6bd2be9b355d3f466ae1
MD5 678fcf26a75d444f2d83696828475573
BLAKE2b-256 d3166be3d7d6504f8b64faac73dcc758eadf6cd4776e59106bf2fae705d0c88c

See more details on using hashes here.

File details

Details for the file keepassfunctions-1.0-py3-none-any.whl.

File metadata

  • Download URL: keepassfunctions-1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for keepassfunctions-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2344352a72f5850345e47e3aa0cf5cc3d94640f08c5eeeb36d0940a12862ad24
MD5 ba0ccecc11b031c640ca7ad9adee048a
BLAKE2b-256 093d3580e8c08dc89d868edb54e47e11c35a52bca439bff558b26442060f1f6b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page