Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Open application and execute commands

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,3221
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Open application and execute commands
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Open application and execute commands - 6/4/2005 8:21:25 AM   
  mdrgroup

 

Posts: 1
Score: 0
Joined: 6/4/2005
From:
Status: offline
Help me I'm a total NOOB!!!!

What I'm trying to do is use WSH to open a windows application, perform commands (such as open file, type text into the file, save file as, etc.). I'm starting with notepad which there seem to be a lot of examples for. Here is the first script:

'VBScript Example
Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run "%windir%\notepad.exe"
WshShell.AppActivate "Notepad"


WshShell.SendKeys "Bok"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "^S"

I am expecting that this script will open notepad, activate the notepad window, and then type "Bok", press return and then save the file. Well the script types bok and enter, but doesn't save the file. Is there some other way of doing this, and controlling the commands of windows applications in general? What I'd really like to learn is how to open any windows program and execute commands in it.

--Noobola

[xx(]
 
 
Post #: 1
 
 Re: Open application and execute commands - 6/5/2005 7:09:45 AM   
  didorno

 

Posts: 361
Score: 0
Joined: 2/12/2005
From:
Status: offline
If you enter the commands with your keyboard, does it work ?
I have first to open the file menue by means of ALT, etcetera, before I can give the save command.
It is advisable to give each sendkeys command some time to work,
for instance "WScript.Sleep 200" between the lines.

Anyway, the use of sendkeys can be dangerous if multiple windows are open. Sometimes the commands can go to the wrong window causing
"unpleasant" results.

Good luck !

(in reply to mdrgroup)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Open application and execute commands Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts