Auto Type

< cpp‎ | language

The World Forum for Harmonization of Vehicle Regulations (ECE Regulations) develops and maintains international-consensus UN Regulations on light sources acceptable for use in lamps on vehicles and trailers type-approved for use in countries that recognise the UN Regulations. These include Regulation 37, which contains specifications for filament lamps. 156 156 156r56r1. 2010 blue bird all american vin: 1bablcpa3af2 ford f350.

C++
Language
Standard Library Headers
Freestanding and hosted implementations
Named requirements
Language support library
Concepts library(C++20)
Diagnostics library
Utilities library
Strings library
Containers library
Iterators library
Ranges library(C++20)
Algorithms library
Numerics library
Localizations library
Input/output library
Filesystem library(C++17)
Regular expressions library(C++11)
Atomic operations library(C++11)
Thread support library(C++11)
Technical Specifications
C++ language
General topics
Keywords
Escape sequences
Flow control
Conditional execution statements
Iteration statements (loops)
while
do-while
Jump statements
goto - return
Functions
Function declaration
Lambda function declaration
inline specifier
Exception specifications(until C++20)
noexcept specifier(C++11)
Exceptions
Namespaces
Types
Fundamental types
Enumeration types
Function types
Specifiers
decltype(C++11)
auto(C++11)
alignas(C++11)
Storage duration specifiers
Initialization
Default initialization
Value initialization
Zero initialization
Copy initialization
Direct initialization
Aggregate initialization
List initialization(C++11)
Constant initialization
Reference initialization
Expressions
Operators
Operator precedence
Alternative representations
Literals
Boolean - Integer - Floating-point
Character - String - nullptr(C++11)
User-defined(C++11)
Utilities
Attributes(C++11)
Types
typedef declaration
Type alias declaration(C++11)
Casts
Implicit conversions - Explicit conversions
static_cast - dynamic_cast
const_cast - reinterpret_cast
Memory allocation
Classes
Access specifiers
friend specifier
Class-specific function properties
Virtual function
override specifier(C++11)
final specifier(C++11)
Special member functions
Default constructor
Copy constructor
Move constructor(C++11)
Copy assignment
Move assignment(C++11)
Destructor
Templates
Template specialization
Parameter packs(C++11)
Miscellaneous
Declarations
Overview
declaration syntax
decl-specifier-seq
declarator
Specifiers
virtual function specifier
explicit function specifier
(C++11)
(C++20)
(C++20)
storage class specifiers
(C++11)
(C++11)
(C++11)
elaborated type specifier
attributes (C++11)
Declarators
reference
pointer
array
Block declarations
simple-declaration
→ structured binding declaration(C++17)
alias declaration(C++11)
namespace alias definition
using-declaration
using-directive
static_assert declaration(C++11)
asm-declaration
opaque enum declaration(C++11)
Other declarations
namespace definition
function declaration
class template declaration
function template declaration
explicit template instantiation(C++11)
explicit template specialization
linkage specification
attribute declaration(C++11)
empty declaration

For variables, specifies that the type of the variable that is being declared will be automatically deduced from its initializer.

For functions, specifies that the return type will be deduced from its return statements.

(since C++14)

For non-type template parameters, specifies that the type will be deduced from the argument.

(since C++17)

[edit]Syntax

auto (1)(since C++11)
decltype(auto) (2)(since C++14)
type-constraintauto (3)(since C++20)
type-constraintdecltype(auto) (4)(since C++20)
type-constraint - a concept name, optionally qualified, optionally followed by a template argument list enclosed in <>
1,3) type is deduced using the rules for template argument deduction.
2,4) type is decltype(expr), where expr is the initializer.

The placeholder auto may be accompanied by modifiers, such as const or &, which will participate in the type deduction. The placeholder decltype(auto) must be the sole constituent of the declared type.(since C++14)

[edit]Explanation

A placeholder type specifier may appear in the following contexts:

  • in the type specifier of a variable: auto x = expr;. The type is deduced from the initializer.
    If the placeholder type specifier is autoor type-constraintauto(since C++20), the variable type is deduced from the initializer using the rules for template argument deduction from a function call (see template argument deduction#Other contexts for details).
    For example, given constauto& i = expr;, the type of i is exactly the type of the argument u in an imaginary template template<class U>void f(const U& u) if the function call f(expr) was compiled. Therefore, auto&& may be deduced either as an lvalue reference or rvalue reference according to the initializer, which is used in range-based for loop.

    If the placeholder type specifier is decltype(auto)or type-constraintdecltype(auto)(since C++20), the deduced type is decltype(expr), where expr is the initializer.

    (since C++14)

    If the placeholder type specifier is used to declare multiple variables, the deduced types must match. For example, the declaration auto i =0, d =0.0; is ill-formed, while the declaration auto i =0, *p =&i; is well-formed and the auto is deduced as int.

  • in the type-id of a new expression. The type is deduced from the initializer. For new Tinit (where T contains a placeholder type, init is either a parenthesized initializer or a brace-enclosed initializer list), the type of T is deduced as if for variable x in the invented declaration T x init;.
  • (since C++14) in the return type of a function or lambda expression: auto& f();. The return type is deduced from the operand of its non-discarded(since C++17)return statement.
    See function#Return_type_deduction.
  • (since C++17) in the parameter declaration of a non-type template parameter: template<auto I>struct A;. Its type is deduced from the corresponding argument.

Furthermore, autoand type-constraintauto(since C++20) can appear in:

  • the parameter declaration of a lambda expression: [](auto&&){}. Such lambda expression is a generic lambda.
  • (since C++20) a function parameter declaration: void f(auto);. The function declaration introduces an abbreviated function template.
(since C++14)
TypeAuto Type

If type-constraint is present, let T be the type deduced for the placeholder, T must satisfy the immediately-declared constraint of type-constraint. That is,

  • If type-constraint is Concept<A1, ..., An>, then the constraint expression Concept<T, A1, ..., An> must be valid and return true;
  • otherwise (type-constraint is Concept without an argument list), the constraint expression Concept<T> must be valid and return true.
(since C++20)

[edit]Notes

Until C++11, auto had the semantic of a storage duration specifier.

Mixing auto variables and functions in one declaration, as in auto f()->int, i =0; is not allowed.

The auto specifier may also be used with a function declarator that is followed by a trailing return type, in which case the declared return type is that trailing return type (which may again be a placeholder type).

The auto specifier may also be used in a structured binding declaration.

(since C++17)

The auto keyword may also be used in a nested-name-specifier. A nested-name-specifier of the form auto:: is a placeholder that is replaced by a class or enumeration type following the rules for constrained type placeholder deduction.

(concepts TS)

[edit]Example

Possible output:

Retrieved from 'https://en.cppreference.com/mwiki/index.php?title=cpp/language/auto&oldid=127488'

Powerful feature that sends simulated keypresses to other applications.

  • Invoking Auto-Type
  • Specifying Keystroke Sequences and Target Windows

Basic Auto-Type Information

KeePass features an 'Auto-Type' functionality. This feature allows you to define a sequence of keypresses, which KeePass can automatically perform for you. The simulated keypresses can be sent to any other currently open window of your choice (browser windows, login dialogs, ...).

By default, the sent keystroke sequence is {USERNAME}{TAB}{PASSWORD}{ENTER}, i.e. it first types the user name of the selected entry, then presses the Tab key, then types the password of the entry and finally presses the Enter key.

For TAN entries, the default sequence is {PASSWORD}, i.e. it just types the TAN into the target window, without pressing Enter.

You can freely define your own Auto-Type sequence: simply write the sequence into the notes field of the entry, prefixed with 'Auto-Type:'. Your notes could look something like this:
As you can see, the only important thing is that the auto-type sequence is prefixed using 'Auto-Type:' and is one single line. An auto-type sequence cannot be defined using two or more lines.
If you define two or more auto-type sequences, the first one is used.

Auto-Type can be configured individually for each entry using the Auto-Type tab page on the entry dialog (select an entry → Edit Entry). On this page you can specify a default sequence and customize specific window/sequence associations.
Two-Channel Auto-Type Obfuscation is supported (making Auto-Type resistant against keyloggers).

Additionally, you can create customized window/sequence associations, which override the default sequence. You can specify different keystroke sequences for different windows for each entry. For example, imagine a webpage, to which you want to login, that has multiple pages where one can login. These pages could all look a bit different (on one you could additionally need to check some checkbox – like often seen in forums). Here creating customized window/sequence associations solves the problems: you simply specify different auto-type sequences for each windows (identified by their window titles).

Invoking Auto-Type:
There are three different methods to invoke auto-type:

  • Invoke auto-type for an entry by using the context menu command Perform Auto-Type while the entry is selected.
  • Select the entry and press Ctrl+V (that's the menu shortcut for the context menu command above).
  • Using the system-wide auto-type hot key. KeePass will search all entries in the currently opened database for matching sequences.

All methods are explained in detail below.

Input Focus:
Note that auto-type starts typing into the control of the target window that has the input focus. Thus, for example for the default sequence you have to ensure that the input focus is set to the user name control of the target window before invoking auto-type using any of the above methods.


Requirements and Limitations

Rights:
For auto-type to work, KeePass must be running with the same or higher rights as the target application. Especially, if the target application is running with administrative rights, KeePass must be running with administrative rights, too. For details, see Windows Integrity Mechanism Design. An example are certain instances of VMware Workstation that run on a higher integrity level.

Remote Desktops and Virtual Machines:
KeePass does not know the keyboard layout that has been selected in a remote desktop or virtual machine window. If you want to auto-type into such a window, you must ensure that the local and the remote/virtual system are using the same keyboard layout.

When performing auto-type into a remote desktop or virtual machine window, the following characters may be problematic (depending on the exact circumstances) and should therefore be avoided, if possible: ' (U+0022), ' (U+0027), ^ (U+005E), ` (U+0060), ~ (U+007E), ¨ (U+00A8), ¯ (U+00AF), ° (U+00B0), ´ (U+00B4), ¸ (U+00B8), spacing modifier letters (U+02B0 to U+02FF), and characters that cannot be realized with a direct key combination.

Wayland:
On a Unix-like system with a Wayland compositor, there may be further limitations; see the Auto-Type on Wayland page.


Context Menu: 'Perform Auto-Type' Command

This method is the one that requires the least amount of configuration and is the simpler one, but it has the disadvantage that you need to select the entry in KeePass which you want to auto-type.

The method is simple: right-click on an entry of your currently opened database and click 'Perform Auto-Type' (or alternatively press the Ctrl+V shortcut for this command). The window that previously got the focus (i.e. the one in which you worked before switching to KeePass) will be brought to the foreground and KeePass auto-types into this window.

The sequence which is auto-typed depends on the window's title. If you didn't specify any custom window/sequence associations, the default sequence is sent. If you created associations, KeePass uses the sequence of the first matching association. If none of the associations match, the default sequence is used.


Global Auto-Type Hot Key

This is the more powerful method, but it also requires a little bit more work/knowledge, before it can be used.

Simple Global Auto-Type Example:

  1. Create an entry in KeePass titled Notepad with values for user name and password.
  2. Start Notepad (under 'Programs' → 'Accessories').
  3. Press Ctrl+Alt+A within Notepad. The user name and password will be typed into Notepad.

The KeePass entry title Notepad is matched with the window title of Notepad and the default Auto-Type sequence is typed.

How It Works - Details:

KeePass registers a system-wide hot key for auto-type. The advantage of this hot key is that you don't need to switch to the KeePass window and select the entry. You simply press the hot key while having the target window open (i.e. the window which will receive the simulated keypresses).

By default, the global hot key is Ctrl+Alt+A (i.e. hold the Ctrl and Alt keys, press A and release all keys). You can change this hot key in the options dialog (main menu 'Tools' → 'Options' → tab 'Integration'/'Advanced'): here, click into the global auto-type hot key textbox and press the hot key that you wish to use. If the hot key is usable, it will appear in the textbox.

When you press the hot key, KeePass looks at the title of the currently opened window and searches the currently opened database for usable entries. If KeePass finds multiple entries that can be used, it displays a selection dialog. An entry is considered to be usable for the current window title when at least one of the following conditions is fulfilled:

  • The title of the entry is a substring of the currently active window title.
  • The entry has a window/sequence association, of which the window specifier matches the currently active window title.

The second condition has been mentioned already, but the first one is new. By using entry titles as filters for window titles, the configuration amount for auto-type is almost zero: you only need to make sure that the entry title is contained in the window title of the window into which you want the entry to be auto-typed. Of course, this is not always possible (for example, if a webpage has a very generic title like 'Welcome'), here you need to use custom window/sequence associations.

Custom window/sequence associations can be specified using the Notes field of entries. If you now have a window open that starts with 'Some Website - Welcome' and press the global auto-type hot key combination, KeePass performs the auto-type sequence above.
Some sites, notably banks, use multi-page login schemes. You can use Auto-Type-Window strings to automate these sites. You can also use Auto-Type-Window strings to standardize your LAN login in one KeePass entry.
As many Auto-Type-Window strings per entry can be defined as you wish.
Also, one sequence can be used for multiple windows. For this, first define a window/sequence pair as normal, then continue by appending '-' and a number, starting with 1. Example: Here, the Auto-Type-1 sequence will be used for all Auto-Type-Window-1 windows.
Custom window associations override the KeePass entry title. If any custom window associations are specified, they will be the only item(s) used to determine a match and the KeePass entry title will be ignored.

Custom window/sequence associations can be specified on the 'Auto-Type' tab page of each entry.
The associations complement the KeePass entry title. Any associations specified will be used in addition to the KeePass entry title to determine a match.

Auto-Type window definitions, entry titles and URLs are Spr-compiled, i.e. placeholders, environment variables, field references, etc. can be used.

Auto Typer


Auto-Type Keystroke Sequences

An auto-type keystroke sequence is a one-line string that can contain placeholders and special key codes.

A complete list of all supported placeholders can be found on the page Placeholders. The special key codes can be found below.

Above you've seen already that the default auto-type is {USERNAME}{TAB}{PASSWORD}{ENTER}. Here, {USERNAME} and {PASSWORD} are placeholders: when auto-type is performed, these are replaced by the appropriate field values of the entry. {TAB} and {ENTER} are special key codes: these are replaced by the appropriate keypresses. Special key codes are the only way to specify special keys like Arrow-Down, Shift, Escape, etc.

Of course, keystroke sequences can also contain simple characters to be sent. For example, the following string is perfectly valid as keystroke sequence string:
{USERNAME}{TAB}Some text to be sent!{ENTER}.

Special key codes are case-sensitive.

Special key codes are case-insensitive.

Special Keys:
The following codes for special keys are supported:

Special KeyCode
Tab{TAB}
Enter{ENTER} or ~
Arrow Up{UP}
Arrow Down{DOWN}
Arrow Left{LEFT}
Arrow Right{RIGHT}
Insert{INSERT} or {INS}
Delete{DELETE} or {DEL}
Home{HOME}
End{END}
Page Up{PGUP}
Page Down{PGDN}
Space{SPACE}
Backspace{BACKSPACE}, {BS} or {BKSP}
Break{BREAK}
Caps-Lock{CAPSLOCK}
Escape{ESC}
Windows Key{WIN} (equ. to {LWIN})
Windows Key: left, right{LWIN}, {RWIN}
Apps / Menu{APPS}
Help{HELP}
Numlock{NUMLOCK}
Print Screen{PRTSC}
Scroll Lock{SCROLLLOCK}
F1 - F16{F1} - {F16}
Numeric Keypad +{ADD}
Numeric Keypad -{SUBTRACT}
Numeric Keypad *{MULTIPLY}
Numeric Keypad /{DIVIDE}
Numeric Keypad 0 to 9{NUMPAD0} to {NUMPAD9}
Shift+
Ctrl^
Alt%

Special KeyCode
+{PLUS}
%{PERCENT}
^{CARET}
~{TILDE}
(, ){LEFTPAREN}, {RIGHTPAREN}
{, }{LEFTBRACE}, {RIGHTBRACE}
@{AT}
Windows Key (as modifier)@

Special KeyCode
+{+}
%{%}
^{^}
~{~}
(, ){(}, {)}
[, ]{[}, {]}
{, }{{}, {}}

Additionally, some special commands are supported:

Command SyntaxAction
{DELAY X}Delays X milliseconds.
{DELAY=X}Sets the default delay to X milliseconds for all following keypresses.
{CLEARFIELD}Clears the contents of the edit control that currently has the focus (only single-line edit controls).
{VKEY X}Sends the virtual key of value X.
{APPACTIVATE WindowTitle}Activates the window 'WindowTitle'.
{BEEP XY}Beeps with a frequency of X hertz and a duration of Y milliseconds.

Command SyntaxAction
{VKEY XF}Sends the virtual key of value X; see below.

{VKEY XF}:
This command sends the virtual key of value X. The parameter FAuto Type is optional and may be a combination of the following values:
  • E: Send an extended key; see below.
  • N: Send a non-extended key; see below.
  • D: Press and hold down the key (without releasing it).
  • U: Release the key (without pressing it).

The values E and N are mutually exclusive. It is recommended to specify neither E nor N, if possible; KeePass then determines automatically whether the virtual key is typically realized using an extended key.

The values D and U are mutually exclusive. If neither D nor U is specified, KeePass sends a keypress (i.e. down and up).

On Linux systems, KeePass automatically converts most Windows virtual key codes to Linux key codes (i.e. the {VKEY ...} command works on both systems).

Examples:
  • {VKEY 13}
    Presses and releases the primary Enter key. This is equivalent to {ENTER}.
  • {VKEY 13 E}
    Presses and releases the Enter key of the numeric keypad.
  • {VKEY 91 D}e{VKEY 91 U}
    Sends Win+E (i.e. it presses and holds down the left Win key, presses and releases the E key, and releases the Win key), which starts Windows Explorer (on Windows). This is not equivalent to {LWIN}e (which first presses and releases the left Win key and then presses and releases the E key).
    Note that Windows Explorer can also be started using {CMD:/Explorer.exe/W=0/} (the {CMD:/.../} placeholder can run arbitrary command lines).
Do not use the {VKEY ...} command to change the state of the Shift, Ctrl and Alt modifiers. For this, use +, ^ and % instead (see above).
Keys and special keys (not placeholders or commands) can be repeated by appending a number within the code. For example, {TAB 5} presses the Tab key 5 times.

Examples:

{TITLE}{TAB}{USERNAME}{TAB}{PASSWORD}{ENTER}
Types the entry's title, a Tab, the user name, a Tab, the password of the currently selected entry, and presses Enter.

{TAB}{PASSWORD}{ENTER}
Presses the Tab key, enters the entry's password and presses Enter.

{USERNAME}{TAB}^v{ENTER}
Types the user name, presses Tab, presses Ctrl+V (which pastes data from the Windows clipboard in most applications), and presses Enter.

Toggling Checkboxes:
A checkbox (e.g. 'Stay logged in on this computer') can usually be toggled by sending a space character (' '). Example:
{USERNAME}{TAB}{PASSWORD}{TAB} {TAB}{ENTER}
If there is a form with a user name field, a password field and a checkbox, this sequence would enter the user name, the password and toggle the checkbox that follows the password control.

Pressing Non-Default Buttons:
Pressing non-default buttons works the same as toggling checkboxes: send a space character (' '). Note that this should only be used for non-default buttons; for default buttons, {ENTER} should be sent instead.

Higher ANSI Characters:
The auto-type function supports sending of higher ANSI characters in range 126-255. This means that you can send special characters like ©, @, etc. without any problems; you can write them directly into the keystroke sequence definition.


Target Window Filters

When creating a custom window/sequence association, you need to tell KeePass how the matching window titles look like. Here, KeePass supports simple wildcards:

String with WildcardMeaning
STRINGMatches all window titles that are named exactly 'STRING'.
STRING*Matches all window titles that start with 'STRING'.
*STRINGMatches all window titles that end with 'STRING'.
*STRING*Matches all window titles that have 'STRING' somewhere in the window title. This includes the string being directly at the start or at the end of the window title.

Other wildcards aren't supported. The * wildcard must not be in the middle of a string.
For example, *Windows*Explorer* won't match Windows Explorer, it will only match Windows*Explorer, i.e. the middle * character is treated as '*' text character instead of a wildcard.

Wildcards may also appear in the middle of patterns. For example, *Windows*Explorer* would match Windows Internet Explorer.
Additionally, matching using regular expressions is supported. In order to tell KeePass that the pattern is a regular expression, enclose it in //. For example, //B.?g Window// would match Big Window, Bug Window and Bg Window.

By using wildcards, you can make your auto-type associations browser-independent. See the usage examples for more information.


Change Default Auto-Type Sequence

The default auto-type sequence (i.e. the one which is used when you don't specify a custom one) is {USERNAME}{TAB}{PASSWORD}{ENTER}. KeePass allows you to change this default sequence. Normally you won't need to change it (use custom window/sequence definitions instead!), but it is quite useful when some other application is interfering with KeePass (for example a security software that always asks you for permission before allowing KeePass to auto-type).

The default auto-type sequence can be changed in the Auto-Type configuration dialog. This dialog can be found in 'Tools''Options''Advanced''Auto-Type'.

By default, entries inherit the auto-type sequence of their containing group. Groups also inherit the auto-type sequence of their parent groups. There is only one top group (the first group contains all other groups). Consequently, if you change the auto-type sequence of this very first group, all other groups and their entries will use this sequence. Practically, this is a global override. To change it, right-click on the first group, choose 'Edit Group' and switch to the 'Auto-Type' tab.

Usage Example

Now let's have a look at a real-world example: logging into a website. In this example, will we use the global auto-type hot key to fill out the login webpage. First open the test page, and afterwards create a new entry in KeePass with title Test Form and a user name and password of your choice.

Let's assume the global auto-type hot key is set to Ctrl+Alt+A (the default). KeePass is running in the background, you have opened your database and the workspace is unlocked.

Auto Typer Download

When you now navigate to the test page and are being prompted for your user name and password, just click into the user name field and press Ctrl+Alt+A. KeePass enters the user name and password for you!

Auto Typer For Nitro Type

Why did this work? The window title of your browser window was 'Test Form - KeePass - Internet Explorer' or 'Test Form - KeePass - Mozilla Firefox', depending on the browser you are using. Because we gave the entry in KeePass the title Test Form, the entry title is contained in the window title, therefore KeePass uses this entry.

Auto Typer For Nitro Type

Here you see the huge advantages of auto-type: it not only doesn't require any additional browser software (the browser knows nothing of KeePass – there are no helper browser plugins required), it is also browser-independent: the one entry that you created within KeePass works for Internet Explorer and Mozilla Firefox (and other browsers) without requiring any modifications or definitions.

When you would use window/sequence associations (instead of entry title matching), you can achieve the same browser-independent effect using wildcards: you could for example have used Test Form - KeePass - * as window filter. This filter matches both the Internet Explorer and the Firefox window.