Program der andere programme schliest?
Nicky 20.05.2005 - 14:59 535 3
Nicky
Banned
|
Seas, Ich schreib jetzt auf english sonst wirds mir zu kompl.
Ok, What I want to do is create a program that if I hit F1 (or any other key that i set) that it will exit certain programms.
So for instance. If I push F1 the program will exit limewire and bittorrent.
I know a good deal of java, c++ and a bit of visual basic so if anyone could help i would be most thankfull!
Mfg Nicky
|
watchout
Legendundead
|
|
mat
AdministratorLegends never die
|
nein, bitte nicht mit terminateprocess(). viel schöner wäre es dem fenster eine WM_QUIT message zu schicken. natürlich benötigt man fallbacks, weil anwendungen furchtbar programmiert sein können und zB die QUIT message abfangen usw. man könnte das quasi mit timeout machen, sowie der windowseigene "prozess-beenden dialog". http://www.overclockers.at/showthre...threadid=136898das ding hier macht schon einiges was du brauchen könntest (systray, window hook für abfangen des keys)
|
that
Hoffnungsloser Optimist
|
Korrekt schickt man einem Windows-Programm ein WM_CLOSE, wenn man es "sauber" beenden will. Resources: - hotkey.cpp from http://that.at to intercept global hotkeys - Win32 APIs FindWindow and SendMessage I also found this on my hard drive (just merge this nice little command line tool with the technology from hotkey.cpp): // closewnd.cpp - close specified windows
#include <windows.h>
#include <string.h>
#include <stdio.h>
static const char Helptext[] =
"Window close utility, (c)that2001\n\n"
"Syntax: closewnd <window title>\n";
BOOL CALLBACK EnumProc(HWND hwnd, LPARAM lParam)
{
LPCSTR pszTitle = (LPCSTR) lParam;
char sz[200];
GetWindowText(hwnd, sz, sizeof(sz));
if (IsWindowVisible(hwnd) && strstr(_strlwr(sz), pszTitle))
PostMessage(hwnd, WM_CLOSE, 0, 0);
return TRUE;
}
int main(int argc, char **argv)
{
if (argc < 2) {
printf(Helptext);
return 1;
}
_strlwr(argv[1]);
EnumWindows(EnumProc, (LPARAM) argv[1]);
return 0;
}
|