|
-
Aug 1st, 2000, 02:45 PM
#1
Thread Starter
Lively Member
hi, i need to close an outside program, i mean if there is a program running and its filename is lets say:
c:\program\someprogram.exe, so i want my program to simply close that program, any ideas ???
thankx in advance, yair
-
Aug 1st, 2000, 02:53 PM
#2
This will list all running file's by filename (C:\....) and give you the option to kill them.
App List and Kill
-
Aug 1st, 2000, 02:59 PM
#3
Lively Member
-
Aug 1st, 2000, 03:01 PM
#4
Kill a.k.a Close .
-
Aug 1st, 2000, 03:09 PM
#5
Thread Starter
Lively Member
OKOKOK, i got it, i need to kil,
now the prob... HOW??
thnkx,
yair
-
Aug 1st, 2000, 03:10 PM
#6
Lively Member
Yeah, but "kill" is such a better word then "close". Maybe they could make coding less stressful by adding words like "Mangle", "Pummel", and "Annihilate".
-
Aug 1st, 2000, 03:13 PM
#7
You can also use SendMessage.
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_CLOSE = &H10
Private Sub Command1_Click()
'Get Calculator's Handle and close it
MyhWnd = FindWindow(0&, "Calculator")
SendMessage MyhWnd, WM_CLOSE, 0&, 0&
End Sub
-
Aug 1st, 2000, 03:13 PM
#8
Lively Member
Follow the link Matt posted. Hell, you might learn something.
-
Aug 1st, 2000, 03:19 PM
#9
Thread Starter
Lively Member
ok, thankx alot u guys...
bye,
yair
-
Aug 1st, 2000, 03:57 PM
#10
Also, if the Application you want to close does not have a caption, you can close it according to it's class.
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_CLOSE = &H10
Private Sub Command1_Click()
'Get Calculator's Handle (By it's class) and close it
MyhWnd = FindWindow("SciCalc", 0&)
SendMessage MyhWnd, WM_CLOSE, 0&, 0&
End Sub
-
Aug 1st, 2000, 09:59 PM
#11
You could also do it the Sendkeys way. This will give the program focus and press alt+f4.
Code:
AppActivate "The Caption of the Program"
SendKeys "%{F4}"
-
Aug 14th, 2000, 10:49 AM
#12
Member
Yeah, but...
If you're trying to close a program that has something like, say, an unsaved file, you'll get a prompt asking to save, thereby not closing the program immediately using SendKeys. Try going to the VB Help, search for AppActivate, and see what "See Also" items it lists to see if there is already something similar.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|