该脚本在 Windows 操作系统中打开文本编辑器并打印指定的文本。
#if ARDUINO > 10605
#include <Keyboard.h>
#endif
void typeKey(uint8_t key)
{
Keyboard.press(key);
delay(50);
Keyboard.release(key);
}
/* Init function */
void setup()
{
// Begining the Keyboard stream
Keyboard.begin();
//Wait 500ms
delay(500);
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r');
Keyboard.releaseAll();
delay(500);
Keyboard.print("notepad.exe");
typeKey(KEY_RETURN);
delay(1000);
Keyboard.print("This is my test text.");
// Ending stream
Keyboard.end();
}
/* Unused endless loop */
void loop() {}
暂时没有评论