Why re-invent the wheel twice?

Everything you ask for is already available in Keepass in a function called "auto-type".
Short example: (considering Keepass is launched and sitting in the task tray).
A website or application installer needs a password.
You hit the global auto-type shortcut.
Keepass checks if the title of the current window is a.) the title of a record or b.) configured in a record as "auto-type-window".
If there is more than one hit, a pop up appears, asking you to select the proper record
Keepass sends "auto-type" or - if not configured - USERNAME TAB PASSWORD ENTER.
You can of course also open Keepass, search your record and let "auto type" execute (on the last active window).
Auto-type is just like any macro language allowing to send any key + comes with some extra commands like
[Title field {TITLE} or %TITLE%
Username field {USERNAME} or %USERNAME%
URL field {URL} or %URL%
Password field {PASSWORD} or %PASSWORD%
Notes field {NOTES} or %NOTES%
{VKEY X} Sends the VKEY of value X.
{BEEP X Y} Beeps with a frequency of X and a duration of Y milliseconds.
{DELAY X} Delays X milliseconds.
{DELAY=X} Sets the default delay to X milliseconds for all following keypresses.
{APPACTIVATE WindowTitle} Activates the window "WindowTitle".
{APPDIR} Will be replaced by the current application directory path.
{CLEARFIELD} Clears the contents of the edit control that currently has the focus.
I think even complicated commands (like for nVidia Pure Video) should be possible.