pykeepass icon indicating copy to clipboard operation
pykeepass copied to clipboard

Edit custom window titles for auto-type

Open vwochnik opened this issue 5 years ago • 1 comments

Hello there.

I am wondering how to edit the 'Custom sequences for specific windows' for individual entries.

Thank you.

vwochnik avatar Jul 10 '20 17:07 vwochnik

I stumbled on the same question, and I also wanted to know how to read/write the Plugin Data which is saved by KeePassXC under Properties.

Both questions have a similar answer, the key is entry.dump_xml(). You'll see the custom sequences in the tag AutoType and the plugin data tag is called CustomData.

To get the data:

def get_associations(entry):
    assocs = [ x.findall('Association') for x in entry._element.findall('AutoType') ]
    flattened_assocs = [ assoc for assoc_list in assocs for assoc in assoc_list ]
    associations = [ ( y.find('Window').text, y.find('KeystrokeSequence').text ) for y in flattened_assocs ]
    return associations

def get_custom_data(entry):
    items = [ x.findall('Item') for x in entry._element.findall('CustomData') ]
    flattened_items = [ item for item_list in items for item in item_list ]
    custom_data = { y.find('Key').text: y.find('Value').text for y in flattened_items }
    return custom_data

Saving and deleting is similar as for custom properties. See the functions set_custom_property and delete_custom_property in entry.py.

roelderickx avatar Oct 17 '21 15:10 roelderickx