Date of publication: 20.05.2024
Script to shut down or restart a Windows-based computer after a specified time (countdown timer).
#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);
delay(3000);
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r');
Keyboard.releaseAll();
delay(200);
Keyboard.print("cmd");
typeKey(KEY_RETURN);
delay(200);
Keyboard.print("shutdown -s -f -t 3600 -c \"Some text\"");
// 3600 - 1 Hour, for cancel use command shutdown -a
// for reboot change -s on -r
delay(200);
typeKey(KEY_RETURN);
Keyboard.print("exit");
typeKey(KEY_RETURN);
delay(3000);
// Ending stream
Keyboard.end();
}
/* Unused endless loop */
void loop() {}
No Comments Yet