Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Software Development
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop driver drivers dvd email error excel excel 2003 firefox hard drive hardware hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem recovery router safe mode screen slow sound spyware trojan upgrade vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Software Development >
Windows Script Programming

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
juliette salexa's Avatar
Junior Member with 25 posts.
 
Join Date: Dec 2008
Location: Ontario, Canada
09-Jun-2009, 04:05 PM #1
Windows Script Programming
Hello,
Does anybody use Windows Script Host ??

I want to write a program that:
1. runs program.exe
2. once program.exe opens (it will be a new window), it types "filename" into the newly opened window. Then my program instructs the computer to press "enter"
3. The program now instructs the computer to type in "Y" and "Enter" in the same window as step 2.
4. The program instructs windows to close the window to which steps 2 and 3 refer.

This is very simple, but I don't know how to do it!

I'm pretty sure Windows can do this because i can do this pretty easily in UNIX, the only problem is that program.exe only runs on Windows ..

I'd appreciate any help. Thanks.
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
09-Jun-2009, 05:59 PM #2
If the program you want to run is graphical and doesn't take any cmd line arguments then you would need to use a program like AutoHotkey or AutoIt to do what you want to do.
juliette salexa's Avatar
Junior Member with 25 posts.
 
Join Date: Dec 2008
Location: Ontario, Canada
10-Jun-2009, 12:29 AM #3
Quote:
Originally Posted by Squashman View Post
If the program you want to run is graphical and doesn't take any cmd line arguments then you would need to use a program like AutoHotkey or AutoIt to do what you want to do.
Thanks ..
It's a GUI, but I've made the program such that everything the program does is based on typed in commands.

I could type in the commands myself, but I'd have to do the same thing over and over again for a thousand different files.

Do I still have to use AutoHotKey or AutoIt to do this ?? And if so, which would you recommend ??

Thanks a lot Squashman!
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 5,485 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
10-Jun-2009, 10:28 AM #4
If you can close the window using ALT+F4, this should work, just substitute program.exe for notepad.exe. The Sleep commands might need to be adjusted, or might not be needed at all. This will not prevent another program from stealing the focus, it simply sends keystrokes to the active window:
Code:
Set objShell = CreateObject("WScript.Shell")
objShell.Run "notepad.exe"
Wscript.Sleep 1500
objShell.SendKeys "filename"
Wscript.Sleep 100
objShell.SendKeys "{ENTER}"
Wscript.Sleep 100
objShell.SendKeys "y"
Wscript.Sleep 100
objShell.SendKeys "{ENTER}"
Wscript.Sleep 100
objShell.SendKeys "%{F4}"
WScript.Quit
The % is used to send ALT.

Notepad will prompt to save when closed, this example lets the user make a choice.
You could send ALT+Y (objShell.SendKeys "%y") to save, send a file name (including drive&path), then ALT+S to save, or ALT+N to not save.

More info on the SendKeys Method.

AutoIt or AutoHotKeys would also be good choices. I haven't used either enough to be able to recommend one over the other.

HTH

Jerry
__________________
Microsoft MVP - Windows Desktop Experience
Of course I know all the answers ; I just don't always match the answers to the right questions
Are you aware of the New Signature Limitations?
Closed Thread Bookmark and Share

Tags
javascript, program, unix, vbscript, windows script

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 11:06 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.