-1

我正在尝试使用键盘功能通过键盘打印字符串,在这种情况下,我正在尝试打印以下语句。

CODE
____
Keyboard.begin()
Keyboard.print("echo \"-----BEGIN CERTIFICATE-----\" >> text.txt"); //--> Arduino  
delay(200)
Keyboard.print(KEY_RETURN);
Keyboard.end();

output
______
echo @-----END CERTIFICATE-----@ >> text.txt

Desired output
______________

echo "-----BEGIN CERTIFICATE-----" >> text.txt 

谁能帮我这个!!!下面是示例代码

 
#include <Keyboard.h>
void setup() 
{
    Keyboard.begin();
    delay(5000);
// Minimize all windows
    Keyboard.press(KEY_LEFT_GUI);
    Keyboard.press('d');
    Keyboard.releaseAll();
    delay(50);
// run task
    Keyboard.press(KEY_LEFT_GUI);
    Keyboard.press('r');
    Keyboard.releaseAll();
    delay(100);
    Keyboard.print("PowerShell -NoLogo");
    delay(100);
    Keyboard.write(KEY_RETURN);
    delay(100);
//-------------------- the above code works fine ---------------------

// save file 
    Keyboard.print("echo \"-----BEGIN CERTIFICATE-----\" >> text.txt");//---> this line
    delay(50);
    Keyboard.write(KEY_RETURN);
    delay(500);
    Keyboard.end();
}
4

1 回答 1

2

Arduino 的键盘库使用美国布局。因此,如果您发送双引号,在您的键盘布局中是shift+2这将导致 a@这将是美国布局的输出。

我不知道您使用的是哪种布局,所以我无法告诉您要发送什么字符。

或者使用keyboard.write("\"");

于 2021-11-16T15:03:08.267 回答