Keyboard Arduino Leonardo键盘命令
当使用Arduino作为键盘按下主板上的按钮时,我希望在Windows7中访问cmd:Keyboard Arduino Leonardo键盘命令,keyboard,arduino,Keyboard,Arduino,当使用Arduino作为键盘按下主板上的按钮时,我希望在Windows7中访问cmd: const int buttonPin = 2; const int ledPin = 13; int buttonState = 0; char ctrlKey = KEY_LEFT_GUI; void setup() { // Initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // Initialize the p
const int buttonPin = 2;
const int ledPin = 13;
int buttonState = 0;
char ctrlKey = KEY_LEFT_GUI;
void setup() {
// Initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// Initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// Read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
delay(1000);
Keyboard.press(ctrlKey);
Keyboard.press('r'); // This call runs
Keyboard.println("cmd"); // But here it won't write "cmd"
Keyboard.press('10');
Keyboard.releaseAll();
delay(1000);
}
else
{
digitalWrite(ledPin, LOW);
}
}
我还尝试了分别书写、打印和按每个字母的方法,但都失败了。大多数情况下,它会最小化所有程序或邀请所有固定在windows工具栏中的程序
问题出在哪里?您的代码按下Super、Super、Super、Super,然后按下Super和一些空键。在尝试填充文本框之前,您需要先释放Super,填充完文本框后,您需要按Enter键,而不是按那个奇怪的键。Ahaaa,这就是重点。关于enter,我找不到enter的arduino键盘修饰符。“\n”,或\n作为字符串的一部分。我在键盘类中遇到打印方法问题。我有Keyboard.printecho 0.0.0.0 websitename.com>>%WINDIR%\\system32\\drivers\\etc\\hosts;结果是echo 0.0.0.0 websitename.com::%WINDIR%zszstem32zdriverszetczhosts,但我想打印echo 0.0.0.0 websitename.com>>%WINDIR%\system32\drivers\etc\hosts