Batch file or vbscript help!

December 30, 2010 at 12:18:05
Specs: Windows 7
Is it possible for in a bat or vbs file to open a program then simulate button presses then open another program?

first program location- C:\Program Files\UltraISO\UltraISO.exe
tab tab enter f6 tab enter
second program location- C:\Program Files\Black Isle\Torment\Torment.exe

what this does is mounts a game to a virtual drive then plays it.


See More: Batch file or vbscript help!

Report •


#1
December 30, 2010 at 12:55:20
You can send keys (inclusive F1-F12 keys, del, home and more) with nircmd.

Download nircmd: http://www.nirsoft.net/utils/nircmd...

Unzip nircmd.zip into your Windows (or Windows\system32) directory.

::SCRIPT.bat

@echo off
REM *** Set the path to the program(s) here
set P1=C:\Program Files\UltraISO\UltraISO.exe
set P2=C:\Program Files\Black Isle\Torment\Torment.exe

REM *** Start the given program. (P1)
start explorer.exe "%P1%"

REM *** Waits 5 second.
nircmd.exe wait 5000

REM *** Presses TAB key.
nircmd.exe sendkey 0x09 press

REM *** Waits 1 second.
nircmd.exe wait 1000

REM *** Presses TAB key.
nircmd.exe sendkey 0x09 press

REM *** Waits 1 second.
nircmd.exe wait 1000

REM *** Presses ENTER key.
nircmd.exe sendkey 0x0D press

REM *** Waits 1 second.
nircmd.exe wait 1000

REM *** Presses F6 key.
nircmd.exe sendkey 0x75 press

REM *** Waits 1 second.
nircmd.exe wait 1000

REM *** Presses TAB key.
nircmd.exe sendkey 0x09 press

REM *** Waits 1 second.
nircmd.exe wait 1000

REM *** Presses ENTER key.
nircmd.exe sendkey 0x0D press

REM *** Waits 1 second.
nircmd.exe wait 1000

REM *** Start the given program. (P2)
start explorer.exe "%P2%"

REM *** Pauses till user input.
pause

REM *** Exits
exit

You can remove the wait(s), but it's recommend to use them, because otherwise maybe it will do it too fast. LOL

Regards,

Happy is ONE who says I am an OttoMAN.


Report •

#2
December 30, 2010 at 13:46:51
Cool tool, If you keep promoting it this way they are gonna hire you as Brand Ambesdor :) Seems autoit is gonna out of market soon.

anyway its Nice and neat.

Subhash Chandra.


Report •

#3
December 30, 2010 at 14:12:57
Yes, especially since VBScript and the newer POWERSHELL! can send keyboard input without third party applications.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
December 31, 2010 at 05:42:00
@Razor2.3

"Is it possible for in a bat or vbs file ... "

If you have another solution for this question with vbs?

Happy is ONE who says I am an OttoMAN.


Report •

#5
December 31, 2010 at 06:15:00
I do, but if I were the one doing this, I'd probably just change Planescape: Torment's config file (and patch the EXE) to not use CD's in the first place. (I'm assuming its copy protection is the same one used by the Baldur's Gate series.)

That said, VBScript would look something like this:

With CreateObject("WScript.Shell")
  .Run """C:\Program Files\UltraISO\UltraISO.exe""", 1
  WScript.Sleep 5000
  .SendKeys "{TAB}{TAB}~"
  WScript.Sleep 1000
  .SendKeys "{F6}"
  WScript.Sleep 1000
  .SendKeys "{TAB}~"
  .Run """C:\Program Files\Black Isle\Torment\Torment.exe""", 1
End With

How To Ask Questions The Smart Way


Report •

#6
December 31, 2010 at 07:31:25
Oh ok.

Nice script :)

Happy is ONE who says I am an OttoMAN.


Report •

#7
December 31, 2010 at 07:49:18
MUs

Need a suggestion.... using nircmd.exe sendkey 0x0D press
Seems no matter where I place it I cant get it to work. ????

if %INPUT% == baker echo cookies   >>temp.txt


Report •

#8
December 31, 2010 at 12:50:38
It does work for me :c
Do you even have nircmd? And un-zipped nircmd.exe into your WINDOWS directory?

Have a look @ my post #2

The 0x0D code is a virtual key code for the ENTER key, Google: Virtual Key Codes.

By the way..

"if %INPUT% == baker echo cookies >>temp.txt" ???

Regards,

Happy is ONE who says I am an OttoMAN.


Report •

#9
January 1, 2011 at 02:41:24
"Do you even have nircmd? And un-zipped nircmd.exe into your WINDOWS directory?"

Yes

"Have a look @ my post #2"
Post 2 isn' t yours....post1?

Did.

"The 0x0D code is a virtual key code for the ENTER key"

Correct

", Google: Virtual Key Codes."

I think that might be best.

Oh! your code in post 1 works perfectly.......I might not be be pleased with
your reply to me but I do give credit where credit is deserved.

W.L.


Report •

#10
January 1, 2011 at 04:21:01
Yeah I meant post #1 >:c

"I might not be be pleased with your reply to me"

Why?

Regards,

Happy is ONE who says I am an OttoMAN.


Report •


Ask Question