Rodolfo;
Te dejo este c贸digo, que entiendo es lo que necesitas, y que Manu Exp贸sito me lo cedi贸 hace unos cuaaaaantos a帽os
//----------------------------------------------------------------------------//
// 聽DATAS.....: * lCapture tiene un valor logico, .f. si la ventana no se 聽 聽 //
// 聽 聽 聽 聽 聽 聽 聽pudo capturar y .t. si si se hizo 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 //
// 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽//
// 聽METODOS...: * New( cTitle ) es el constructor, cTitle es el titulo de una //
// 聽 聽 聽 聽 聽 聽 聽ventana, si se le pasa intentara capturarla y pondra .t. en 聽 //
// 聽 聽 聽 聽 聽 聽 聽::lCapture 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽//
// 聽 聽 聽 聽 聽 聽 聽* WCapture se encarga de buscar la ventana y asignarla a 聽 聽 聽//
// 聽 聽 聽 聽 聽 聽 聽nuestro objeto TWindow. Si la captura podremos interactuar 聽 聽//
// 聽 聽 聽 聽 聽 聽 聽como si fuera una ventana mas de nuestra aplicacion 聽 聽 聽 聽 聽 //
// 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽//
// 聽NOTAS.....: TWCapture esta heredada de TWindows por lo que tendremos a 聽 聽//
// 聽 聽 聽 聽 聽 聽 聽nuestra disposicion todas las datas y metodos de esta clase. 聽//
// 聽 聽 聽 聽 聽 聽 聽No distingue entre mayusculas y minuscula pero si se tienen 聽 //
// 聽 聽 聽 聽 聽 聽 聽en cuenta los espacios 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽//
//----------------------------------------------------------------------------//
#include "Objects.ch"
//----------------------------------------------------------------------------//
CLASS TWCapture FROM TWindow
聽 聽 DATA lCaptured 聽AS BOOL
聽 聽 METHOD New( cTitle ) CONSTRUCTOR
聽 聽 METHOD WCapture( cTitle )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( cTitle ) CLASS TWCapture
聽 聽 if( ValType( cTitle ) == "C", ::WCapture( cTitle ), ::lCaptured := .f. )
return( Self )
//----------------------------------------------------------------------------//
METHOD WCapture( cTitle ) CLASS TWCapture
聽 聽local hWnd := FindWindow( 0, cTitle )
聽 聽::lCaptured := ( hWnd > 0 )
聽 聽::hWnd := if( ::lCaptured, hWnd, 0 )
return( ::lCaptured )
//----------------------------------------------------------------------------//
Sample01
//----------------------------------------------------------------------------//
// TWCapture by Manu Exposito
// Demo01 de la clase TWCapture
// Pasando un titulo de ventana
//----------------------------------------------------------------------------//
#define CRLF chr( 13 ) + chr( 10 )
function Main()
聽 聽local oWnd
聽 聽local cTitle := space( 40 )
聽 聽 if MsgGet( "Entre titulo de una ventana abierta", "Titulo:", @cTitle ) .and. !empty( cTitle )
聽 聽 聽 聽 oWnd := TWCapture():New( AllTrim( cTitle ) )
聽 聽 聽 聽 Jugar( oWnd )
聽 聽 else
聽 聽 聽 聽 MsgAlert( "No ha elegido ningun titulo de ventana" + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽"Ejecuto el WorPad y capturamos la ventana" )
聽 聽 聽 聽 WinExec( "NotePad.exe Demo01.prg" )
聽 聽 聽 聽 oWnd := TWCapture():New( "demo01 - bloc de notas" )
聽 聽 聽 聽 Jugar( oWnd )
聽 聽 endif
return nil
//----------------------------------------------------------------------------//
static function Jugar( oWnd )
聽 聽 聽 聽 local cTitle := oWnd:cTitle
聽 聽 聽 聽 if oWnd:lCaptured
聽 聽 聽 聽 聽 聽 MsgAlert( "Muy bien, ya lo tenemos" + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Hemos capturado la ventana con titulo: " + cTitle + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 CRLF + "Ahora vamos a jugar con ella" )
聽 聽 聽 聽 聽 聽 MsgInfo( "La centramos" )
聽 聽 聽 聽 聽 聽 oWnd:Center()
聽 聽 聽 聽 聽 聽 MsgInfo( "Pinto una linea" )
聽 聽 聽 聽 聽 聽 oWnd:Line( 0, 0, 500, 500 )
聽 聽 聽 聽 聽 聽 MsgInfo( "La desplazo a la izquierda" )
聽 聽 聽 聽 聽 聽 oWnd:Move( 0, 0 )
聽 聽 聽 聽 聽 聽 MsgInfo( "Ahora minimizo" )
聽 聽 聽 聽 聽 聽 oWnd:Minimize()
聽 聽 聽 聽 聽 聽 MsgInfo( "Ahora maximizo" )
聽 聽 聽 聽 聽 聽 oWnd:Maximize()
聽 聽 聽 聽 聽 聽 MsgInfo( "La restauro" )
聽 聽 聽 聽 聽 聽 oWnd:Restore()
聽 聽 聽 聽 聽 聽 MsgInfo( "Ahora cambio titulo" )
聽 聽 聽 聽 聽 聽 oWnd:SetText( "TWCapture captura ventanas - by Manu Exposito 2001" )
聽 聽 聽 聽 聽 聽 MsgInfo( "Ahora la oculto" )
聽 聽 聽 聽 聽 聽 oWnd:Hide()
聽 聽 聽 聽 聽 聽 MsgInfo( "Ahora la muestro" )
聽 聽 聽 聽 聽 聽 oWnd:Show()
聽 聽 聽 聽 聽 聽 MsgInfo( "y ahora termino" )
聽 聽 聽 聽 聽 聽 oWnd:End()
聽 聽 聽 聽 else
聽 聽 聽 聽 聽 聽 MsgStop( "No se pudo capturar ninguna ventana" )
聽 聽 聽 聽 聽 聽 oWnd := nil
聽 聽 聽 聽 endif
return( nil )
Sample02
//----------------------------------------------------------------------------//
// TWCapture by Manu Exposito
// Demo02 de la clase TWCapture
//----------------------------------------------------------------------------//
#define CRLF chr( 13 ) + chr( 10 )
function Main()
聽 聽 local oWnd := TWCapture():New()
聽 聽 local cTitle := space( 40 )
聽 聽 oWnd:WCapture( "demo02 - bloc de notas" )
聽 聽 if !oWnd:lCaptured 聽 聽 聽// Si no esta la ventana la ejecutamos nosotros
聽 聽 聽 聽 WinExec( "NotePad.exe demo02.prg" )
聽 聽 聽 聽 oWnd:WCapture( "demo02 - bloc de notas" ) 聽// y la capturamos
聽 聽 endif
聽 聽 Jugar( oWnd )
return nil
//----------------------------------------------------------------------------//
static function Jugar( oWnd )
聽 聽 聽 聽 local cTitle := oWnd:cTitle
聽 聽 聽 聽 if oWnd:lCaptured
聽 聽 聽 聽 聽 聽 MsgAlert( "Muy bien, ya lo tenemos" + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Hemos capturado la ventana con titulo: " + cTitle + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 CRLF + "Ahora vamos a jugar con ella" )
聽 聽 聽 聽 聽 聽 MsgInfo( "La centramos" )
聽 聽 聽 聽 聽 聽 oWnd:Center()
聽 聽 聽 聽 聽 聽 MsgInfo( "Pinto una linea" )
聽 聽 聽 聽 聽 聽 oWnd:Line( 0, 0, 500, 500 )
聽 聽 聽 聽 聽 聽 MsgInfo( "La desplazo arriba a la izquierda" )
聽 聽 聽 聽 聽 聽 oWnd:Move( 0, 0 )
聽 聽 聽 聽 聽 聽 MsgInfo( "Ahora minimizo" )
聽 聽 聽 聽 聽 聽 oWnd:Minimize()
聽 聽 聽 聽 聽 聽 MsgInfo( "Ahora maximizo" )
聽 聽 聽 聽 聽 聽 oWnd:Maximize()
聽 聽 聽 聽 聽 聽 MsgInfo( "La restauro" )
聽 聽 聽 聽 聽 聽 oWnd:Restore()
聽 聽 聽 聽 聽 聽 MsgInfo( "Ahora cambio titulo" )
聽 聽 聽 聽 聽 聽 oWnd:SetText( "TWCapture captura ventanas - by Manu Exposito 2001" )
聽 聽 聽 聽 聽 聽 MsgInfo( "Ahora la oculto" )
聽 聽 聽 聽 聽 聽 oWnd:Hide()
聽 聽 聽 聽 聽 聽 MsgInfo( "Ahora la muestro" )
聽 聽 聽 聽 聽 聽 oWnd:Show()
聽 聽 聽 聽 聽 聽 MsgInfo( "y ahora termino" )
聽 聽 聽 聽 聽 聽 oWnd:End()
聽 聽 聽 聽 else
聽 聽 聽 聽 聽 聽 MsgStop( "No se pudo capturar ninguna ventana" )
聽 聽 聽 聽 聽 聽 oWnd := nil
聽 聽 聽 聽 endif
return( nil )
//----------------------------------------------------------------------------//
Saludos