Arduino / C++ / USB HID

DuckyScript Interpreter

An Arduino library that allows DuckyScript-style commands to be written directly inside an Arduino sketch using a C++ raw string.

Role: Designer and developer Status: In development Tools: Arduino, C++, USB HID

The idea

I wanted Arduino users to be able to write simple keyboard automation scripts without manually converting every command into Keyboard library calls.

How it works

The library accepts a multiline raw string, separates it into individual lines, identifies each command, parses its argument, and executes the corresponding Arduino function.

DStoArduino(R"DS(
DELAY 1000
GUI r
STRING notepad
ENTER
STRING Hello World
)DS");

Interpreter pipeline

  1. Receive the raw string.
  2. Read one line at a time.
  3. Separate command from argument.
  4. Validate the command.
  5. Execute the Arduino equivalent.

Challenges

Important design problems include limited Arduino memory, keyboard layouts, line-length limits, error reporting, modifier combinations, and safely stopping a running script.

What I learned

This project introduced me to interpreters, parsing, string processing, USB HID behavior, library design, and the differences between desktop C++ and microcontroller programming.