There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Software Development
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard netgear network printer problem ram registry repair router slow software sound toshiba trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless xbox
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Software Development >
Windows Script Programming

Reply  
Thread Tools
juliette salexa's Avatar
Junior Member with 29 posts.
 
Join Date: Dec 2008
Location: Ontario, Canada
09-Jun-2009, 05: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
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
09-Jun-2009, 06: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 29 posts.
 
Join Date: Dec 2008
Location: Ontario, Canada
10-Jun-2009, 01: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 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
10-Jun-2009, 11: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 Expert - Consumer
Of course I know all the answers ; I just don't always match the answers to the right questions

Reply

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.

Search Tech Support Guy

Find the solution to your
computer problem!




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



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:11 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.