Fiz as mudanças necessárias.
Agora vai funcionar.
Agradeço
Código: Selecionar todos
#include <hmg.ch>
#define GW_HWNDFIRST 0
#define GW_HWNDNEXT 2
#define GW_OWNER 4
Function Main()
//################# inserido por mim - a variável como é recebida como um parametro
Parameters como
//################# inserido por mim
Local aTitles := GetTitles( GetForegroundWindow() )
mytexto := estacao := estacnu := unitserver := ''
DebugMSG(aTitles)
Return
Function GetTitles( hOwnWnd )
Local aTasks := {}, cTitle := "", ;
hWnd := GetWindow( hOwnWnd, GW_HWNDFIRST ) // Get the first window
//################# inserido por mim
mydir := directory('solicaux.t??')
cntarq := 1
while cntarq <= len(mydir)
mytexto += mydir[cntarq,1]+crlf+memoread(mydir[cntarq,1])+crlf+crlf
if getenv('USERDOMAIN')+'###'+getenv('USERNAME') $ memoread(mydir[cntarq,1])
estacao := 'TERM'+ltri(str(val(subs(mydir[cntarq,1],11))))
estacnu := subs(mydir[cntarq,1],11)
unitserver := if ('UNITSERVER' $ memoread(mydir[cntarq,1]) , estacao , '' )
exit
end
cntarq++
end
//################# inserido por mim
//################# inserido por mim - como = 'V' significa só as visíveis
if como = 'v'
//################# inserido por mim
Do While hWnd != 0 // Loop through all the windows
cTitle := GetWindowText( hWnd )
If GetWindow( hWnd, GW_OWNER ) = 0 .AND.; // If it is an owner window
IsWindowVisible( hWnd ) .AND.; // If it is a visible window
hWnd != hOwnWnd .AND.; // If it is not this app
!EMPTY( cTitle ) .AND.; // If the window has a title
!( "Prompt de comando" $ cTitle ) .AND.; // If it is not DOS session
!( cTitle == "Program Manager" ) // If it is not the Program Manager
aAdd( aTasks, { cTitle, hWnd } )
Endif
hWnd := GetWindow( hWnd, GW_HWNDNEXT ) // Get the next window
Enddo
//################# inserido por mim - como = 'i' significa só as invisíveis
elseif como = 'i'
//################# inserido por mim
Do While hWnd != 0 // Loop through all the windows
cTitle := GetWindowText( hWnd )
If GetWindow( hWnd, GW_OWNER ) = 0 .AND.; // If it is an owner window
hWnd != hOwnWnd .AND.; // If it is not this app
!EMPTY( cTitle ) .AND.; // If the window has a title
!( "Prompt de comando" $ cTitle ) .AND.; // If it is not DOS session
!( cTitle == "Program Manager" ) // If it is not the Program Manager
aAdd( aTasks, { cTitle, hWnd } )
Endif
hWnd := GetWindow( hWnd, GW_HWNDNEXT ) // Get the next window
Enddo
//################# inserido por mim
end
//################# inserido por mim
Return ( aTasks )
Function DebugMSG
Local i, aTemp := {}
//################# inserido por mim - definindo uma variável texto vazia
Local fll := ''
//################# inserido por mim
For i := 1 to pcount()
//################# comentado por mim
//aadd( aTemp, hb_PValue(i))
//################# comentado por mim
//################# inserido por mim -> adicionando na var texto o conteudo seguido de carriage return
// Fll += aTemp, hb_PValue(i)+chr(13)+chr(10)
Fll += hb_valtoexp(hb_PValue(i))+chr(13)+chr(10)
//################# inserido por mim
Next i
//################# comentado por mim
//MsgBox(hb_valtoexp(aTemp), "Helpful informations")
//################# comentado por mim
//################# inserido por mim --> gravando em um texto o conteudo da variavel
memowrit('qp.t'+estacnu,fll)
//################# inserido por mim
Return Nil
