[HELP] Batch Line Command Problem

rohan.vaddiparty

Honorable
Sep 8, 2017
23
0
10,540
Greetings Everyone,

So basically I have a software which acts on startup. Apparently on every startup of the machine, The person should click [TAB] button twice and then click [Enter]. Being in startup, You know how hard it'll be for them everyday since it works on system startup full screen with no keyboard whatsoever.

My request is,


    1 Windows 7 Starts
    2 Application starts automatically ( Startup Folder )
    3 {Here i need a batch file to execute so that it will press TAB button twice and ENTER once}


I've searched the whole internet for command lines, Haven't found anything related to my problem or the problem itself. I would be glad if someone could help me with the problem. You can reply below with a solution ( the code ).

Best Regards.
 
Solution
Hi, I've been a bit interested in AutoHotKey but haven't tried it out until today when I tried to find a solution for you. Give this a try:

Download and install AutoHotKey from here:
https://autohotkey.com/download/
I used the Installer download. It takes up about 10 MB when installed (it's tiny).

If you just run AutoHotKey by itself, it does nothing but load up a help file. It's made for scripting. You run it by creating and opening a script. So create a quick test script to see if you can get it working by doing the following:

Create a new text file on your desktop and rename it to start.ahk

Open it in notepad. Copy/paste in the following:

; Open Notepad
Run notepad.exe

; Wait for Notepad to open.
; This will wait up to 30...

gardenman

Splendid
Moderator
Hi, I've been a bit interested in AutoHotKey but haven't tried it out until today when I tried to find a solution for you. Give this a try:

Download and install AutoHotKey from here:
https://autohotkey.com/download/
I used the Installer download. It takes up about 10 MB when installed (it's tiny).

If you just run AutoHotKey by itself, it does nothing but load up a help file. It's made for scripting. You run it by creating and opening a script. So create a quick test script to see if you can get it working by doing the following:

Create a new text file on your desktop and rename it to start.ahk

Open it in notepad. Copy/paste in the following:

; Open Notepad
Run notepad.exe

; Wait for Notepad to open.
; This will wait up to 30 seconds for it to open before continuing without it.
WinWaitActive, Untitled - Notepad, , 30

; Type in some keys in Notepad.
Send abc{Tab}abc{Enter}test{Tab}123


Save it and double click on it to run it. If this script works, you will of course need to modify it for your own use. Your script could be something as simple as this:

WinWaitActive, Title Bar of Some Program, , 30
Send {Tab}{Tab}{Enter}


Then add a shortcut to the .AHK file to your start menu / startup folder. I literally just downloaded AutoHotKey 30 minutes ago and this is my first script. I'm no expert at it but if you have more questions about it I might be able to figure it out.

Another option would be PowerShell (which I'm not sure if its even installed by default on Win 7). Here's a few links for info on it:
https://stackoverflow.com/questions/17849522/how-to-perform-keystroke-inside-powershell
https://superuser.com/questions/992511/emulate-a-keyboard-button-via-the-command-line
 
Solution

rohan.vaddiparty

Honorable
Sep 8, 2017
23
0
10,540


Worked like a charm. This was my code:
Send {TAB}{TAB}{ENTER}

Cause i created a batch file with the following:

start (Application Name)
timeout /t 5 (5 secs delay for the application to start up)
start click.ahk ( The AHK to run the TAB TAB ENTER )


Thank you.
 

gardenman

Splendid
Moderator
Great, I'm glad that worked out. A few tips:

#1. You probably could replace your whole batch file with a script. You can use the Run command just like the batch file start command. There is also a Sleep command that will delay the script. Example: Sleep 5000 will wait for 5 seconds. But then again, a combination of batch and script works just as good.

#2. You can easily convert your .AHK script into an .EXE file. Right click on your .AHK file and choose Compile Script. Give it a few seconds to create your .EXE file. It will be about 1 mb in size and will contain both your script and the AutoHotKey program itself. Therefore if you ever decide to uninstall AutoHotKey, you can do that, yet your compiled script (.EXE) will still work.
 

rohan.vaddiparty

Honorable
Sep 8, 2017
23
0
10,540


Just did the .exe file. Coded it to run the whole procedure through ahk. The .exe compilation is better cause in future kiosks, I can just execute the .exe file without installing ahk.