Pessoal,
Sou funcionário do BB em Curitiba (CSO) e, como em todos os órgãos regionais do Banco, dependemos de robôs para a captura de dados para geração de informações necessárias para uso interno, bem como para agilizar os processos repetitivos. Sou totalmente contra este tipo de abordagem para obtenção de dados, embora não tenhamos muitas opções.
Talvez o mais adequado seria implementar soluções corporativos para estas demandas (o que talvez no momento não seja factível, considerando a complexidade das soluções) e, em não havendo esta possibilidade, permitir o acesso às informações através de um (ou mais) data wherehouse, que pudesse ser acessado remotamente - permitindo a extração dos dados atualizados das bases corporativas. Esta última, permitiria a aposentadoria da maioria dos robôs hoje em uso.
Convicções à parte, vamos ao que interessa: Preciso do "caminho das pedras" para desenvolver uma estrutura de captura em VB.Net e/ou Java. Atualmente possuo robôs em VBA (Access e afins), VB.Net e Java - usando o PComm.
Conto com sua preciosa ajuda.
Grato,
Geison.
Autor: Geison Rodrigo dos Santos
5252 comentários
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System")
If (System Is Nothing) Then
MsgBox "NÃO FOI POSSÍVEL ACESSAR EXTRA. OPERAÇÃO CANCELADA."
Stop
End If
Set Sessions = System.Sessions If (Sessions Is Nothing) Then
MsgBox "NÃO FOI POSSÍVEL ACESSAR EXTRA. OPERAÇÃO CANCELADA."
Stop
End If
'________________________________
'Estabelece Tempo de espera padrão
g_HostSettleTime = 500 OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If '________________________________
'Variáveis
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 Is Nothing) Then
MsgBox "NÃO FOI POSSÍVEL ACESSAR EXTRA. OPERAÇÃO CANCELADA."
Stop
End If
If Not Sess0.Visible Then Sess0.Visible = True
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
(...) Aí, para capturar do Extra um texto de 22 caracteres de comprimento, que esteja na linha 20, coluna 1, usamos o seguinte comando no VBA: variavel = Sess0.Screen.Getstring(20, 1, 22) E para enviar comandos ou digitar algo no Extra, por exemplo, na linha 19, coluna 66, a letra A, e depois enviar o comando Enter, usamos: Sess0.Screen.Putstring "A", 19, 66
Sess0.Screen.SendKeys ("<Enter>")
Sess0.Screen.WaitHostQuiet (10) De qualquer maneira, se a sua DLL puder ser utilizada por nós, então ficaremos muito gratos a você! Grande abraço!
A função 8 (obtem string) parece ter algum problema na passagem de parâmetros o que exige que a string seja inicializada com espaços. O código que foi usado no teste foi: HllFunctionNo = 8 HllLength = (linha * 80) - (linha * 80 - 80) HllReturnCode = linha * 80 - 79 HllData = space(HllLength) dummy& = hllapi&(HllFunctionNo, HllData, HllLength, HllReturnCode) Form1.Text3.Text = Mid(HllData, col1, col2 + 1 - col1)
Geison.
dinâmico (DLL) é uma biblioteca especificada na cláusula Lib de uma
instrução Declare. As causas e soluções desse erro são as seguintes:O arquivo não é um DLL executável. Se o arquivo for um arquivo de texto de origem, deverá ser compilado e vinculado ao formulário de DLL executável. O arquivo não é um DLL do Microsoft Windows. Obtenha o DLL do Microsoft Windows equivalente do arquivo. O arquivo está em um DLL anterior do Microsoft Windows que é
incompatível com o modo de proteção do Microsoft Windows. Obtenha uma versão atualizada do DLL. O DLL faz referência a outro DLL que não está presente. Obtenha o DLL referido e torne-o disponível para o outro DLL. O DLL ou um dos DLLs referidos não está em um diretório
especificado por seu caminho. Mova o DLL para um diretório referido ou coloque seu diretório atual no caminho. Acho que o problema pode ser o item 4, pois quando utilizo um programa de verificar a ddl (chamado Dependency Walker) me informa que os módulos "LIBGCC_S_SEH-1.DLL", "LIBSTDC++-6.DLL", "IESHIMS.DLL" e "SYSNTFY.DLL" não foram localizados. Mas é só um palpite, outros usuários estão conseguindo acessar a ddl sem problemas? Obrigado.
Geison.
A função 8 (obtem string) parece ter algum problema na passagem de parâmetros o que exige que a string seja inicializada com espaços. O código que foi usado no teste foi: HllFunctionNo = 8 HllLength = (linha * 80) - (linha * 80 - 80) HllReturnCode = linha * 80 - 79 HllData = space(HllLength) dummy& = hllapi&(HllFunctionNo, HllData, HllLength, HllReturnCode) Form1.Text3.Text = Mid(HllData, col1, col2 + 1 - col1) ---------MÓDULO ANTERIOR ------------------------------------------------------------------
Option Compare Database Option Explicit Private HllFunctionNo As Long
Private HllData As String * 8000
Private HllLength As Long
Private HllReturnCode As Long ' trocar a linha abaixo pela linha seguinte:
'Private Declare Function hllapi& Lib "PCSHLL32.DLL" (Func&, ByVal DataString$, Length&, RetC&) Private Declare Function hllapi& Lib "libhllapi.dll" (Func&, ByVal DataString$, Length&, RetC&) Global Sessão As String
Global Tela As String
--------------------------------------------------------
Public Function Aguardar(ByVal linha As Integer, Coluna As Integer, TEXTO As String) As Boolean
If Copiar(linha, Coluna, Len(TEXTO)) = TEXTO Then
Aguardar = True
Else
Aguardar = False
End If
End Function
--------------------------------------------------------
Public Sub Atualizar()
Dim i As Integer
i = 0
Do While i < 20
HllFunctionNo = 4
HllData = ""
HllLength = 0
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
HllFunctionNo = 5
HllData = ""
HllLength = 0
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
Tela = Left(HllData & Space(1920), 1920)
i = i + 1
Loop
End Sub
--------------------------------------------------------
Public Function Colar(ByVal linha As Integer, Coluna As Integer, ByVal TEXTO As String) As Integer
HllFunctionNo = 15
HllData = TEXTO
HllLength = Len(TEXTO)
HllReturnCode = ((linha - 1) * 80) + Coluna
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
Colar = CInt(HllReturnCode)
End Function
--------------------------------------------------------
Public Function Conectar() As Integer
HllFunctionNo = 1
HllData = Sessão
HllLength = 4
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
Conectar = CInt(HllReturnCode)
HllFunctionNo = 9
HllData = "NORESET "
HllLength = 8
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
End Function
--------------------------------------------------------
Public Function Copiar(ByVal linha As Integer, Coluna As Integer, Tamanho As Integer) As String
Dim v As Variant
Dim t As Boolean
Copiar = Mid(Tela, ((linha - 1) * 80) + Coluna, Tamanho)
Atualizar
v = CopiarEspecial(2, 2, 3)
If v = "Ter" Then
v = ""
Exit Function
End If
t = IsNumeric(Copiar = Mid(Tela, ((linha - 1) * 80) + Coluna, Tamanho))
If t = False Then
Copiar = 0
Else
Copiar = Mid(Tela, ((linha - 1) * 80) + Coluna, Tamanho)
End If
End Function --------------------------------------------------------
Public Function CopiarEspecial(ByVal linha As Integer, Coluna As Integer, Tamanho As Integer) As String
CopiarEspecial = Mid(Tela, ((linha - 1) * 80) + Coluna, Tamanho)
End Function --------------------------------------------------------
Public Function Cursor() As Integer
HllFunctionNo = 7
HllData = ""
HllLength = 0
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
Cursor = HllLength
End Function
--------------------------------------------------------
Public Function CursorC() As Integer
Dim VAR As Integer
VAR = Cursor()
CursorC = IIf(VAR Mod 80 = 0, 80, VAR Mod 80)
End Function
--------------------------------------------------------
Public Function CursorL() As Integer
Dim VAR As Integer
VAR = Cursor()
CursorL = IIf(VAR Mod 80 = 0, VAR / 80, Int(VAR / 80) + 1)
End Function
--------------------------------------------------------
Public Function Desconectar() As Integer
HllFunctionNo = 2
HllData = ""
HllLength = 0
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
Desconectar = CInt(HllReturnCode)
End Function
--------------------------------------------------------
Public Function Enviar(ByVal origem As String, Destino As String, ByVal Opção As Integer) As Integer
Dim tipo As String
Select Case Opção
Case 1
tipo = "ASCII CRLF"
Case 2
tipo = ""
End Select
HllFunctionNo = 90
HllData = Trim(origem & " " & Destino & " " & tipo)
HllLength = Len(Trim(origem & " " & Destino & " " & tipo))
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
Enviar = HllReturnCode
End Function
--------------------------------------------------------
Public Function Localizar(ByVal TEXTO As String) As Integer
HllFunctionNo = 6
HllData = TEXTO
HllLength = Len(TEXTO)
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
Localizar = CInt(HllReturnCode)
End Function
--------------------------------------------------------
Public Function Posicionar(ByVal linha As Integer, Coluna As Integer) As Integer
HllFunctionNo = 40
HllData = ""
HllLength = 0
HllReturnCode = (80 * (linha - 1)) + Coluna
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
Posicionar = CInt(HllReturnCode)
End Function
--------------------------------------------------------
Public Function Receber(ByVal origem As String, Destino As String, ByVal Opção As Integer) As Integer
Dim tipo As String
Select Case Opção
Case 1
tipo = "ASCII CRLF"
Case 2
tipo = ""
End Select
HllFunctionNo = 91
HllData = Trim(origem & " " & Destino & " " & tipo)
HllLength = Len(Trim(origem & " " & Destino & " " & tipo))
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
Receber = HllReturnCode
End Function
--------------------------------------------------------
Public Function Teclar(TEXTO As String) As Integer
Dim TelaAnterior As String
Atualizar
TelaAnterior = Tela
HllFunctionNo = 3
HllData = TEXTO
HllLength = Len(TEXTO)
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
Teclar = CInt(HllReturnCode)
Do While TelaAnterior = Tela
Atualizar
Loop
Atualizar
' Atualizar
' Atualizar
End Function --------------------------------------------------------
Public Function Teclar2(TEXTO As String) As Integer
Dim TelaAnterior As String
Atualizar
TelaAnterior = Tela
HllFunctionNo = 3
HllData = TEXTO
HllLength = Len(TEXTO)
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
Teclar2 = CInt(HllReturnCode)
' Do While TelaAnterior = Tela
' Atualizar
' Loop
Atualizar
' Atualizar
' Atualizar
End Function
--------------------------------------------------------
Public Function Teclar1(TEXTO As String) As Integer
Dim TelaAnterior As String
Atualizar
TelaAnterior = Tela
HllFunctionNo = 3
HllData = TEXTO
HllLength = Len(TEXTO)
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
Teclar1 = CInt(HllReturnCode)
' Do While TelaAnterior = Tela
Atualizar
' Loop
Atualizar
' Atualizar
' Atualizar
End Function --------------------------------------------------------
Public Sub Atualiza(n As Integer)
Dim cont As Integer For cont = 1 To n
Atualizar
Next cont End Sub --------------------------------------------------------
Dim i As Integer
i = 0
Do While i < 20
HllFunctionNo = 4
HllData = ""
HllLength = 0
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode HllFunctionNo = 8
HllLength = 1920
HllData = space(HllLength)
HllReturnCode = 0
hllapi& HllFunctionNo, HllData, HllLength, HllReturnCode
Tela = Left(HllData & Space(1920), 1920)
i = i + 1
Loop
End Sub
Primeira msg box:
Receber arquivo (pw3270.exe:3064):GLib-GIO-ERROR**:No GSettings schemas are installed on the system Enviar arquivo (pw3270.exe:4064):GLib-GIO-ERROR**:No GSettings schemas are installed on the system Segunda msg box: this application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Trava do sistema: Detalhes: Assinatura do problema:
Nome do Evento de Problema: APPCRASH
Nome do Aplicativo: pw3270.exe
Versão do Aplicativo: 0.0.0.0
Carimbo de Data/Hora do Aplicativo: 5091a6a9
Nome do Módulo de Falhas: libglib-2.0-0.dll
Versão do Módulo de Falhas: 2.32.4.0
Carimbo de Data/Hora do Módulo de Falhas: 50450cf1
Código de Exceção: 40000015
Deslocamento de Exceção: 00038667
Versão do sistema operacional: 6.1.7601.2.1.0.256.48
Identificação da Localidade: 1046
Informações Adicionais 1: 14b4
Informações Adicionais 2: 14b40b94241087619e797edae7a1cc70
Informações Adicionais 3: 0b83
Informações Adicionais 4: 0b832cc1a5ba4ba10901871c54c66ff9 Leia nossa declaração de privacidade online:
go.microsoft.com/fwlink/?linkid=104288&clcid=0x0416 Se a declaração de privacidade online não estiver disponível, leia nossa declaração de privacidade offline:
C:\Windows\system32\pt-BR\erofflps.txt