elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


  Mostrar Mensajes
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 [13] 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ... 32
121  Programación / Programación Visual Basic / Re: Consola por pipe crashea en windows 8 y versiones adelantadas en: 7 Abril 2016, 19:31 pm
Pues yo no entiendo no papa XD
122  Programación / Programación Visual Basic / Re: Evitar la seleccion de la camara web en: 7 Abril 2016, 19:05 pm
Mi teoría es que  la función llama a capCreateCaptureWindowA para obtener el handle (hwnd) y posteriormente se manda el mensaje para conectar pero el paso de uno al otro es demasiado rápido, casi simultáneo y se intenta conectar ANTES de haber recibido el handle o preparar el dispositivo, yo que se  :P.

Una solución podría ser crear una espera entre un proceso y el otro

Por ejemplo:


Código
  1. Do
  2. hHwnd = capCreateCaptureWindowA(strDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, 480, Picture1.hwnd, 0)
  3. DoEvents
  4. Loop While hwnd = 0

O mejor:

Código
  1.  
  2. '//...
  3. Private Sub Espera(Segundos As Single)
  4.  Dim ComienzoSeg As Single
  5.  Dim FinSeg As Single
  6.  ComienzoSeg = Timer
  7.  FinSeg = ComienzoSeg + Segundos
  8.  Do While FinSeg > Timer
  9.      DoEvents
  10.      If ComienzoSeg > Timer Then
  11.          FinSeg = FinSeg - 24 * 60 * 60
  12.      End If
  13.  Loop
  14. End Sub
  15.  
  16.  
  17. '//Conecta la cámara
  18. Private Sub ConectarCamara()
  19.  
  20. '//Activa la webcam
  21. hHwnd = capCreateCaptureWindowA(strDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, 480, Picture1.hWnd, 0)
  22.  
  23. Espera (2) '///<---Esperar dos segundos antes de conectar
  24.  
  25. Dim Retry As Boolean, I As Integer
  26.  
  27. For I = 1 To 10 '//Hace diez intentos para conectar
  28. Retry = SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, IndexDevice, 0)
  29.  
  30.    If Retry = True Then
  31.        SendMessage hHwnd, WM_CAP_SET_SCALE, False, 0
  32.        SendMessage hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0
  33.        SendMessage hHwnd, WM_CAP_SET_PREVIEW, True, 0
  34.  
  35.        SetWindowPos hHwnd, HWND_BOTTOM, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, _
  36.        SWP_NOMOVE Or SWP_NOZORDER
  37.  
  38.        cmdGuardar.Enabled = True
  39.        cmdDesconectar.Enabled = True
  40.        cmdConectar.Enabled = False
  41.        Exit For
  42.    End If
  43. Next I
  44.  
  45. If Retry = False Then
  46.        DestroyWindow hHwnd
  47.        cmdGuardar.Enabled = False
  48. End If
  49.  
  50. End Sub
  51.  
  52.  
  53. '//...
  54.  
  55.  




Me he basado en las respuestas de este otro usuario que tenía el mismo problema:

http://stackoverflow.com/questions/10721085/webcam-video-source-dialog-comes-up


Código:
...

2
down vote
Finally I Found a solution for this.
The problem happens in Windows 7 / 8

First you need this API function

Private Declare Function GetTickCount Lib "kernel32" () As Long
Then... after you call capCreateCaptureWindowA() you have to wait 1 second processing events, (note: sleep don't work the same)

IniTime = GetTickCount()
While GetTickCount() < (IniTime + 1000)
   DoEvents
Wend
then you call WM_CAP_DRIVER_CONNECT (maybe a couple of times).. and THAT's IT ... no more video source dialog

'...

With this solution it works perfect. The GetTickCount() waiting for events worked along with calling the function until it returned true.

Private Sub PreviewVideo(ByVal pbCtrl As PictureBox)    
    hWnd = capCreateCaptureWindowA(VideoSource, WS_VISIBLE Or WS_CHILD, 0, 0, 0,
   0, pbCtrl.Handle.ToInt64, 0)    
    Dim IniTime As Long = GetTickCount()
    While GetTickCount() < (IniTime + 1000)
        Application.DoEvents()
    End While    
    Dim OKAnswer As Boolean = False
    For xretries As Integer = 1 To 10
          ' I'll give you Only 10 tries to connect, otherwise I AM LEAVING MICROSOFT!
          OKAnswer = SendMessage(hWnd, WM_CAP_DRIVER_CONNECT, VideoSource, 0)
          If OKAnswer Then
              Exit For
          End If    
    Next    
    If okanswer Then
          SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0)
          SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 30, 0)
          SendMessage(hWnd, WM_CAP_SET_PREVIEW, True, 0)
          SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, pbCtrl.Width, pbCtrl.Height, SWP_NOMOVE Or SWP_NOZORDER)    
    Else
          DestroyWindow(hWnd)    
    End If    
End Sub

Claro que esto es en Net
123  Programación / .NET (C#, VB.NET, ASP) / Re: Tabla html con net en: 7 Abril 2016, 16:29 pm
Gracias Elektro  ;-)

Ahora mismo estaba buscando ejemplos en g'u'gle. Me has ahorrado el trabajo, o gran parte.  


s2s



(Aunque aquí podríamos tener el problema que ya comentamos... con system.web.dll)
124  Programación / .NET (C#, VB.NET, ASP) / Re: Pregunta Boba / como pasar registros desde un listbox a variables en: 7 Abril 2016, 15:42 pm
Lo que no entiendo es por qué no usas este otro código que te pasó Elektro y que modifiqué para 6 números y para que no hubieran correlativos.

Todas las combinaciones:

Código
  1.        Dim intCol As New List(Of Integer)({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.OfType(Of Integer))
  2.  
  3.        Dim pairsCol As IEnumerable(Of String) = Nothing
  4.  
  5.        pairsCol =
  6.            From value1 As Integer In intCol
  7.            From value2 As Integer In intCol
  8.            From value3 As Integer In intCol
  9.            From value4 As Integer In intCol
  10.            From value5 As Integer In intCol
  11.            Select String.Join(Environment.NewLine, (
  12.                               From value6 As Integer In intCol
  13.                                  Where (value1 <> value2) AndAlso
  14.                                        (value1 <> value3) AndAlso
  15.                                        (value1 <> value4) AndAlso
  16.                                        (value1 <> value5) AndAlso
  17.                                        (value1 <> value6) AndAlso
  18.                                        (value2 <> value3) AndAlso
  19.                                        (value2 <> value4) AndAlso
  20.                                        (value2 <> value5) AndAlso
  21.                                        (value2 <> value6) AndAlso
  22.                                        (value3 <> value4) AndAlso
  23.                                        (value3 <> value5) AndAlso
  24.                                        (value3 <> value6) AndAlso
  25.                                        (value4 <> value5) AndAlso
  26.                                        (value4 <> value6) AndAlso
  27.                                        (value5 <> value6) AndAlso
  28.                                        (value2 > value1) AndAlso
  29.                                        (value3 > value2) AndAlso
  30.                                        (value4 > value3) AndAlso
  31.                                        (value5 > value4) AndAlso
  32.                                        (value6 > value5)
  33.                                  Select String.Format("{0:00} {1:00} {2:00} {3:00} {4:00} {5:00}",
  34.                                                       value1, value2, value3, value4, value5, value6)))
  35.  
  36.  
  37.        For Each pairs As String In pairsCol
  38.            For Each line As String In pairs.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
  39.                ListBox1.Items.Add(line)
  40.            Next line
  41.  
  42.        Next pairs
  43.  
  44.  



Combinaciones SIN todos los  números correlativos

Código
  1.      Dim intCol As New List(Of Integer)({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.OfType(Of Integer))
  2.  
  3.        Dim pairsCol As IEnumerable(Of String) = Nothing
  4.  
  5.        pairsCol =
  6. From value1 As Integer In intCol
  7. From value2 As Integer In intCol
  8. From value3 As Integer In intCol
  9. From value4 As Integer In intCol
  10. From value5 As Integer In intCol
  11. Select String.Join(Environment.NewLine, (
  12.              From value6 As Integer In intCol
  13.                 Where (value1 <> value2) AndAlso
  14.                       (value1 <> value3) AndAlso
  15.                       (value1 <> value4) AndAlso
  16.                       (value1 <> value5) AndAlso
  17.                       (value1 <> value6) AndAlso
  18.                       (value2 <> value3) AndAlso
  19.                       (value2 <> value4) AndAlso
  20.                       (value2 <> value5) AndAlso
  21.                       (value2 <> value6) AndAlso
  22.                       (value3 <> value4) AndAlso
  23.                       (value3 <> value5) AndAlso
  24.                       (value3 <> value6) AndAlso
  25.                       (value4 <> value5) AndAlso
  26.                       (value4 <> value6) AndAlso
  27.                       (value5 <> value6) AndAlso
  28.                       (value2 > value1) AndAlso
  29.                       (value3 > value2) AndAlso
  30.                       (value4 > value3) AndAlso
  31.                       (value5 > value4) AndAlso
  32.                       (value6 > value5)
  33.                 Select String.Format("{0:00} {1:00} {2:00} {3:00} {4:00} {5:00}",
  34.                                      value1, value2, value3, value4, value5, value6)))
  35.  
  36.  
  37.        For Each pairs As String In pairsCol
  38.            For Each line As String In pairs.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
  39.                Dim Pattern As String = " "
  40.                Dim Digito() As String
  41.                Digito = System.Text.RegularExpressions.Regex.Split(line, Pattern)
  42.  
  43.                        If CInt(Digito(1)) <> CInt(Digito(0)) + 1 Or
  44.                                CInt(Digito(2)) <> CInt(Digito(1)) + 1 Or
  45.                                    CInt(Digito(3)) <> CInt(Digito(2)) + 1 Or
  46.                                     CInt(Digito(4)) <> CInt(Digito(3)) + 1 Or
  47.                                       CInt(Digito(5)) <> CInt(Digito(4)) + 1 Then
  48.                    ListBox1.Items.Add(line)
  49.  
  50.                End If
  51.            Next line
  52.  
  53.        Next pairs



Pero no me queda claro como pasar cada Item a Integer.

Este ejemplo, al final va obteniendo los números y crea una array cuyos items son los números de una combinación pero no se como se podría crear otro array con cada array ?¿?¿?¿

Código
  1.        Dim intCol As New List(Of Integer)({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.OfType(Of Integer))
  2.  
  3.        Dim pairsCol As IEnumerable(Of String) = Nothing
  4.  
  5.        pairsCol =
  6. From value1 As Integer In intCol
  7. From value2 As Integer In intCol
  8. From value3 As Integer In intCol
  9. From value4 As Integer In intCol
  10. From value5 As Integer In intCol
  11. Select String.Join(Environment.NewLine, (
  12.              From value6 As Integer In intCol
  13.                 Where (value1 <> value2) AndAlso
  14.                       (value1 <> value3) AndAlso
  15.                       (value1 <> value4) AndAlso
  16.                       (value1 <> value5) AndAlso
  17.                       (value1 <> value6) AndAlso
  18.                       (value2 <> value3) AndAlso
  19.                       (value2 <> value4) AndAlso
  20.                       (value2 <> value5) AndAlso
  21.                       (value2 <> value6) AndAlso
  22.                       (value3 <> value4) AndAlso
  23.                       (value3 <> value5) AndAlso
  24.                       (value3 <> value6) AndAlso
  25.                       (value4 <> value5) AndAlso
  26.                       (value4 <> value6) AndAlso
  27.                       (value5 <> value6) AndAlso
  28.                       (value2 > value1) AndAlso
  29.                       (value3 > value2) AndAlso
  30.                       (value4 > value3) AndAlso
  31.                       (value5 > value4) AndAlso
  32.                       (value6 > value5)
  33.                 Select String.Format("{0:00} {1:00} {2:00} {3:00} {4:00} {5:00}",
  34.                                      value1, value2, value3, value4, value5, value6)))
  35.  
  36.  
  37.        For Each pairs As String In pairsCol
  38.            For Each line As String In pairs.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
  39.                Dim Pattern As String = " "
  40.                Dim Digito() As String
  41.                Digito = System.Text.RegularExpressions.Regex.Split(line, Pattern)
  42.  
  43.                        If CInt(Digito(1)) <> CInt(Digito(0)) + 1 Or
  44.                                CInt(Digito(2)) <> CInt(Digito(1)) + 1 Or
  45.                                    CInt(Digito(3)) <> CInt(Digito(2)) + 1 Or
  46.                                     CInt(Digito(4)) <> CInt(Digito(3)) + 1 Or
  47.                                       CInt(Digito(5)) <> CInt(Digito(4)) + 1 Then
  48.                    ListBox1.Items.Add(line)
  49.  
  50.                End If
  51.            Next line
  52.  
  53.        Next pairs
  54.  
  55.        '//Esto solo crea un array con la última combinación.
  56.       '//En realidad lo hace con todas pero solo queda registrada la última
  57.       '//¿Habría que hacer una colección de arrays?
  58.        Dim NuevaLista As New List(Of String)(ListBox1.Items.OfType(Of String))
  59.        Dim int32Col As IEnumerable(Of Integer) = Nothing
  60.  
  61.        For Each item As String In NuevaLista
  62.            int32Col = From Elemento As String In item.Split(" "c) Select CInt(Elemento)
  63.        Next
  64.  
  65.        'Los números de la última combinación
  66.        MessageBox.Show(int32Col(0).ToString)
  67.        MessageBox.Show(int32Col(1).ToString)
  68.        MessageBox.Show(int32Col(2).ToString)
  69.        MessageBox.Show(int32Col(3).ToString)
  70.        MessageBox.Show(int32Col(4).ToString)
  71.        MessageBox.Show(int32Col(5).ToString)
  72.  


FALTABA UN:

Código:
(value5 <> value6) AndAlso

Ya lo he puesto  :¬¬
125  Programación / .NET (C#, VB.NET, ASP) / Tabla html con net en: 7 Abril 2016, 14:38 pm
Hola

¿Hay alguna clase o función en Net para crear tablas Html?. Mi idea es crear una tabla HTML a partir de datos de un datagridview o ListView.

Lo que yo he hecho por ahora es algo como lo siguiente:

Código
  1.  
  2.        Dim builder As New System.Text.StringBuilder
  3.        With builder
  4.            .AppendLine("<table border=""1"" style=""border-collapse: collapse;"">")
  5.            .AppendLine("<caption>Leyenda</caption>")
  6.            .AppendLine("<tbody>")
  7.            .AppendLine("<tr>")
  8.            .AppendLine(String.Format("<td>{0}</td>", "Celda1"))
  9.            .AppendLine(String.Format("<td>{0}</td>", "Celda2"))
  10.            .AppendLine("</tr>")
  11.            .AppendLine("<tr>")
  12.            .AppendLine(String.Format("<td>{0}</td>", "Celda3"))
  13.            .AppendLine(String.Format("<td>{0}</td>", "Celda4"))
  14.            .AppendLine("</tr>")
  15.            .AppendLine("</tbody>")
  16.            .AppendLine("</table>")
  17.        End With
  18.  


Pero es muy tedioso



He encontrado algo que puede ser lo que busco.

HtmlTable Class

del system.web.dll


Código
  1. Imports System.Web.UI.HtmlControls
  2.  
  3. Public Class Form1
  4.  
  5.    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.  
  7.        Dim i As Integer
  8.        Dim j As Integer
  9.        Dim Table1 As HtmlTable
  10.        Dim row As HtmlTableRow
  11.        Dim cell As HtmlTableCell
  12.  
  13.       '//...
  14.    End Sub
  15. End Class
126  Programación / .NET (C#, VB.NET, ASP) / Re: Pregunta Boba / como pasar registros desde un listbox a variables en: 7 Abril 2016, 14:10 pm
Pero no sería pasarlo a integer, sino crear una colección o matriz interpretando cada elemento de una cadena de texto distinto de " " como integer. De ahí el uso que le das de Split


Al parecer tiene dos códigos, uno que le pasé yo y otro el tuyo Elektro. El cual estará como lo acabas de poner. Y quiere usar los dos en el mismo proyecto
127  Programación / .NET (C#, VB.NET, ASP) / Re: Pregunta Boba / como pasar registros desde un listbox a variables en: 7 Abril 2016, 13:40 pm
No se, como no sea que quites los espacios a "AA BB CC DD..." y quede "AABBCCDD". Pero entonces no aceptaría Integer porque saldrían números muy grandes como 102030444546 y no se acepta como Integer, si no como Double.

Código
  1.      ListBox1.Items.Add("01 02 03 04 05 06")
  2.        ListBox1.Items.Add("10 20 30 44 45 46")
  3.        ListBox1.Items.Add("12 22 34 45 56 65")
  4.        ListBox1.Items.Add("12 22 34 45 56 65")
  5.  
  6.  
  7.        Dim Pattern As String = " "
  8.        Dim Digito() As String
  9.  
  10.        '//Mete los Items del ListBox en ClearList
  11.        Dim ClearList As New List(Of String)(ListBox1.Items.OfType(Of String))
  12.        For Each Item As String In ClearList
  13.            Digito = System.Text.RegularExpressions.Regex.Split(Item, Pattern)
  14.            If CInt(Digito(1)) = CInt(Digito(0)) + 1 And
  15.                 CInt(Digito(2)) = CInt(Digito(1)) + 1 And
  16.                     CInt(Digito(3)) = CInt(Digito(2)) + 1 And
  17.                        CInt(Digito(4)) = CInt(Digito(3)) + 1 And
  18.                           CInt(Digito(5)) = CInt(Digito(4)) + 1 Then
  19.  
  20.                ListBox1.Items.Remove(Item) '<-----Borra un Item del ListBox
  21.            End If
  22.        Next
  23.  
  24.  
  25.        ClearList.Clear() '//Borra  ClearList
  26.        ClearList.AddRange(ListBox1.Items.OfType(Of String)) '//Consigue la nueva lista del ListBox
  27.  
  28.        Dim NuevaLista As New List(Of Double)
  29.        For Each Item As String In ClearList
  30.            NuevaLista.Add(Item.Replace(" ", Nothing))
  31.        Next
  32.  
  33.        MessageBox.Show(NuevaLista(0).ToString)
  34.        MessageBox.Show(NuevaLista(1).ToString)
  35.  
  36.  



Rectifico mi comentario "no se puede meter cadenas string a integer", por si alguien me regaña...

A ver si el string es un número, entonce sí:

Código:
Dim Cadena as string = "12345"
Dim Numero as Integer = Cadena

también con el singo "-" delante indicando negatividad.
Código:
       
Dim Cadena As String = "-12345"
Dim Numero As Integer = Cadena

Pero si tiene carácteres distintos a un número tal como Espacio, coma, "x", "&" o letras por ejemplo pues entonces creo que no. A no ser que combiertas la cadena de texto a byte o algo así, no se, no he probado.

128  Programación / .NET (C#, VB.NET, ASP) / Re: Pregunta Boba / como pasar registros desde un listbox a variables en: 7 Abril 2016, 13:19 pm
Código:
no se puede pasar el codigo entero a integer ? 

¿Es esta la pregunta?
"Entero a integer"  es lo mismo XD.

No fuera bromas. No se a que te refieres

Es como querer pasar

Código:
 Dim txtCadena as String = "La patata boba" 

a Integer.
129  Programación / Programación Visual Basic / Re: Consola por pipe crashea en windows 8 y versiones adelantadas en: 7 Abril 2016, 13:00 pm
Jajajaja, en VB6 o en cualquier otro lenguaje se usan las mismas funciones... Pero vamos que si insistes y tienes mucho interés lo programo.

Saludos.

El problema no es que tenga las mismas funciones o no. El problema está en saber interpretar el código ASM y saber lo suficiente en VB para pasar de uno a otro. Y además  concretamente lo que pide illuminat3d. Pienso yo vamos XD. No es pos fastidiar.
130  Programación / .NET (C#, VB.NET, ASP) / Re: Pregunta Boba / como pasar registros desde un listbox a variables en: 7 Abril 2016, 12:52 pm
Repito. No puedes meter cadenas de texto 'string' en integer.

De hecho, según ese código (que me suena un poco  :xD) ya  tienes el ejemplo de como meter el ListBox en una variable...

Código
  1. Dim ClearList As New List(Of String)(ListBox1.Items.OfType(Of String))

Lo que hace el código, es meter la lista pura del ListBox (que son cadenas string) en la variable ClearList   que es un List(of T) que es un array.  
Luego en el For Each repasa cada Item del ClearList y si cumple las condiciones borra los Items del ListBox que las cumpla.


Ahora, si quieres meterlo en una variable, llamada por ejemplo 'NuevaLista', tan solo lo  has de meter otra vez como antes:
Código:
 Dim NuevaLista As New List(Of String)(ListBox1.Items.OfType(Of String))

Y ya lo tienes metido. Pero como String, claro. Porque algo como esto --> "01 02 03 04 05 06" es string e incluso Object, pero no integer

Código
  1.        ListBox1.Items.Add("01 02 03 04 05 06")
  2.        ListBox1.Items.Add("10 20 30 44 45 46")
  3.        ListBox1.Items.Add("12 22 34 45 56 65")
  4.        ListBox1.Items.Add("12 22 34 45 56 65")
  5.  
  6.  
  7.        Dim Pattern As String = " "
  8.        Dim Digito() As String
  9.  
  10.        '//Mete los Items del ListBox en ClearList
  11.        Dim ClearList As New List(Of String)(ListBox1.Items.OfType(Of String))
  12.        For Each Item As String In ClearList
  13.            Digito = System.Text.RegularExpressions.Regex.Split(Item, Pattern)
  14.            If CInt(Digito(1)) = CInt(Digito(0)) + 1 And
  15.                 CInt(Digito(2)) = CInt(Digito(1)) + 1 And
  16.                     CInt(Digito(3)) = CInt(Digito(2)) + 1 And
  17.                       CInt(Digito(4)) = CInt(Digito(3)) + 1 And
  18.                         CInt(Digito(5)) = CInt(Digito(4)) + 1  Then
  19.  
  20.                ListBox1.Items.Remove(Item) '<-----Borra un Item del ListBox
  21.            End If
  22.        Next
  23.        '//Mete la nueva lista en NewList
  24.        Dim NuevaLista As New List(Of String)(ListBox1.Items.OfType(Of String))
  25.        NuevaLista = NuevaLista.Distinct.ToList '//Quita Items repetidos
  26.        MessageBox.Show(NuevaLista(0).ToString)
  27.        MessageBox.Show(NuevaLista(1).ToString)
  28.  

Pero como te comenté no soy experto en NET, pero por lo que sé, yo lo veo así.

s2s



había un condición repetida dos veces, ya lo he quitado :
Código:
CInt(Digito(5)) = CInt(Digito(4)) + 1 

Bueno, no es solo que estuviera repetido.. es que faltaba uno, el :
Código:
CInt(Digito(4)) = CInt(Digito(3)) + 1

ya que supongo que es para quitar combinaciones con todos los números correlativos
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 [13] 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ... 32
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines