0

Is it possible with a batch file to open a file then execute or "click" an option in the opened application "File" menu with just one .bat file?

So for example normally I would double-click the Firefox shortcut on my desktop then click on "File" > "New Tab".

Is it possible to do that with a single .bat file?

Shiasu-sama
  • 1,179
  • 2
  • 12
  • 39

1 Answers1

1

You can use the CursorPos.exe by @Aacini to move the cursor. Here is the download link: https://www.dostips.com/forum/viewtopic.php?t=3428. In the download page, you can only download the set of .exe files. Extract CursorPos.exe from them.

Usage: CursorPos [[±]col [±]row] If no parameter is given, return current cursor position as col+(row<<16) in ERRORLEVEL. If any coordinate have sign, the position given is relative to the current one. If cursor is moved, the Ascii code of the character at new position is returned in ERRORLEVEL.

And for mouse input you can use batbox.exe. Download link: https://batchprogrammers.blogspot.com/2016/06/batbox-awesome-batch-plugin-by.html?m=1. The full information is available there.

Wasif
  • 14,755
  • 3
  • 14
  • 34
  • I've done some more research and found out about ".SendKeys". Would it be easier to maybe to use ".SendKeys" somehow to do "Alt+F" to open the File Context Menu then "Down Arrow" to select an option then "Enter" to execute it? – Shiasu-sama Nov 20 '19 at 19:58
  • No it will be much harder than you think. You will need more complex scripts and the error chance will be more. So I suggest you to use these tools to make menu. – Wasif Nov 21 '19 at 07:18
  • I'm very new to batch files and batch commands. Can you maybe post an simple example of using CursorPos.exe and batbox.exe? Thanks for the feedback. – Shiasu-sama Nov 21 '19 at 09:16
  • My browser is saying: "We can’t connect to the server at www.dos9.org". I am unable to download batbox.exe :( – Shiasu-sama Nov 21 '19 at 09:29
  • Sorry for the unavailable link. I am giving a new link in its place. – Wasif Nov 21 '19 at 16:32