Como Puedo Capturar Una Imagen En Visual Basic

Quiero Capturar Una Pantalla En Visual Basic De Un Equipo Remoto Y Traerla A Mi Equipo Por Winsock y guardala en un archivo
Ah también tengo otro problema no puedo abrir bases de datos en formato access 2000 en vb6 porque alguien que me ayude
mi mail es [email protected]

1 respuesta

Respuesta
1
Te explico como lo tengo yo :
Tengo un programa en mi computadora y otro en el que quiero sacar la pantalla y tengo un control en mi programa que se llama sockpantalla y en el del cliente igual bueno voy a tratar de ponerte el código en secuencia voy intercalar el código de los dos programas para que veas como es el orden.. y en otra respuesta te pongo el código separado por equipo (Esto es cuando ya tienes el código de conexión y los equipos ya conectados):
MIPC - (Envio Peticion de Datos):
Private Sub Mnu_ObtenPantalla_Click()
sockPantalla.Close
If sockPantalla.State = 7 Then
sockPantalla.SendData "Obtener Pantalla"
ElseIf sockPantalla.State = 9 Then
MsgBox "Error en socket...", vbInformation, App.EXEName
End If
End Sub
CLIENTE - (Recibe Peticion Procesa y Envia) :
Private Sub sockPantalla_DataArrival(Index As Integer, ByVal bytesTotal As Long)
On Error GoTo ManejaError
Dim Datos As String
Dim Contador As Integer
sockPantalla(Index).GetData Datos
Contador = 0
If UCase(Datos) = UCase("Obtener Pantalla") Then
Picture1.Picture = LoadPicture()
Do
keybd_event 44, 1, 0&, 0&
Picture1.Picture = Clipboard.GetData
Loop Until Picture1.Picture <> 0
Call GuardarBinary(Picture1, Index)
Clipboard.Clear
End If
Exit Sub
ManejaError:
Select Case Err
Case 0
Case 521
Contador = Contador + 1
If Contador >= 15 Then
sockPantalla(Index).SendData "NADA"
Exit Sub
End If
Resume
Case Else
MsgBox "Ha ocurrido un evento no esperado con mensaje " & Err & " - " & Error(Err), vbCritical, App.EXEName
Exit Sub
End Select
End Sub
MIPC - (Recibe Informacion y Guarda en Archivo):
Private Sub sockPantalla_DataArrival(ByVal bytesTotal As Long)
Dim MaxArreglo As Long
Dim ContArr As Long
Dim DatosImg() As Byte
Dim ContDatos As Long
Dim DatosVar() As Byte
Dim Slide As Long
Dim Porcentaje As Double
ReDim DatosVar(bytesTotal)
BytesRecibidos = BytesRecibidos + bytesTotal
sockPantalla.GetData DatosVar, vbArray + vbByte
If UBound(DatosVar) >= 3 Then
If DatosVar(0) = 78 And DatosVar(1) = 65 And DatosVar(2) = 68 And DatosVar(3) = 65 Then
MsgBox "No se pudo Obtener Imagen de Pantalla Actual"
Exit Sub
End If
End If
If Recibir = False Then
'Formulario para Barra de Desplazamiento
frmProcesoPantalla.Show
Datafile = FreeFile
Open App.Path & "\PicTemp.bmp" For Binary Access Write As Datafile
Recibir = True
If UBound(DatosVar) > 3 Then
total = Val("&H" & Hex(DatosVar(4)) & Format(Hex(DatosVar(3)), "00") & Hex(DatosVar(2)))
End If
End If
'****Esta parte es para presentar un barra de desplazamiento
'****Crea un formulación de nombre frmprocesopantalla con un picturebox de nombre PicObt que contenga un picturebox de nombre PicSlideObt
Slide = CDbl(frmProcesoPantalla.PicSlideObt.Width) * CDbl((BytesRecibidos / total))
Porcentaje = (BytesRecibidos / total) * 100
If Porcentaje >= 100 Then
Porcentaje = 100
End If
Posslide = Slide
frmProcesoPantalla.PicSlideObt.Line (0, 0)-(Posslide, frmProcesoPantalla.PicSlideObt.Height), vbBlue, BF
frmProcesoPantalla.PicSlideObt.Refresh
frmProcesoPantalla.PicSlideObt.Cls
frmProcesoPantalla.PicSlideObt.Line (0, 0)-(Posslide, frmProcesoPantalla.PicSlideObt.Height), vbBlue, BF
frmProcesoPantalla.PicSlideObt.CurrentX = (frmProcesoPantalla.PicSlideObt.ScaleWidth
Creo que no cupo la respuesta te la vuelvo a enviar...
Te explico como lo tengo yo :
Tengo un programa en mi computadora y otro en el que quiero sacar la pantalla y tengo un control en mi programa que se llama sockpantalla y en el del cliente igual bueno voy a tratar de ponerte el código en secuencia voy intercalar el código de los dos programas para que veas como es el orden.. y en otra respuesta te pongo el código separado por equipo (Esto es cuando ya tienes el código de conexión y los equipos ya conectados):
MIPC - (Envio Peticion de Datos):
Private Sub Mnu_ObtenPantalla_Click()
sockPantalla.Close
If sockPantalla.State = 7 Then
sockPantalla.SendData "Obtener Pantalla"
ElseIf sockPantalla.State = 9 Then
MsgBox "Error en socket...", vbInformation, App.EXEName
End If
End Sub
CLIENTE - (Recibe Peticion Procesa y Envia) :
Private Sub sockPantalla_DataArrival(ByVal bytesTotal As Long)
On Error GoTo ManejaError
Dim Datos As String
Dim Contador As Integer
sockPantalla.GetData Datos
Contador = 0
If UCase(Datos) = UCase("Obtener Pantalla") Then
Picture1.Picture = LoadPicture()
Do
keybd_event 44, 1, 0&, 0&
Picture1.Picture = Clipboard.GetData
Loop Until Picture1.Picture <> 0
Call GuardarBinary(Picture1)
Clipboard.Clear
End If
Exit Sub
ManejaError:
Select Case Err
Case 0
Case 521
Contador = Contador + 1
If Contador >= 15 Then
sockPantalla.SendData "NADA"
Exit Sub
End If
Resume
Case Else
MsgBox "Ha ocurrido un evento no esperado con mensaje " & Err & " - " & Error(Err), vbCritical, App.EXEName
Exit Sub
End Select
End Sub
MIPC - (Recibe Informacion y Guarda en Archivo):
Private Sub sockPantalla_DataArrival(ByVal bytesTotal As Long)
Dim MaxArreglo As Long
Dim ContArr As Long
Dim DatosImg() As Byte
Dim ContDatos As Long
Dim DatosVar() As Byte
Dim Slide As Long
Dim Porcentaje As Double
ReDim DatosVar(bytesTotal)
BytesRecibidos = BytesRecibidos + bytesTotal
sockPantalla.GetData DatosVar, vbArray + vbByte
If UBound(DatosVar) >= 3 Then
If DatosVar(0) = 78 And DatosVar(1) = 65 And DatosVar(2) = 68 And DatosVar(3) = 65 Then
MsgBox "No se pudo Obtener Imagen de Pantalla Actual"
Exit Sub
End If
End If
If Recibir = False Then
'Formulario para Barra de Desplazamiento
frmProcesoPantalla.Show
Datafile = FreeFile
Open App.Path & "\PicTemp.bmp" For Binary Access Write As Datafile
Recibir = True
If UBound(DatosVar) > 3 Then
total = Val("&H" & Hex(DatosVar(4)) & Format(Hex(DatosVar(3)), "00") & Hex(DatosVar(2)))
End If
End If
'****Esta parte es para presentar un barra de desplazamiento
'****Crea un formulación de nombre frmprocesopantalla con un picturebox de nombre PicObt que contenga un picturebox de nombre PicSlideObt
Slide = CDbl(frmProcesoPantalla.PicSlideObt.Width) * CDbl((BytesRecibidos / total))
Porcentaje = (BytesRecibidos / total) * 100
If Porcentaje >= 100 Then
Porcentaje = 100
End If
Posslide = Slide
frmProcesoPantalla.PicSlideObt.Line (0, 0)-(Posslide, frmProcesoPantalla.PicSlideObt.Height), vbBlue, BF
frmProcesoPantalla.PicSlideObt.Refresh
frmProcesoPantalla.PicSlideObt.Cls
frmProcesoPantalla.PicSlideObt.Line (0, 0)-(Posslide, frmProcesoPantalla.PicSlideObt.Height), vbBlue, BF
frmProcesoPantalla.PicSlideObt.CurrentX = (frmProcesoPantalla.PicSlideObt.ScaleWidth - frmProcesoPantalla.PicSlideObt.TextWidth("Obteniendo Imagen " & Format(Porcentaje, "#0.00") & "%")) / 2
frmProcesoPantalla.PicSlideObt.CurrentY = (frmProcesoPantalla.PicSlideObt.ScaleHeight - frmProcesoPantalla.PicSlideObt.TextHeight("Obteniendo Imagen " & Format(Porcentaje, "#0.00") & "%")) / 2
frmProcesoPantalla.PicSlideObt.Print "Obteniendo Imagen " & Format(Porcentaje, "#0.00") & "%"
frmProcesoPantalla.PicSlideObt.Refresh
'********************
'********************
If UBound(DatosVar) > 0 Then
Put Datafile, , DatosVar
End If
If Porcentaje >= 100 Or total <= BytesRecibidos Then
Porcentaje = 0
BytesRecibidos = 0
If UBound(DatosVar) = 0 Then
Close Datafile
End If
Msgbox "Listo Imagen Guardada...",vbInformation,App.exeName
End If
End Sub
Espero te Sirva .
En cuanto a tu problema de las bd entra a el menu de proyecto y luego referencias y busca :
Microsoft DAO 3.6 Object Library
El siguiente es el código del procedimiento GuardarBinary :
'General
Dim Datafile As Integer
Dim Chunk() As Byte
Const conChunkSize As Integer = 16384
Public Sub GuardarBinary(unPicture As Object)
On Error GoTo ManejaError
Dim Contador As Integer
Dim Fragment As Integer, F1 As Long, Chunks As Integer
SavePicture unPicture.Picture, "pictemp"
Datafile = FreeFile
Open "pictemp" For Binary Access Read As Datafile
F1 = LOF(Datafile)
If F1 = 0 Then Close Datafile: Exit Sub
Chunks = F1 / conChunkSize
Fragment = F1 Mod conChunkSize
ReDim Chunk(Fragment)
Get Datafile,, Chunk()
SockPantalla. SendData Chunk()
ReDim Chunk(conChunkSize)
For Contador = 1 To Chunks
Get Datafile,, Chunk
SockPantalla. SendData Chunk()
DoEvents
Next Contador
Close Datafile
On Local Error Resume Next
If Len(Dir$("pictemp")) Then
Kill "PicTemp"
End If
Err = 0
ManejaError:
Select Case Err
Case 0
Case Else
MsgBox "Ha ocurrido un evento no esperado con mensaje " & Err & " - " & Error(Err), vbCritical, App.EXEName
Exit Sub
End Select
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas