Author Topic: N00b questions about keyboard library  (Read 30504 times)

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: N00b questions about keyboard library
« Reply #15 on: March 28, 2013, 08:07:51 pm »
@forsakenrider: Currently the way you're doing it with three lines is the best way to do it. DigiKeyboard (like DigiUSB) inherits it's print, println, and write functionality from the official arduino Serial library, so you can check out the docs for those functions over on the arduino reference site. As I mentioned earlier, sprintf functionality (template strings which substitute values in) are complex to implement and use a lot of memory, which is why the arduino software doesn't make use of them.

forsakenrider

  • Newbie
  • *
  • Posts: 26
Re: N00b questions about keyboard library
« Reply #16 on: March 28, 2013, 08:11:33 pm »
Thanks for more info. That was basically the conclusion I had found with google, but no where did I find it said like that.

I saved a lot of memory, about 1000 bytes, by removing the sprintf!

buzzy456

  • Newbie
  • *
  • Posts: 1
Re: N00b questions about keyboard library
« Reply #17 on: January 22, 2016, 02:06:12 am »
Basically, I want to make it lock the icons, print screen, save, set as background a thats it. heres the code so far. missing the lock icons because no menu.

when it goes to paste the printscreen it doesnt get pasted, its like MSPAINT isnt the program in view. how do I fix that?

Code: [Select]
#include "DigiKeyboard.h"

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


void loop() {
 
  DigiKeyboard.update();
  DigiKeyboard.sendKeyStroke(0);
  DigiKeyboard.delay(5000);
  DigiKeyboard.sendKeyStroke(KEY_D, MOD_GUI_LEFT); //minimize all windows
  DigiKeyboard.delay(100);
  DigiKeyboard.sendKeyStroke(KEY_PrintScreen); //prntscr
  DigiKeyboard.delay(100); 
  DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
  DigiKeyboard.delay(100);
  DigiKeyboard.println("mspaint");
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.delay(1200);
  DigiKeyboard.sendKeyStroke(KEY_V, MOD_CONTROL_RIGHT);
  digitalWrite(1, HIGH);
  DigiKeyboard.delay(500);
  digitalWrite(1, LOW);
  DigiKeyboard.delay(500);
 
}

why did you add the DigiKeyboard.sendKeyStroke(0);?
 was that beacuse digispark was skipping your first line of keystroke code
because mine just skipped the first line and went to the secon one so i put that in, is that the same for you?