Home ArduinoRubber Duck Open Youtube on a PC using a Leonardo

Open Youtube on a PC using a Leonardo

This example will attempt to open a video on Youtube on your PC, its basically another example that shows how to use an Arduino Leonardo to send keystrokes to a PC, interesting for testing and possible automation. Also could be used to seriously p**s someone off if this was attached to their PC

Rubber Duck Script

For those that are interested

[codesyntax lang=”cpp”]

DELAY 3000
GUI r
DELAY 200
STRING https://www.youtube.com/watch?v=IUDHg1Tg27M
ENTER
DELAY 3000
STRING f

[/codesyntax]

You can use the tool at https://thehacktoday.com/ducky/ to convert it to Arduino code which is below

Arduino Code

Upload to your Arduino Leonardo or equivalent, plug in and a web browser should open with the url to the Youtube video

[codesyntax lang=”cpp”]

#include "Keyboard.h"

void typeKey(uint8_t key)
{
  Keyboard.press(key);
  delay(50);
  Keyboard.release(key);
}

/* Init function */
void setup()
{
  // Begining the Keyboard stream
  Keyboard.begin();

  // Wait 500ms
  delay(500);

  delay(3000);

  Keyboard.press(KEY_LEFT_GUI);
  Keyboard.press('r');
  Keyboard.releaseAll();

  delay(200);

  Keyboard.print("https://www.youtube.com/watch?v=IUDHg1Tg27M");

  typeKey(KEY_RETURN);

  delay(3000);

  Keyboard.print("f");

  // Ending stream
  Keyboard.end();
}

/* Unused endless loop */
void loop() {}

[/codesyntax]

You may also like