Microsoft KB Archive/153003

= How to perform a screen capture programmatically from Visual FoxPro =

Article ID: 153003

Article Last Modified on 2/8/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 9.0 Professional Edition

-



This article was previously published under Q153003



SUMMARY
It is not possible to use the KEYBOARD command in FoxPro to stuff the keyboard buffer with PrintScrn or Alt+PrintScrn to copy the whole screen or the active window to the clipboard. This article describes how you can call the Win32 API function, keybd_event, to get this functionality under Windows 95 and Windows NT. This functionality, however, is not available under Windows 3.1 or Windows for Workgroups since the Win32s subsystem does not contain these API functions.



MORE INFORMATION
The following commands register the keybd_event function and set up a variable that will be passed each time to the function: DECLARE INTEGER keybd_event IN Win32API ; INTEGER, INTEGER, INTEGER, INTEGER VK_SNAPSHOT = 44   && from the winuser.h   VK_LMENU = 164 KEYEVENTF_KEYUP = 2 KEYEVENTF_EXTENDEDKEY = 1 The following commands copy the full windows desktop to the clipboard (the equivalent of PrintScrn): DOEVENTS keybd_event(VK_SNAPSHOT, 1, 0, 0 ) keybd_event(VK_SNAPSHOT, 1, KEYEVENTF_KEYUP, 0 ) DOEVENTS The following commands copy the active application window to the clipboard (the equivalent of ALT+PrintScrn): DOEVENTS keybd_event( VK_LMENU,   0, KEYEVENTF_EXTENDEDKEY, 0 )  && key down keybd_event( VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY, 0 ) keybd_event( VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0 ) keybd_event( VK_LMENU,   0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0 ) DOEVENTS

Additional query words: VFoxWin

Keywords: kb3rdparty KB153003

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.