Multiple databases - force KP so it always offers DB_1 when called

Help
John
2012-12-05
2012-12-20
  • John

    John - 2012-12-05

    I have two databases, DB_1 with pwd_1, and DB_2 with pwd_2.
    KeePass is started but minimised to the taskbar and both DB_1 and DB_2 are locked.
    When I press Ctrl/Alt/a, KeePass offers me the last used database, which is probably DB_2.

    How do I force KeePass to offer me DB_1 every time?

    I have installed KeeAutoExec and set it so that when I open DB_1, KeeAutoExec opens DB_2 for me. I do not want to use KeeAutoExec to open DB_1 if DB_2 is opened because I would then have to store my DB_1 password in DB_2, which I don't want to do.
    I have searched the forum and tried to create a trigger (Event: Application initialised, Action: Open database file) but it didn't work for me.

     
    Last edit: John 2012-12-06
  • Dominik Reichl

    Dominik Reichl - 2012-12-05

    Create a Windows shortcut to your KDBX file (if you haven't associated KDBX files with KeePass: create a shortcut to KeePass.exe and specify the database file path as argument). By double-clicking on the shortcut, this database is opened.

    Of course you could also use a KeePass trigger (in this case I'd recommend disabling the option to open the last used file).

     
  • John

    John - 2012-12-05

    Perhaps I should add that I have KeePass configured so it always closes the databases 120 seconds after using it so my way of operating is:
    1 KeePass is minimised with all databases locked (Edit removed)
    2 place cursor in Username field on web page
    3 ctrl/alt/a to activate AutoType
    4 KeePass offers me the "Open Database" window for the last used database.
    5 I type in my password - KeePass searches all open databases for window matches

    I see there is an "AutoType selected entry" in Options > Integration - can that help?

     
    Last edit: John 2012-12-08
  • John

    John - 2012-12-05

    Dominik
    Thank you - unfortunately our posts crossed.
    I know I can use the command line to open a specified database when KeePass starts. My problem is I want to to force KeePass to offer me DB_1 when I do an AutoType request.

     
  • John

    John - 2012-12-05

    I can do what I want if I can force the DB_1 tab to be at the front when all databases are locked because AutoType always offers the password box for that database when it is activated.
    There is a trigger to activate the tab but I cannot get it to work. I tried with
    Event: application initialised; Actions: Activate Database (select tab)
    Event: closing db file before saving; Actions: Activate Database (select tab)
    where I used the full path to DB_1 for the actions.

     
  • Paul

    Paul - 2012-12-06

    I have the solution - maybe. :)

    1. Create a Trigger.
    2. Event = Opened database file DB_2. Use the full path.
    3. Action = Activate database file DB_1. Use the full path.

    cheers, Paul

     
  • John

    John - 2012-12-06

    Paul
    Thanks - but it didn't work :-(
    Essentially the problem is that on AutoType, KeePass always offers the password box to unlock the 'last active database'. So
    - if I have been editing an entry in DB_2
    - then DB_2 is the active database, and
    - KeePass wants to open DB_2.

    If I had a trigger Event "When database is locked" I could use the Action "Activate database (select tab)" and force DB_1 to be the active database every time KeePass locks the databases and minimises.

    I had been very confused because I did not realise that a database is "open" whenever it has a tab, and is "open" even when locked. Interestingly using (ie AutoTyping it to a web page) an entry from a database does not make that database the 'last active database'.

    I am experimenting with "Activate database (select tab)" but I managed to corrupt DB_2 (only a sandbox version!) doing so.

     
  • Paul

    Paul - 2012-12-06

    Add an additional trigger with the event "User interface state updated".

    cheers, Paul

     
  • wellread1

    wellread1 - 2012-12-06

    I believe the problem is that KeePass is not correctly remembering the last view settings when the "Activate database (select tab)" action is triggered during locking (database closing). If it is not possible to modify KeePass so that the result of the "Activate database" action is remembered during locking (closing), then your suggestion of adding an "On locking Database" event (before locking begins) would be helpful.

    I was able to observe the following sequence when a trigger, set to activate DB_1 when DB_2 is closed, executed during locking:

    1. DB_2 is closed
    2. DB_1 is activated (selected)
    3. DB_1 is closed
    4. KeePass interface is updated showing both databases locked and DB_2 is active (selected)

    Step 4 showing DB_2 is active is not the intended result of this trigger. (DB_1 should be active)

    Note: The steps above are not readily observable via the KeePass interface. However adding additional triggers that use the WAIT action and that are linked to the database closings allowed me to observe that DB_1 was selected during locking but that the selection was forgotten.

     
    Last edit: wellread1 2012-12-06
  • John

    John - 2012-12-06

    Paul - thanks. I had tried with that trigger but it didn't work, presumably becauase of wellread1's comment

    wellread1
    Thanks - that does explain it.

    If I could find a way to force DB_2 to close before DB_1 when KeePass minimises and both are closed, it would do what I want, but I cannot get any combination of triggers to do it.

    I also think you are saying that "locked" is the same as "closed". In other words, if KeePass has a tab marked 'DB.kbdx Locked', then DB is closed. It does not mean that 'DB is open, but locked'.

     
    Last edit: John 2012-12-06
  • wellread1

    wellread1 - 2012-12-07

    The only difference between locking and closing is the last view settings are saved in memory. Presumably these include the order in which the current databases should be re-opened at unlock. See http://keepass.info/help/base/security.html#seclocking.

    I also believe it would be useful to be able to define the re-opening order of multiple databases in a trigger, either at locking or at unlocking. Unfortunately I have not found a way to do this yet.

     
  • John

    John - 2012-12-08

    wellread1
    Thanks. Shall I submit a feature request or will Dominik have been reading these? My feature request would be:

    "A method where the user can specify which database is opened when an AutoType is performed".

     
  • wellread1

    wellread1 - 2012-12-08

    John,

    I think the feature is better defined as "A method where the user can specify which database is opened when a KeePass Workspace Unlock is triggered by global AutoType"

    I suspect that if the fix were straightforward it would be posted already, but it can't hurt to post a feature request. Besides yourself, this issue has thwarted develop1 and myself. See https://sourceforge.net/p/keepass/discussion/329221/thread/bd6e6245/?limit=250#a05d.

    -wellread1

     
    Last edit: wellread1 2012-12-08
  • John

    John - 2012-12-16

    I have also posted a bug report "KeePass does not remember the last view settings during locking" at https://sourceforge.net/p/keepass/bugs/1069/ as this appears to be a bug which, if fixed, may well be simpler to implement than the feature request.

     
  • John

    John - 2012-12-20

    Dominik

    Many, many thanks - that is absolutely fantastic. It does exactly what I want and also, I think, what several others would like. I would not have asked had I realised it required 5,000 lines of code to be examined.

    I created a trigger which activates the DB_1 tab when DB_2 is closed. It is

    Event: Closing database file (after saving) Equals C:...\DB_2.kdbx
    Conditions: none
    Actions: Activate database (select tab) File/URL C:...\DB_1.kdbx

    Whenever KeePass minimises, I see the DB_1 tab brought to the front. When I use AutoType by ctrl/alt/a, I am always offered DB_1 irrespective of which database had previously been at the front, and I always type my DB_1 password to "get into" KeePass. When DB_1 opens, KeeAutoExec opens DB_2 for me.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks