I am missing a trigger that could be called "Executing Built-in KeePass Commands" that would execute KeePass GUI Command.
I use Keepass (v2.54 portable version) with multiple plugins (such as VeraCrypt Mount or KeeAgent).
The current KeePass2 Triggers support multiple Actions.
As a frequent KeePass user, in order to make KeePass perform manual actions, I would need a way to reproduce repetitive actions in KeePass. I would like to have a trigger action called "Executing Built-in KeePass Commands" that enable me to tell KeePass what to do.
Examples :
1) KeePass > Find > "Last Modifies Entries..."
2) KeePass > Select Entry with uuid:xxx > right click > "Mount Volume"
3) KeePass > Help > Donate...
In more details:
Example 1 : each time I open my database, in order to check last password changed with KeePass > Find > "Last Modified Entries...". I would like this result to be displayed automatically, without my manual action. How to find the last modified entries?"
Example 2 : I would like to auto-mount a VeraCrypt volume each time I open my database. Even though I read "automount truecrypt volume at startup with keepass" thread, (and "Mount a truecrypt file with keepass"). I have not been able to do it using "customer fields" used by the "VeraCrypt Mount" plugin (because the code "O" can't be used as WantedField). Hence, each time I open my database with the "VeraCrypt Mount" plugin, I have to right-click on a certain entry to activate the "Mount" action.
What do you think ?
Thanks in advance for your feedback.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is an interesting idea, but it would be difficult to make it work reliably with all commands in all situations.
Your example 1 can already be realized. You could add a trigger with the event 'Opened database file' and two actions: 'Wait' shortly (e.g. 500 ms) and 'Execute command line / URL' with 'File/URL' set to 'PowerShell.exe' (without the quotes) and 'Arguments' set to this: -Command "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('%im')"
(this simulates keypresses: Alt+I opens the 'Find' menu and M executes the 'Last Modified Entries' menu command). Furthermore, set 'Window style' to 'Hidden' (otherwise the PowerShell window receives the keypresses).
Best regards,
Dominik
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you Paul and Dominik for your quick feedback.
Thank you Dominik, your trick for my Example 1 works with SendWait('%im').
I am stuck in selecting an entry with my Example 2.
I hope finding help again O:)
I would like to send : Alt-i > F > veracrypt > ENTER > right-click > M > M
but I manage only to send: Alt-i > F > veracrypt > ENTER with this code: SendWait('%ifveracrypt{ENTER}')
The SendWait('{MENU}') (right-click) goes nowhere
I tried many key combinations (that work manually), but none works with SendWait():
SendWait('^fveracrypt{ENTER}') to simulate Ctrl-F > veracrypt > ENTER
--> this open a Find window but return nothing, like if it was looking in an empty database
SendWait('{TAB}{TAB}{ENTER}') to simulate TAB > TAB > ENTER
--> nothing happens
Please, would somebody have an idea how to "select an entry" (in order to send keys to it) ?
Note : I do not know anything about PowerShell (mine is 1.0 on a win7 x64) nor .NET Windows API (my .NET is 4.8)
Searching takes a few milliseconds, so you need to wait (you may also need to wait when a dialog opens, etc.). For waiting in PowerShell, there's the Start-Sleep command. For example, Start-Sleep -Seconds 1 waits one second.
In my previous post, I mentioned to start with a 'Wait' trigger action. Actually, waiting in PowerShell with Start-Sleep is even better.
For example, the following performs a search and opens the context menu: Add-Type -AssemblyName System.Windows.Forms; Start-Sleep -Milliseconds 500; [System.Windows.Forms.SendKeys]::SendWait('^fveracrypt{ENTER}'); Start-Sleep -Seconds 1; [System.Windows.Forms.SendKeys]::SendWait('+{F10}')
Depending on how long the operations take, a longer delay might be necessary (e.g. if you have a very large database, causing the search to take longer than 1 second).
Best regards,
Dominik
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Of course, with -Command "..." around the whole example.
If your script gets more complicated, consider to write a PS1 script file and run that with PowerShell, instead of putting everything into one command line.
Best regards,
Dominik
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1) VeraCrypt Mount Button
2) VeraCrypt AutoMount[1] (when opening a specific database)
3) Display Last Entries[1] (when opening any database)
4) VeraCrypt AutoMount & Last Modified Entries[1] (when opening a specific database)
[1] those triggers are not compatible together, use only one of them
Edit: I put then in the attached file (rather than in plain text)
Hello all,
Thanks for the amazing job each contributor does.
I am missing a trigger that could be called "Executing Built-in KeePass Commands" that would execute KeePass GUI Command.
I use Keepass (v2.54 portable version) with multiple plugins (such as VeraCrypt Mount or KeeAgent).
The current KeePass2 Triggers support multiple Actions.
As a frequent KeePass user, in order to make KeePass perform manual actions, I would need a way to reproduce repetitive actions in KeePass. I would like to have a trigger action called "Executing Built-in KeePass Commands" that enable me to tell KeePass what to do.
Examples :
1) KeePass > Find > "Last Modifies Entries..."
2) KeePass > Select Entry with uuid:xxx > right click > "Mount Volume"
3) KeePass > Help > Donate...
In more details:
What do you think ?
Thanks in advance for your feedback.
2 - This is really a change in the plug-in, not KeePass. A mount on startup option would work.
cheers, Paul
Last edit: Paul 2024-06-27
This is an interesting idea, but it would be difficult to make it work reliably with all commands in all situations.
Your example 1 can already be realized. You could add a trigger with the event 'Opened database file' and two actions: 'Wait' shortly (e.g. 500 ms) and 'Execute command line / URL' with 'File/URL' set to '
PowerShell.exe
' (without the quotes) and 'Arguments' set to this:-Command "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait('%im')"
(this simulates keypresses:
Alt
+I
opens the 'Find' menu andM
executes the 'Last Modified Entries' menu command). Furthermore, set 'Window style' to 'Hidden' (otherwise the PowerShell window receives the keypresses).Best regards,
Dominik
Thank you Paul and Dominik for your quick feedback.
Thank you Dominik, your trick for my Example 1 works with
SendWait('%im')
.I am stuck in selecting an entry with my Example 2.
I hope finding help again O:)
Alt-i > F > veracrypt > ENTER > right-click > M > M
Alt-i > F > veracrypt > ENTER
with this code:SendWait('%ifveracrypt{ENTER}')
SendWait('{MENU}')
(right-click) goes nowhereI tried many key combinations (that work manually), but none works with SendWait():
SendWait('^fveracrypt{ENTER}')
to simulateCtrl-F > veracrypt > ENTER
--> this open a Find window but return nothing, like if it was looking in an empty database
SendWait('{TAB}{TAB}{ENTER}')
to simulateTAB > TAB > ENTER
--> nothing happens
Please, would somebody have an idea how to "select an entry" (in order to send keys to it) ?
Note : I do not know anything about PowerShell (mine is 1.0 on a win7 x64) nor .NET Windows API (my .NET is 4.8)
Keys I collected that works with SendWait():
Last edit: Régis De Nice 2024-06-28
Searching takes a few milliseconds, so you need to wait (you may also need to wait when a dialog opens, etc.). For waiting in PowerShell, there's the
Start-Sleep
command. For example,Start-Sleep -Seconds 1
waits one second.In my previous post, I mentioned to start with a 'Wait' trigger action. Actually, waiting in PowerShell with
Start-Sleep
is even better.{MENU}
does not exist. In order to open the context menu, you could sendShift
+F10
, i.e.+{F10}
. All key codes that theSendKeys
class supports are documented here:https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys
For example, the following performs a search and opens the context menu:
Add-Type -AssemblyName System.Windows.Forms; Start-Sleep -Milliseconds 500; [System.Windows.Forms.SendKeys]::SendWait('^fveracrypt{ENTER}'); Start-Sleep -Seconds 1; [System.Windows.Forms.SendKeys]::SendWait('+{F10}')
Depending on how long the operations take, a longer delay might be necessary (e.g. if you have a very large database, causing the search to take longer than 1 second).
Best regards,
Dominik
Of course, with
-Command "..."
around the whole example.If your script gets more complicated, consider to write a PS1 script file and run that with PowerShell, instead of putting everything into one command line.
Best regards,
Dominik
This works great, thank you @dreichl 🙂 👍
Last edit: Régis De Nice 2024-07-26
I share my triggers :
1) VeraCrypt Mount Button
2) VeraCrypt AutoMount [1] (when opening a specific database)
3) Display Last Entries [1] (when opening any database)
4) VeraCrypt AutoMount & Last Modified Entries [1] (when opening a specific database)
[1] those triggers are not compatible together, use only one of them
Edit: I put then in the attached file (rather than in plain text)
Cheers, Regis
Last edit: Régis De Nice 2024-07-27