There is no native way to do this cleanly.
But you can use VBS
to simulate keystrokes if you want, something similar to AutoIT, but nowhere as flexible. On the Plus side of things, you don't need to download VBS. It's been included in every version of Windows since 95.
I am including an example that launches notepad.exe
, then types the following into it:
Hello World!
abcDEF
.
The following single line is called LaunchNotepad.bat
:
cscript /nologo LaunchNotepad.vbs
.
The following is the contents of LaunchNotepad.vbs
:
' Create WScript Shell Object to access filesystem.
Set WshShell = WScript.CreateObject("WScript.Shell")
' Start / Run NOTEPAD.EXE
WshShell.Run "%windir%\notepad.exe"
' Select, or bring Focus to a window named `NOTEPAD`
WshShell.AppActivate "Notepad"
' Wait for 5 seconds
WScript.Sleep 5000
WshShell.SendKeys "Hello World!"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "abc"
WshShell.SendKeys "{CAPSLOCK}"
WshShell.SendKeys "def"
Note that if there is one or more instances of Notepad.exe
already open, and it takes more than 5 seconds to open notepad, the above code may select the the last active instance of notepad and type into that.
To get the VBS
code to work how you want, you'll need to learn how to navigate around Adobe Air by keyboard. Usually either tabs and/or arrow-keys will suffice. Sometimes you may need to use the ALT key to move into the menus.
Also, you might actually be able to use a series of keyboard commands like ALT+FSENTER, or even a keyboard shortcut like CTRL+S.
To send TAB, ALT+F, and CTRL+S :
WshShell.SendKeys "{TAB}" ' TAB TAB Key
WshShell.SendKeys "%F" ' ALT-F (F)ile Menu
WshShell.SendKeys "^S" ' CTRL-S Save File
WshShell.SendKeys "%(Fa){ENTER}" ' ALT-F+ALT-A ENTER (F)ile -> Save (A)s -> (ENTER)
WshShell.SendKeys "{UP}" ' Up Arrow Up Arrow
WshShell.SendKeys "{DOWN}" ' Down Arrow Down Arrow
WshShell.SendKeys "{LEFT}" ' Left Arrow Left Arrow
WshShell.SendKeys "{RIGHT}" ' Right Arrow Right Arrow