I have problem with buttons when coding teensy 2.0++.
Could you hint me how to press two buttons <Alt>+<Shift>
simultaneously?
Exactly saying my problem is: this code
uint8_t key, modifier=0;
void setup()
{
delay(15000);
Keyboard.begin();
// switch_on_lat();
run("cmd");
delay(2000);
// switch_on_lat();
Keyboard.print("echo Hello!");
delay(1000);
Press_Enter();
delay(5000);
Keyboard.print("exit");
delay(1000);
Press_Enter();
}
void loop()
{
}
void switch_on_lat()
{
// modifier |= MODIFIERKEY_LEFT_SHIFT;
// modifier |= MODIFIERKEY_LEFT_ALT;
// Keyboard.set_modifier(MODIFIERKEY_LEFT_ALT);
Keyboard.set_key2(MODIFIERKEY_LEFT_ALT);
// Keyboard.send_now();
// Keyboard.press(KEY_LEFT_ALT);
// delay(1500);
Keyboard.set_key1(MODIFIERKEY_LEFT_SHIFT);
Keyboard.send_now();
// Keyboard.press(modifier);
delay(2500);
// Keyboard.set_modifier(0);
// Keyboard.send_now();
// Keyboard.releaseAll();
Keyboard.set_key2(0);
Keyboard.set_key1(0);
Keyboard.send_now();
// delay(1000);
}
void run(char *SomeCommand){
Keyboard.set_modifier(MODIFIERKEY_RIGHT_GUI);
// simulate pressing of button <Windows>
Keyboard.set_key1(KEY_R);
// simulate pressing of button <R>
Keyboard.send_now();
// Send combination <Windows>+<R>, which opens window "exec"
delay(1500);
Keyboard.set_modifier(0);
// simulate releasing of button <Windows>
Keyboard.set_key1(0);
// simulate releasing of button <R>
Keyboard.send_now();
// release combination <Windows>+<R>
Keyboard.print(SomeCommand);
// enter an argument into window "exec"
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now(); // press <Enter>
Keyboard.set_key1(0);
Keyboard.send_now(); // release <Enter>
// Press_Enter();
}
void Press_Enter()
{
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now();
Keyboard.set_key1(0);
Keyboard.send_now();
}
works good under Windows-7 if the default input langauge
is English. Else it doesn't work!
For switching keyboard's layout I am trying to simulate pressing
of <Alt>+<Shift> by different ways but unsuccessfully!
The most simple construction
Keyboard.set_modifier(MODIFIERKEY_LEFT_ALT);
Keyboard.set_key1(MODIFIERKEY_LEFT_SHIFT);
Keyboard.send_now();
delay(1500);
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
does not work and I can not understand why. Who knows please help.
Thanks.
Could you hint me how to press two buttons <Alt>+<Shift>
simultaneously?
Exactly saying my problem is: this code
uint8_t key, modifier=0;
void setup()
{
delay(15000);
Keyboard.begin();
// switch_on_lat();
run("cmd");
delay(2000);
// switch_on_lat();
Keyboard.print("echo Hello!");
delay(1000);
Press_Enter();
delay(5000);
Keyboard.print("exit");
delay(1000);
Press_Enter();
}
void loop()
{
}
void switch_on_lat()
{
// modifier |= MODIFIERKEY_LEFT_SHIFT;
// modifier |= MODIFIERKEY_LEFT_ALT;
// Keyboard.set_modifier(MODIFIERKEY_LEFT_ALT);
Keyboard.set_key2(MODIFIERKEY_LEFT_ALT);
// Keyboard.send_now();
// Keyboard.press(KEY_LEFT_ALT);
// delay(1500);
Keyboard.set_key1(MODIFIERKEY_LEFT_SHIFT);
Keyboard.send_now();
// Keyboard.press(modifier);
delay(2500);
// Keyboard.set_modifier(0);
// Keyboard.send_now();
// Keyboard.releaseAll();
Keyboard.set_key2(0);
Keyboard.set_key1(0);
Keyboard.send_now();
// delay(1000);
}
void run(char *SomeCommand){
Keyboard.set_modifier(MODIFIERKEY_RIGHT_GUI);
// simulate pressing of button <Windows>
Keyboard.set_key1(KEY_R);
// simulate pressing of button <R>
Keyboard.send_now();
// Send combination <Windows>+<R>, which opens window "exec"
delay(1500);
Keyboard.set_modifier(0);
// simulate releasing of button <Windows>
Keyboard.set_key1(0);
// simulate releasing of button <R>
Keyboard.send_now();
// release combination <Windows>+<R>
Keyboard.print(SomeCommand);
// enter an argument into window "exec"
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now(); // press <Enter>
Keyboard.set_key1(0);
Keyboard.send_now(); // release <Enter>
// Press_Enter();
}
void Press_Enter()
{
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now();
Keyboard.set_key1(0);
Keyboard.send_now();
}
works good under Windows-7 if the default input langauge
is English. Else it doesn't work!
For switching keyboard's layout I am trying to simulate pressing
of <Alt>+<Shift> by different ways but unsuccessfully!
The most simple construction
Keyboard.set_modifier(MODIFIERKEY_LEFT_ALT);
Keyboard.set_key1(MODIFIERKEY_LEFT_SHIFT);
Keyboard.send_now();
delay(1500);
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
does not work and I can not understand why. Who knows please help.
Thanks.