Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
API function for ALT+F4 shortcut
Message
From
03/08/2000 13:31:03
 
 
To
03/08/2000 12:48:24
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00400465
Message ID:
00400510
Views:
12
>How can I programmatically determine which application (window title)is running on my desktop?
>

Use GetForeGroundWindow() to get the hWnd of the Foreground Window, and use the hWnd to call GetWindowText() to retrieve the title bar text:

DECLARE INTEGER GetForegroundWindow IN WIN32API
DECLARE INTEGER GetWindowText IN WIN32API INTEGER hWnd, STRING @ lpString, INTEGER nMaxCount
lpTitle = REPL(CHR(0),512)
=GetWindowText(GetForegroundWindow(),@lpTitle,511)
cWindowTitle=LEFT(lpTitle,AT(CHR(0),lpTitle)-1)

>How can I could programmatically close\Alt+F4 running application?

You can use SendMessage() to send a WM_QUIT message to the main Window of the application, and if that doesn't work, get a process handle to the application and invoke TerminateProcess() through the API.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform