Visual Basic Explorer
Visual Basic Explorer
 Navigation
 Home


 Coding
 Source Code

 FAQ Center

 VB Tips

 Downloads

 ToolBox

 Tutorials

 VB Games

 VB News

 VB Award

 VB Forums



 Affiliates
 Planet Source Code

 Rent a Coder

 DirectX4VB


 Misc
 Search

 Feedback

 Advertise

 About


Need to hire
a VB coder?

Please support our sponsor:

 Home 
 Site Map 
 Forums 
 News 
 Feedback 

 

Q. Closing an external application?

 
I`m trying to write a program that will close an
application after a certain period of time. Running
the program (i.e. Notepad) seems easy, but I have yet
to find a statement to terminate it.

 
A. You can use SendKeys to close a program. The following
text is taken from the SendKeys example in the online help.
It runs, uses and closes the calculator, but notepad would
be very similar.

 
ReturnValue = Shell("Calc.exe", 1) .
ppActivate ReturnValue' Activate calc.

 
For i = 1 To 100
endKeys i & "{+}", True' Send keys
Next i .
endKeys "=", True' Get grand total.

 
endKeys "%{F4}", True' ALT+F4 closes

 
(26-Aug-98 Bob Walsh rlwalsh@capecod.net)

 
A. Place 2 command buttons on a form and then paste this
code into your declarations section.

Press Command1 to start up notepad and Command2 to terminate
it.

Option Explicit
Dim ReturnValue
Private Sub Command1_Click()
ReturnValue = Shell("notepad.exe", 1)
End Sub

 
Private Sub Command2_Click()
Dim i
ppActivate ReturnValue' Activate notepad.
endKeys "%{F4}", True' Send ALT+F4 to close notepad
End Sub

 
(26-Aug-98 Rich ryarnell@andrew.cmu.edu)


Downloads

In IE right-click and select 'Save Target As...' or in Netscape right-click and select 'Save Link As...'

 

View Plain Text View Plain Text
Download Demo Project Not Available
View Code Online Not Available





Home | About | What's New | Source Code | FAQ | Tips & Tricks | Downloads | ToolBox | Tutorials | Game Programming | VB Award | Search | VB Forums | Feedback | VBNews | Copyright & Disclaimer | Advertise | Privacy Policy |

Quick searches: Site Search | Advanced Site Search 

Copyright 2002 by Exhedra Solutions, Inc.
By using this site you agree to its terms and conditions
VB Explorer and VBExplorer.com are trademarks of Exhedra Solutions, Inc.