Wait for a key in a Dos box

The wait for a key in a Dos box needs a trick in order to work. An example is given below :

Shell("Notepad.exe")

'Use Shell to launch an application

Shell("C:\WINDOWS\Command.com",1)

UseWindow("WINOA386.MOD|ttyGrab|Commandes MS-DOS|1")

'Here all the sendkeys you want in the Dos box

sendkeys("<enter>")

pause 5 ticks

sendkeys("Dir <enter>")

 

'Wait for F12 ; a wait for a key in a Dos box works only if

' the Dos box has not the focus

'So, as a trick, we generate a new UseWindow on a Window present on the desktop

'The Dos box has not the focus but the user still sees it

UseWindow("EXPLORER.EXE|Button")
Pause until

Key("<F12>")

PauseFalse

MsgBox("'Wait for' at line " + #ErrorLine$ + " has failed !",16,"Runtime error")

End

EndPause

 

'switch to Notepad

UseWindow("NOTEPAD.EXE|Edit|Untitled - NotePad|1",1)

sendkeys("hello")