Ducky commands
Ducky Script syntax is simple. Each command resides on a new line and may have options follow. Commands are written in ALL CAPS, because ducks are loud and like to quack with pride. Most commands invoke keystrokes, key-combos or strings of text, while some offer delays or pauses. Below is a list of commands and their function, followed by some example usage. [1]
The syntax is very simple and abstractly looks like this:
COMMAND_1 ARGUMENT_1 ARGUMENT_2 ... ARGUMENT_N
COMMAND_2 ARGUMENT_1 ARGUMENT_2 ... ARGUMENT_N
...
COMMAND_N ARGUMENT_1 ARGUMENT_2 ... ARGUMENT_N
Syntax features
As already mentioned, each command is written from a new line. Empty lines are allowed both at the beginning and end of the file, and between commands (they do not affect the process in any way, the parser simply ignores them)
There must be strictly one space between the command and the argument and between each argument. Spaces at the end of lines are truncated, so the command "STRING Hello World "
will be equivalent to "STRING Hello World"
All commands which supported by the parser are described here
REM
DELAY
- class pparser.commands.DELAY(arg, pparser)[source]
Command creates a momentary pause in the ducky script. It is quite handy for creating a moment of pause between sequential commands that may take the target computer some time to process. Multiple DELAY commands can be used to create longer delays
- Syntax
DELAY <time>
- Parameters
time – Time to pause in milliseconds \(\in [1, 10^5]\)
- Example
DELAY 5000 REM I just waited 5 seconds!
DEFAULTDELAY & DEFAULT_DELAY
- class pparser.commands.DEFAULTDELAY(arg, pparser)[source]
DEFAULTDELAY or DEFAULT_DELAY is used to define how long to wait between each subsequent command. Command must be issued at the beginning of the ducky script and is optional. Not specifying the command will result in faster execution of ducky scripts. This command is mostly useful when debugging.
DELAY
command will override this delay- Syntax
DEFAULTDELAY <time>
DEFAULT_DELAY <time>
- Parameters
time – Time to pause in milliseconds \(\in [1, 10^5]\)
- Example
DEFAULTDELAY 500 STRING Super text STRING Another super text DELAY 300 STRING Text after delay REM The total pause is 1.8 seconds
REPEAT
- class pparser.commands.REPEAT(arg, pparser)[source]
Repeats the last N commands several times
- Syntax
REPEAT <num> <amount?>
- Parameters
num – Number of repetitions
amount – Amount of commands to repeat, defaults to 1
- Example
DELAY 200 DELAY 500 REPEAT 5 2 REM The total pause is 4.2 seconds
Note
Command cannot be called if the declared amount of commands to repeat is greater than the number of commands already processed
Command cannot repeat several types of commands:
REM
,DEFAULTDELAY
,DEFAULT_DELAY
,REPEAT
Delay will not be called per repeat if the
DEFAULTDELAY
orDEFAULT_DELAY
was called at the beginning of the file
STRING
- class pparser.commands.STRING(arg, pparser)[source]
Processes the text in two modes (you can choose one)
Alt (each character is entered as an Alt code)
non-Alt (entered as a normal keystroke, only characters which supported on a specific keyboard layout
- Syntax
STRING <string>
- Parameters
string – Text to print
- Example
STRING Hello World! STRING Another text :)
STRINGDELAY & STRING_DELAY
- class pparser.commands.STRINGDELAY(arg, pparser)[source]
Processes the text in two modes (you can choose one) with a certain speed characters typing
Alt (each character is entered as an Alt code)
non-Alt (entered as a normal keystroke, only characters which supported on a specific keyboard layout
- Syntax
STRINGDELAY <time> <string>
STRING_DELAY <time> <string>
- Parameters
time – Time to pause per character in milliseconds \(\in [1, 10^5]\)
string – Text to print
- Example
STRINGDELAY 200 Hello World! STRING_DELAY 300 Another text REM These commands takes 6 seconds!
Single Key
- class pparser.commands.SingleKey(arg, pparser)[source]
Emulates one special key by one-time pressing. The list of available keys and their description are below
- Syntax
<key>
- Parameters
key – Key to emulate
- Example
STRING Hello World! HOME REM I moved to the beginning of the line!
Key
Description
MENU or APP
Emulates the App key, sometimes referred to as the menu key or context menu key. On Windows systems this is similar to the SHIFT F10 key combo, producing the menu similar to a right-click
DOWNARROW or DOWN
Emulates down arrow key
UPARROW or UP
Emulates down arrow key
LEFTARROW or LEFT
Emulates left arrow key
RIGHTARROW or RIGHT
Emulates right arrow key
DELETE
Emulates delete key
END
Emulates end key
HOME
Emulates home key
INSERT
Emulates insert key
PAGEUP
Emulates page up key
PAGEDOWN
Emulated page down key
PRINTSCREEN or PRINTSCRN or PRNTSCRN or PRTSCN or PRSC or PRTSCR
Emulates PrtSc (Print Screen) key, which typically takes screenshots
BREAK or PAUSE
Emulates Pause/Break key
NUMLOCK
Toggle numlock
CAPSLOCK
Toggle capslock
SCROLLLOCK
Toggle scroll lock
ESC or ESCAPE
Emulates esc key
SPACE
Emulates spacebar
TAB
Emulates tab key
BACKSPACE or BKSP
Emulates backspace key. On MacOS this is the delete key
ENTER
Emulates enter key
F1
Emulates F1 key
F2
Emulates F2 key
F3
Emulates F3 key
F4
Emulates F4 key
F5
Emulates F5 key
F6
Emulates F6 key
F7
Emulates F7 key
F8
Emulates F8 key
F9
Emulates F9 key
F10
Emulates F10 key
F11
Emulates F11 key
F12
Emulates F12 key
F13
Emulates F13 key
F14
Emulates F14 key
F15
Emulates F15 key
F16
Emulates F16 key
F17
Emulates F17 key
F18
Emulates F18 key
F19
Emulates F19 key
F20
Emulates F20 key
F21
Emulates F21 key
F22
Emulates F22 key
F23
Emulates F23 key
F24
Emulates F24 key
Combo Key
- class pparser.commands.ComboKey(arg, pparser)[source]
Emulates key sequences by holding down each key at the same time. The list of available combo keys and their description are below
- Syntax
<key1> <key2?> <key3>
- Parameters
key1 – Main combo key, beginning of the sequence
key2 – Optional second combo key, must not match the first one
key3 –
SingleKey
or ASCII lowercase character (a-z)
- Example
CONTROL ALT DELETE REM Opens auxiliary window
Key
Description
WINDOWS or WIN or GUI or COMMAND or CMD or META
Emulates the Windows-Key, sometimes referred to as the Super-key
SHIFT
Emulates SHIFT key, which can be used when navigating fields to select text, among other functions
ALT
Emulates ALT key, which can be used for many functions, such as navigating among windows
CONTROL or CTRL
Emulates CONTROL key for very popular combinations: saving a file, undoing the last action, etc.