Consider a state-machine approach. I don't see your entire code so this may not do what you want (as well, I only compiled it, didn't test it...)
Give it a try.
#include <Keyboard.h>
#define ST_INIT 0
#define ST_INIT_DELAY 1
#define ST_RELEASE_DELAY 2
#define ST_NOTEPAD_DELAY 3
#define ST_RELEASE_2_DELAY 4
#define ST_HELLOWORLD_DELAY 5
#define ST_END 6
const byte pinLED = LED_BUILTIN;
void setup()
{
Keyboard.begin();
pinMode( pinLED, OUTPUT );
digitalWrite( pinLED, LOW );
}//setup
void loop()
{
Keyboard_StateMachine();
}//loop
void Keyboard_StateMachine( void )
{
static bool
bLEDFlag = false;
static byte
stateKSM = ST_INIT;
static unsigned long
timeKSM;
unsigned long
timeNow;
timeNow = millis();
switch( stateKSM )
{
case ST_INIT:
timeKSM = timeNow;
stateKSM = ST_INIT_DELAY;
break;
case ST_INIT_DELAY:
if( timeNow - timeKSM >= 10000U )
{
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r');
timeKSM = timeNow;
stateKSM = ST_RELEASE_DELAY;
}//if
break;
case ST_RELEASE_DELAY:
if( timeNow - timeKSM >= 100U )
{
Keyboard.releaseAll();
timeKSM = timeNow;
stateKSM = ST_NOTEPAD_DELAY;
}//if
break;
case ST_NOTEPAD_DELAY:
if( timeNow - timeKSM >= 500U )
{
Keyboard.print("notepad.exe");
Keyboard.press(KEY_RETURN);
timeKSM = timeNow;
stateKSM = ST_RELEASE_2_DELAY;
}//if
break;
case ST_RELEASE_2_DELAY:
if( timeNow - timeKSM >= 100U )
{
Keyboard.releaseAll();
timeKSM = timeNow;
stateKSM = ST_HELLOWORLD_DELAY;
}//if
case ST_HELLOWORLD_DELAY:
if( timeNow - timeKSM >= 2000U )
{
Keyboard.print("Hello World");
Keyboard.press(KEY_RETURN);
timeKSM = timeNow;
stateKSM = ST_END;
}//if
break;
case ST_END:
//at the end of the SM just blink the built-in LED
if( timeNow - timeKSM >= 250u );
{
bLEDFlag ^= true;
digitalWrite( LED_BUILTIN, (bLEDFlag ? HIGH:LOW) );
timeKSM = timeNow;
}//if
break;
}//switch
}//Keyboard_StateMachine