URL: https://www.overclockers.at/coding-stuff/program_der_andere_programme_schliest_142767/page_1 - zur Vollversion wechseln!
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
Well, I never push my buttons for something...
Whatsoever. What you want is to use the WinAPI:
The MSDN is a good reference... http://msdn.microsoft.com/library/d...i_reference.asp
*Hint*
http://msdn.microsoft.com/library/d...nateprocess.asp
hth
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=136898
das ding hier macht schon einiges was du brauchen könntest (systray, window hook für abfangen des keys)
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):
Code: PHP// 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; }
overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2025