There is no natural way to do this cleanly.
But you can use VBS to simulate keystrokes if you want something similar to AutoIT, but itβs not flexible anywhere. On the plus side, you do not need to download VBS. It has been included in every version of Windows since 95.
I include an example that runs notepad.exe , then enters 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"
Please note that if one or more notepad.exe instances notepad.exe already open, and it takes more than 5 seconds to open the notebook, the above code can select the last active notebook instance and enter it.
To get the VBS code to work the way you want, you need to learn how to navigate Adobe Air from the keyboard. Usually enough tabs and / or arrow keys are enough. Sometimes you may need the ALT key to go to the menu.
In addition, you can really use a number of keyboard commands, such as ALT + F S ENTER , or even a keyboard shortcut, such as 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
James k
source share