Advanced PowerBuilder

HomePrevious Lesson: Finding Where the EXE is Running From
Next Lesson: Copying the Full Screen to the Clipboard

Copying the Active Window to the Clipboard

Declare a local external function as shown below.
SUBROUTINE ufx_keybd_event( int bVk, int bScan, &
           int dwFlags, int dwExtraInfo) LIBRARY &
           "user32.dll" ALIAS FOR "keybd_event"

The following code presses the keys for you and releases them as necessary. It depresses ALT + Print Screen keys to copy the active to the Windows clipboard and releases them by sending 2 as the third argument. The virtual mapping keys are listed in the Appendix.
// Object: cb_clipboard_window
// Event: Clicked
ufx_keybd_event( 18, 0, 0, 0 ) // ALT key depressed
ufx_keybd_event( 44, 0, 0, 0 ) // PrintScreen key depressed
ufx_keybd_event( 18, 0, 2, 0 ) // ALT key released

ufx_keybd_event( 44, 0, 2, 0 ) // PrintScreen key released

HomePrevious Lesson: Finding Where the EXE is Running From
Next Lesson: Copying the Full Screen to the Clipboard