How to click a button using a batch file?

I need to click the save button in an Adobe Air app called Arthropods. I can run the application in the bat file with this:

cd C:\Program Files\Arthropod start /w Arthropod.exe 

As soon as it appears, there is a save button in the user interface. How can I click it with a bat file?

I read this:

http://www.ehow.com/how_7788761_press-buttons-batch-file.html

which showed how to simulate clicks in the file menu and other tabs in MS Word, but how to do it on any other button?

PS text on the β€œSave” button, which is the only unique identifier that I can come up with for this button. Is there something batch where I can say something like (pseudocode):

 $('button[text="Save"]').click(); 
+7
source share
4 answers

You can use AutoIt for this. You can create a script that clicks on the "Save" button and calls the generated EXE file from the batch file.

+3
source

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 
+10
source

You cannot automate button clicks with the bat file. If that were possible, you would still need some kind of API for Adobe Air to access the controls themselves. But if there is a shortcut key to this button, you can simulate a keystroke and send it to the application.

0
source

Winbatch is another program that can send keystrokes, but unlike AutoIt, I don't think it's free.

0
source

All Articles