Author Topic: Digispark prank keyboard driver  (Read 40007 times)

handsomejackuk

  • Newbie
  • *
  • Posts: 5
Re: Digispark prank keyboard driver
« Reply #15 on: January 05, 2016, 05:42:18 pm »
bump this for reference

gabe

  • Newbie
  • *
  • Posts: 3
Re: Digispark prank keyboard driver
« Reply #16 on: March 29, 2016, 03:15:41 am »
Heres a fun one, try it on a windows computer!

Code: [Select]
//Wallpaper Prank, modified by DW for use on the digispark

#include "DigiKeyboard.h"



void setup() {
  pinMode(1, OUTPUT); //LED on Model A
 
 
}


void loop() {
 
 
  DigiKeyboard.update();
  DigiKeyboard.sendKeyStroke(0);
  DigiKeyboard.delay(3000);
  DigiKeyboard.sendKeyStroke(KEY_M, MOD_GUI_LEFT); //minimize all windows
  DigiKeyboard.delay(1000);
  DigiKeyboard.sendKeyStroke(KEY_PrintScreen); //prntscr
  DigiKeyboard.delay(50);
  DigiKeyboard.sendKeyStroke(KEY_F10, MOD_SHIFT_LEFT); //Open Menu
  DigiKeyboard.delay(200);
  DigiKeyboard.sendKeyStroke(KEY_V);
  DigiKeyboard.delay(50);
  DigiKeyboard.sendKeyStroke(KEY_D);
  DigiKeyboard.delay(500); 
  DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT); //run
  DigiKeyboard.delay(100);
  DigiKeyboard.println("mspaint");
  DigiKeyboard.delay(1200);
  DigiKeyboard.sendKeyStroke(KEY_V, MOD_CONTROL_LEFT); //paste
  DigiKeyboard.delay(500); 
  DigiKeyboard.sendKeyStroke(KEY_S, MOD_CONTROL_LEFT); //save
  DigiKeyboard.delay(500); 
  DigiKeyboard.println("%userprofile%\\a.bmp"); //save in users folder
  DigiKeyboard.delay(500);
  DigiKeyboard.sendKeyStroke(KEY_F, MOD_ALT_LEFT); //file
  DigiKeyboard.delay(500);
  DigiKeyboard.sendKeyStroke(KEY_K); //set as desktop
  DigiKeyboard.delay(100); 
  DigiKeyboard.sendKeyStroke(KEY_T); //tile
  DigiKeyboard.delay(1000);
  DigiKeyboard.sendKeyStroke(KEY_F4, MOD_ALT_LEFT); //close paint
  DigiKeyboard.delay(300);
  DigiKeyboard.sendKeyStroke(KEY_M, MOD_GUI_LEFT | MOD_SHIFT_LEFT); //back to desktop as it was
 
  digitalWrite(1, HIGH); //turn on led when program finishes
  DigiKeyboard.delay(90000);
  digitalWrite(1, LOW);
  DigiKeyboard.delay(5000);
 
}

I have to add a define for "KEY_PrintScreen". What is the code for it and how can I get it?

Leprechaun

  • Newbie
  • *
  • Posts: 2
Re: Digispark prank keyboard driver
« Reply #17 on: April 28, 2016, 03:12:19 am »
Hello. Please tell me, how do I pass codes Androyd buttons? Examples: KEYCODE_HOME, KEYCODE_MEDIA_PLAY, KEYCODE_MEDIA_STOP, KEYCODE_NAVIGATE_IN? What should I add to DigiKeyboard.h? How to bring in DigiKeyboard.sendKeyStroke (); ? Please forgive me if you misspelled. My English is bad. Translated using translate.google.

Leprechaun

  • Newbie
  • *
  • Posts: 2
Re: Digispark prank keyboard driver
« Reply #18 on: May 02, 2016, 11:39:40 am »
Forum dead ? My question too complex? Prefer not to say beginners ?  :(

Fardenco

  • Newbie
  • *
  • Posts: 8
Re: Digispark prank keyboard driver
« Reply #19 on: February 18, 2017, 05:58:54 pm »
I know it's a quite old thread but hopefully this will help anyone still looking for an answer.

the scan code for printscreen is 70, as you can see in the pictures on this thread
https://digistump.com/board/index.php/topic,2289.0.html

for media keys, the only solution I've found is to use Adafruit's TrinketHidCombo library
https://github.com/adafruit/Adafruit-Trinket-USB/tree/master/TrinketHidCombo

An example here to make a volume knob
https://learn.adafruit.com/trinket-usb-volume-knob/code

Bark3rR

  • Newbie
  • *
  • Posts: 1
Re: Digispark prank keyboard driver
« Reply #20 on: May 31, 2017, 06:58:18 pm »
i want to be able to open spotlight search at the beginning of my code, just making sure this is right

DigiKeyboard.sendKeyStroke(0, MOD_GUI_LEFT | KEY_SPACE);

thx.

LionRelaxe

  • Newbie
  • *
  • Posts: 1
Re: Digispark prank keyboard driver
« Reply #21 on: March 26, 2018, 12:12:07 pm »
Hello,

I needed a variation of the prank, to fool the mouse instead of the keyboard.
Here is a VERY loosely adapted code mashed from two sources:
http://www.instructables.com/id/Mouse-Prank-with-Arduino/
and from the "DigiMouse" example.

This will move the mouse in a step, each 5 to 60 seconds.
Good luck!

Code: [Select]
// DigiMouse test and usage documentation
// CAUTION!!!! This does click things!!!!!!!!
// Originally created by Sean Murphy (duckythescientist)

#include <DigiMouse.h>


int delayLevel = 5; //set the range of time between action, set to 1-10
int range = 5;              // output range of X or Y movement; affects movement speed
//variables for beep
long freq = 4000; //set beep frequency
long period;
long aSecond = 1000000;
int piezo = 12;

void setup() {
  DigiMouse.delay(2000);
  DigiMouse.begin(); //start or reenumerate USB - BREAKING CHANGE from old versions that didn't require this
  DigiMouse.delay(2000);
}

void loop() {
  // If not using plentiful DigiMouse.delay(), make sure to call
  // DigiMouse.update() at least every 50ms
 
  // move across the screen
  // these are signed chars
/* 
  DigiMouse.moveY(10); //down 10
  DigiMouse.delay(500);
  DigiMouse.moveX(20); //right 20
  DigiMouse.delay(500);
  DigiMouse.scroll(5);
  DigiMouse.delay(500);
 
  // or DigiMouse.move(X, Y, scroll) works
 
  // three buttons are the three LSBs of an unsigned char
  DigiMouse.setButtons(1<<0); //left click
  DigiMouse.delay(500);
  DigiMouse.setButtons(0); //unclick all
  DigiMouse.delay(500);

  //or you can use these functions to click
  DigiMouse.rightClick();
  DigiMouse.delay(500);
  DigiMouse.leftClick();
  DigiMouse.delay(500);
  DigiMouse.middleClick();
  DigiMouse.delay(500);

  //for compatability with other libraries you can also use DigiMouse.move(X, Y, scroll, buttons)
  */
 
  //========================================
  //Jump with variable delay

  unsigned long randomDelay = random(5,60); //generate random number for delay
  //unsigned long thisDelay = randomDelay * long (delayLevel) * 1000;
  //Serial.println (thisDelay);
  //unsigned long next = long (millis()) + thisDelay;
  unsigned long next =  (millis() + randomDelay*1000);
  while ((millis() < next) && (millis() > 200)){
      DigiMouse.delay (100);
  }
  //call Jump
  int distanceX = random(100,500); //set jump distance, direction is set in function
  int distanceY = random(100,500); //set jump distance, direction is set in function
  DigiMouse.moveX (distanceX); // modify with math for different results
  DigiMouse.update();
  DigiMouse.moveY (distanceY); // modify with math for different results
  DigiMouse.update();
  DigiMouse.delay (10);
  //jump (distance);  //uncomment this to use jump without beep
  //jumpBeep (distance);  //uncomment this to use jump with a beep


/*
//===========================
  //Jitter with fixed delay
 
  jitter (12);
  delay (60000);
  */
  //===========================
  //Jitter with variable delay
 /*
  long randomDelay = random(30,60); //generate random number for delay
  long thisDelay = randomDelay * long (delayLevel) * 1000;
  Serial.println (thisDelay);
  long next = long (millis()) + thisDelay;
  while (millis() < next){
    //wait
  }
  //call Jitter
  jitter (12); //call jitter function with number of repeats/duration
 */
 
//============================
 
  //Jump with fixed delay
 
  /*
  jump (-150);
  delay (125000);
  */

}


//===============subs=============

void jump(int howFar){
 
  DigiMouse.moveX (howFar); // modify with math for different results
  DigiMouse.delay (2);
}
 
 
void jumpBeep (int howFar) {
  //beep
  period = aSecond/freq;
  for(long k = 0; k < freq/10; k++){
    digitalWrite(piezo,HIGH);
    delayMicroseconds(period/2);
    digitalWrite(piezo,LOW);
    delayMicroseconds(period/2);
  }
   //move
  DigiMouse.moveX (howFar); // modify with math for different results
  DigiMouse.moveY (howFar); // modify with math for different results
  DigiMouse.delay (2);
  }

void jitter (int duration){
  int i = 0;
  while (i < duration){
    DigiMouse.moveX(10);
    DigiMouse.moveY(10);
    DigiMouse.delay (15);
    DigiMouse.moveX(-11);
    DigiMouse.delay (20);
    DigiMouse.moveX(10);
    DigiMouse.moveY(-10);
    DigiMouse.delay(25);
    DigiMouse.moveX(-11);
    DigiMouse.moveY(0);
    DigiMouse.delay (20);
    i++;
  }
}