2

I want to open notepad by my Digispark. I use this code:

/*  * Generated with <3 by Dckuino.js, an open source project !  */

#include <avr/pgmspace.h> #include "DigiKeyboard.h"

const char line1[] PROGMEM = "notepad.exe"; const char line2[] PROGMEM = "Hello World!";

char buffer[256];

#define GetPsz(x) (strncpy_P(buffer, (char*)x, 256)) #define KEY_UP_ARROW 0x52 #define KEY_DOWN_ARROW 0x51 #define KEY_LEFT_ARROW 0x50 #define KEY_RIGHT_ARROW 0x4F #define KEY_LEFT_GUI 0xE3 #define KEY_ESC 0x29 #define KEY_TAB 0x2B

void digiBegin() { DigiKeyboard.sendKeyStroke(0,0); DigiKeyboard.delay(50); }

void digiEnd() { const int led=1; pinMode(led, OUTPUT); while (1) { digitalWrite(led, !digitalRead(led)); DigiKeyboard.delay(1000); } }

void printText(char *txt) { DigiKeyboard.print(txt); DigiKeyboard.update(); }

void setup() { digiBegin();

DigiKeyboard.sendKeyStroke(KEY_R,MOD_GUI_LEFT);

DigiKeyboard.delay(50);

// notepad.exe printText(GetPsz(line1));

DigiKeyboard.sendKeyStroke(KEY_ENTER);

DigiKeyboard.delay(100);

// Hello World! printText(GetPsz(line2));

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

My program opened RUN Windows, but instead of typing "notepad.exe" it types "fgl]hY&]p]" and I don't know where am I am making mistakes. Please help me.

I have to write my code similar this:

#include "DigiKeyboard.h"

int pinled = 1;

void setup() { pinMode(3, INPUT);

digitalWrite(3, HIGH);

}

void loop() { DigiKeyboard.sendKeyStroke(0);

if(digitalRead(3) == LOW)
{
    DigiKeyboard.sendKeyPress(KEY_R, MOD_GUI_LEFT);
    DigiKeyboard.delay(10);

    DigiKeyboard.sendKeyStroke(0, 0);

    DigiKeyboard.sendKeyStroke(KEY_C);
    DigiKeyboard.sendKeyStroke(KEY_M);
    DigiKeyboard.sendKeyStroke(KEY_D);
    DigiKeyboard.sendKeyStroke(KEY_ENTER);

    DigiKeyboard.delay(500);

    DigiKeyboard.sendKeyStroke(KEY_I);
    DigiKeyboard.sendKeyStroke(KEY_P);
    DigiKeyboard.sendKeyStroke(KEY_C);
    DigiKeyboard.sendKeyStroke(KEY_O);
    DigiKeyboard.sendKeyStroke(KEY_N);
    DigiKeyboard.sendKeyStroke(KEY_F);
    DigiKeyboard.sendKeyStroke(KEY_I);
    DigiKeyboard.sendKeyStroke(KEY_G);
    DigiKeyboard.sendKeyStroke(KEY_ENTER);
}

}

timemage
  • 5,639
  • 1
  • 14
  • 25
m7.arman
  • 21
  • 2

0 Answers0