element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Cheer Us Up
  • Challenges & Projects
  • Project14
  • Cheer Us Up
  • More
  • Cancel
Cheer Us Up
Blog Prank with HID device emulated by Raspberry Pi Pico
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Cheer Us Up to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: kk99
  • Date Created: 6 Apr 2021 6:58 PM Date Created
  • Views 5696 views
  • Likes 8 likes
  • Comments 2 comments
  • cheerusupch
Related
Recommended

Prank with HID device emulated by Raspberry Pi Pico

kk99
kk99
6 Apr 2021
image

Cheer Us Up

Enter Your Electronics & Design Project for a chance to win a $200 shopping cart!

Submit an EntrySubmit an Entry  Back to homepage image
Project14 Home
Monthly Themes
Monthly Theme Poll

 

The main idea was to use the Raspberry Pi Pico to emulate the keyboard and mouse to send random keys. I have used CircuitPython with additional usage of adafruit hid library. Below there is source code:

import random
import usb_hid
import time
from adafruit_hid.consumer_control import ConsumerControl
from adafruit_hid.consumer_control_code import ConsumerControlCode
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.mouse import Mouse

kbd = Keyboard(usb_hid.devices)
layout = KeyboardLayoutUS(kbd)
m = Mouse(usb_hid.devices)
cc = ConsumerControl(usb_hid.devices)

while True:
    for x in range(random.randrange(15, 50)):
        kbd.send(random.randrange(32, 127))

    m.click(Mouse.RIGHT_BUTTON)
    for x in range(random.randrange(5, 25)):
        m.move(random.randrange(-100, 100), random.randrange(-100, 100), random.randrange(-1,1))

    cc.send(ConsumerControlCode.VOLUME_INCREMENT)
    time.sleep(random.randrange(5,30))

At the beginning there is initialization of keyboard and mouse devices. In main loop at the first stage there are sent few random key press. Then there is sent right mouse button click and few moves of mouse in to random position. At the end there is increasing of system volume and waiting at random delay to next loop. Of course it is easy to find due that the device is present and listed in system as mass storage device. Below there is short video where random keys or moves are send by Raspberry Pi Pico:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

In similar way we could prank users of remote driven devices e.g. TV. In that case is required to use of IR diode connected to RPI Pico and send random key codes in one of popular standard for remote device e.g. RC-5.

  • Sign in to reply

Top Comments

  • Fred27
    Fred27 over 4 years ago +3
    Randomly toggling caps lock is probably the best way to annoy someone without them realising what's going too quickly. Ideally not too frequently at first.
  • kk99
    kk99 over 4 years ago in reply to Fred27 +1
    Nice idea. I thought about moving into deep sleep instead of normal sleep but mounting of mass storage device is seen during this process in task bar.
Parents
  • Fred27
    Fred27 over 4 years ago

    Randomly toggling caps lock is probably the best way to annoy someone without them realising what's going too quickly. Ideally not too frequently at first.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • Fred27
    Fred27 over 4 years ago

    Randomly toggling caps lock is probably the best way to annoy someone without them realising what's going too quickly. Ideally not too frequently at first.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • kk99
    kk99 over 4 years ago in reply to Fred27

    Nice idea. I thought about moving into deep sleep instead of normal sleep but mounting of mass storage device is seen during this process in task bar.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube