KeeAutoExec mess up triggers
A lightweight and easy-to-use password manager
Brought to you by:
dreichl
I have a main database which automatically opens two other databases using KeeAutoExec.
I have a trigger which uses the "Opened database file" event.
When opening my main database, I would expect my trigger to run three times (one for my main database, and two times for the other ones).
The problem is, the trigger doesn't run for my main database. It only runs for the other ones.
Also, I suspect it's running twice for each database, as I tested it using a message box action on my trigger.
I'm using KeePass 2.61 and KeeAutoExec 2.6.0.0.
Based on your description it is unlikely that the behavior you observe is caused by bugs in the KeeAutoExec plugin or in triggers.
The opened database file event occurs when a database is opened. You can limit when the event causes the trigger to execute by using the optional File URL filter. Also check that triggers that use the open database file action are not active, because this might cause looping. You can also use the change trigger on/off state action to prevent looping.
Not behaving like you expect or messing up are to be expected when one develops a script. Such behavior is usually not evidence of a bug. I suggest you simplify your trigger to the simplest trigger possible that still exhibits the unexpected behavior. The cause of the problem should be easier to identify in the simplified trigger and likewise a solution may be more readily apparent.
If you need additional help please open a help thread. Post a concise but complete description of what your trigger is trying to achieve. You can also post a sample trigger that exhibits the undesired behavior.
Last edit: wellread1 2 days ago
Fine. Adding a filter solves the event trigger multiple times.
BUT still my main database doesn't receive the event, but the first opened database by KeeAutoExec receives two times the event (I suspect it's receiving the event instead of my main database, SO THERE IS A BUG).
I disabled all my other triggers and I'm attaching just the two triggers I have enabled which are needed to reproduce the bug.
The first trigger opens my main database (M_Santiago). That database opens other two databases using KeeAutoExec.
The second trigger gets triggered twice for the first database opened by KeeAutoExec, and one for the second database.
BUT it doesn't get triggered for my main database. There is a bug there.
I can't get your triggers to import.
Can you export them without trimming stuff? (Highlight the triggers and select Tools > Export selected triggers.)
cheers, Paul
Done.
You need to edit the trigger paths and have my setup (one main database opening two other databases using KeeAutoExec).
For more details, read my other posts on this thread
The
{DB_NAME}placeholder returns the name of the current database, which may differ from the one matching a trigger event. As plugin events (used by KeeAutoExec) are raised before trigger events here, we get the behavior that you described. This is correct, not a bug.If you want to see a message box for each opened database, you need to insert another action before the 'Show message box' action: 'Activate database (select tab)' with the filter set to 'Triggering' (and leave 'File/URL' empty).
Best regards,
Dominik
How can I get the name of the opened database which triggered the event?
I have more triggers (disabled at the moment) which compare timestamps of my local databases and Dropbox, then create temp files and according to these files, sync my databases.
The problem is, I can't get it to work with my main database, as you noticed, if I use {DB_NAME} it doesn't contain my main database name, but the first opened database by KeeAutoExec.
My goal with the "Prueba" trigger was to test this using a message box.
So, if this is not a bug, then it's hard limiting what I can do.
I understand KeeAutoExec is switching the tab to it's first opened database, but It seems like a bug because I have no way to react properly to my main database opened event.
It gets even worse because instead of doing it's job once per database, it gets done twice for the first opened database by KeeAutoExec.
I tried what you said about activate database with filter = "Triggering", but it's not working.
I attach a screenshot of what I did.
I still get the same behavior: two message box for the first opened database by KeeAutoExec and no message at all for my main database
Add the filename of the autoopen database that is not being activated to the activate database action. The autoopen database will be activated last, even though it was opened first. See the attached screenshot.
Done. Same behavior.
Isn't this a bug?
Also, I also tried changing the filter to "All". It made all the three triggered events show my main database name (not what I want)
Maybe, maybe not. In any event you should have posted in the help forum first. If the discussion in the help forum revealed a well characterized bug, you would then be in a position to post a concise description of the bug with sufficient documentation to reproduce it.
The documentation of the Filter conditions in the trigger action 'Activate database (select tab):' appears to be at odds with the observed behavior when actions carried out by the KeeAutoExec plugin raise an 'opened database file:' event in a trigger. See my post above where it appears to be necessary to enter the name of the database that contains the autoopen commands into the 'File/URL' field to activate the autoopen database. https://sourceforge.net/p/keepass/bugs/2419/#8406
It is unclear (to me) whether this is bug, or a subtle consequence of the order of execution of various KeeAutoExec events and actions that determine the triggering file and should be clarified in the documentation. e.g. What is the triggering file when actions of the KeeAutoExec plugin are intercepted by a trigger?
Last edit: wellread1 1 day ago
We need Dominik to clarify this.
Would you suggest me to create a help thread?
If that's the case, what concise description would you use?
There is no need at this point. The issues are clear after 13 posts.
I'd suggest to delete the 'File/URL - Filter' from the event of the 'Prueba' trigger, because the current database may already differ from the triggering one at this point and you want it to run for all databases.
With the filter removed, everything looks fine to me, i.e. I cannot reproduce the issue.
Here's a complete package for testing:
https://keepass.info/filepool/KeePass_260319_Test.zip
The package contains KeePass 2.61, KeeAutoExec 2.6, three databases (all with master password '123', and the first one containing KeeAutoExec entries for opening the other two databases) and configuration files containing your triggers, with adjusted paths.
When starting KeePass, the first trigger opens the first database, and KeeAutoExec then opens the other two databases. As expected, the second trigger shows one message box for each of the three databases (in the order 2, 3, 1, which is also expected, because plugin events are raised before trigger events here, like I wrote before).
Best regards,
Dominik
Tysm.
Now I found the bug!!!
It has nothing to do with the "Prueba" trigger but with my actual trigger which I didn't share. However, to keep things simple, we will re-use the setup you created.
With your setup, add the following condition to the "Prueba" trigger:
File exists
{APPDIR}\{DB_BASENAME}.kdbx
It does trigger.
BUT if you change it for:
{APPDIR}\{DB_BASENAME}.txt
And you create for example the file "Database1.txt" it DOES NOT trigger for the main database. That's what is happening to me.
However, if you create the "Database2.txt" file it does only trigger for Database2.
If you rename "Database2.txt" to "Database3.txt", it triggers for Database3 AND Database1.
The problem is on my use-case I may have only the "Database1.txt" file. And it isn't triggering the event for my Database1.
This is a huge problem as to raise events on the main database you depend on having events raised on the other databases, which sometimes they won't rise.
Last edit: Santiago González 11 hours ago