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


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


  Mostrar Mensajes
Páginas: 1 ... 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 [720] 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 ... 1254
7191  Programación / .NET (C#, VB.NET, ASP) / Re: Clickar a un color en: 11 Julio 2014, 14:01 pm
Aquí os dejo una versión mejorada y extendida de lo anterior, por si a alguien le sirve:

Código
  1. ' ***********************************************************************
  2. ' Author           : Elektro
  3. ' Last Modified On : 07-11-2014
  4. ' ***********************************************************************
  5. ' <copyright file="PixelUtil.vb" company="Elektro Studios">
  6. '     Copyright (c) Elektro Studios. All rights reserved.
  7. ' </copyright>
  8. ' ***********************************************************************
  9.  
  10. #Region " Usage Examples "
  11.  
  12.  
  13. ' **************************************************
  14. ' Count the number of Pixels that contains the image
  15. ' **************************************************
  16. '
  17. '' Create a new bitmap.
  18. 'Dim bmp As Bitmap = Bitmap.FromFile("C:\DesktopScreenshot.bmp", False)
  19. '
  20. '' Instance a PixelUtil Class.
  21. 'Dim bmpPixelUtil As New PixelUtil(bmp)
  22. '
  23. '' Display the pixel count.
  24. 'MessageBox.Show(String.Format("Total amount of Pixels: {0}", CStr(bmpPixelUtil.PixelCount)))
  25.  
  26.  
  27. ' ************************************************
  28. ' Searchs for an specific pixel color in the image
  29. ' ************************************************
  30. '
  31. '' Create a new bitmap.
  32. 'Dim bmp As Bitmap = Bitmap.FromFile("C:\DesktopScreenshot.bmp", False)
  33. '
  34. '' Instance a PixelUtil Class.
  35. 'Dim bmpPixelUtil As New PixelUtil(bmp)
  36. '
  37. '' Specify the RGB PixelColor to search.
  38. 'Dim FindColor As Color = Color.FromArgb(255, 174, 201)
  39. '
  40. '' Get the pixel data.
  41. 'Dim FoundPixels As List(Of PixelUtil.PixelData) = bmpPixelUtil.SearchColor(FindColor)
  42. '
  43. '' Loop through each pixel.
  44. 'For Each Pixel As PixelUtil.PixelData In FoundPixels
  45. '
  46. '    Dim sb As New System.Text.StringBuilder
  47. '    With sb
  48. '
  49. '        .AppendLine(String.Format("Index: {0}", CStr(Pixel.Index)))
  50. '        .AppendLine(String.Format("Coord: {0}", Pixel.Coordinates.ToString))
  51. '
  52. '        MessageBox.Show(.ToString, "Pixel-Color Search")
  53. '
  54. '        .Clear()
  55. '
  56. '    End With
  57. '
  58. 'Next Pixel
  59.  
  60.  
  61. ' *********************************************************************
  62. ' Retrieve the index, color, and coordinates of each pixel in the image
  63. ' *********************************************************************
  64. '
  65. '' Create a new bitmap.
  66. 'Dim bmp As Bitmap = Bitmap.FromFile("C:\DesktopScreenshot.bmp", False)
  67. '
  68. '' Instance a PixelUtil Class.
  69. 'Dim bmpPixelUtil As New PixelUtil(bmp)
  70. '
  71. '' Get the pixel data.
  72. 'Dim Pixels As List(Of PixelUtil.PixelData) = bmpPixelUtil.GetPixelData()
  73. '
  74. '' Loop through each pixel.
  75. 'For Each Pixel As PixelUtil.PixelData In Pixels
  76. '
  77. '    Dim sb As New System.Text.StringBuilder
  78. '    With sb
  79. '
  80. '        .AppendLine(String.Format("Index: {0}", CStr(Pixel.Index)))
  81. '        .AppendLine(String.Format("Color: {0}", Pixel.Color.ToString))
  82. '        .AppendLine(String.Format("Coord: {0}", Pixel.Coordinates.ToString))
  83. '
  84. '        MessageBox.Show(.ToString, "Pixel Search")
  85. '
  86. '        .Clear()
  87. '
  88. '    End With
  89. '
  90. 'Next Pixel
  91.  
  92.  
  93. ' ****************************************************************************
  94. ' Retrieve the index, color, and coordinates of a range of pixels in the image
  95. ' ****************************************************************************
  96. '
  97. '' Create a new bitmap.
  98. 'Dim bmp As Bitmap = Bitmap.FromFile("C:\DesktopScreenshot.bmp", False)
  99. '
  100. '' Instance a PixelUtil Class.
  101. 'Dim bmpPixelUtil As New PixelUtil(bmp)
  102. '
  103. '' Specify the pixel range to retrieve.
  104. 'Dim RangeMin As Integer = 1919I
  105. 'Dim RangeMax As Integer = 1921I
  106. '
  107. '' Get the pixel data.
  108. 'Dim FoundPixels As List(Of PixelUtil.PixelData) = bmpPixelUtil.GetPixelData(RangeMin, RangeMax)
  109. '
  110. '' Loop through each pixel.
  111. 'For Each Pixel As PixelUtil.PixelData In FoundPixels
  112. '
  113. '    Dim sb As New System.Text.StringBuilder
  114. '    With sb
  115. '
  116. '        .AppendLine(String.Format("Index: {0}", CStr(Pixel.Index)))
  117. '        .AppendLine(String.Format("Color: {0}", Pixel.Color.ToString))
  118. '        .AppendLine(String.Format("Coord: {0}", Pixel.Coordinates.ToString))
  119. '
  120. '        MessageBox.Show(.ToString, "Pixel-Color Search")
  121. '
  122. '        .Clear()
  123. '
  124. '    End With
  125. '
  126. 'Next Pixel
  127.  
  128.  
  129. #End Region
  130.  
  131. #Region " Imports "
  132.  
  133. Imports System.ComponentModel
  134. Imports System.Drawing.Imaging
  135. Imports System.Runtime.InteropServices
  136.  
  137. #End Region
  138.  
  139. #Region " PixelUtil "
  140.  
  141. Public Class PixelUtil
  142.  
  143. #Region " Vars, Properties "
  144.  
  145.    Private _PixelData As List(Of PixelData) = Nothing
  146.    Private _bmp As Bitmap = Nothing
  147.    Private _PixelCount As Integer = Nothing
  148.  
  149.    ''' <summary>
  150.    ''' Gets the Bitmap object.
  151.    ''' </summary>
  152.    ''' <value>The BMP.</value>
  153.    Public ReadOnly Property bmp As Bitmap
  154.        Get
  155.            Return Me._bmp
  156.        End Get
  157.    End Property
  158.  
  159.    ''' <summary>
  160.    ''' Gets the total amount of pixels that contains the Bitmap.
  161.    ''' </summary>
  162.    ''' <value>The pixel count.</value>
  163.    Public ReadOnly Property PixelCount As Integer
  164.        Get
  165.            Return Me._PixelCount
  166.        End Get
  167.    End Property
  168.  
  169. #End Region
  170.  
  171. #Region " Classes "
  172.  
  173.    ''' <summary>
  174.    ''' Stores specific pixel information of an image.
  175.    ''' </summary>
  176.    Public Class PixelData
  177.  
  178.        ''' <summary>
  179.        ''' Gets or sets the pixel index.
  180.        ''' </summary>
  181.        ''' <value>The pixel index.</value>
  182.        Public Property Index As Integer
  183.  
  184.        ''' <summary>
  185.        ''' Gets or sets the pixel color.
  186.        ''' </summary>
  187.        ''' <value>The pixel color.</value>
  188.        Public Property Color As Color
  189.  
  190.        ''' <summary>
  191.        ''' Gets or sets the pixel coordinates relative to the image.
  192.        ''' </summary>
  193.        ''' <value>The pixel coordinates.</value>
  194.        Public Property Coordinates As Point
  195.  
  196.    End Class
  197.  
  198. #End Region
  199.  
  200. #Region " Constructors "
  201.  
  202.    ''' <summary>
  203.    ''' Prevents a default instance of the <see cref="PixelUtil"/> class from being created.
  204.    ''' </summary>
  205.    Private Sub New()
  206.    End Sub
  207.  
  208.    ''' <summary>
  209.    ''' Initializes a new instance of the <see cref="PixelUtil"/> class.
  210.    ''' </summary>
  211.    ''' <param name="bmp">Indicates the Bitmap image to process it's pixels.</param>
  212.    ''' <exception cref="System.Exception">PixelFormat unsupported.</exception>
  213.    Public Sub New(ByVal bmp As Bitmap)
  214.  
  215.        If Not bmp.PixelFormat = PixelFormat.Format24bppRgb Then
  216.            Throw New Exception("PixelFormat unsupported.")
  217.        End If
  218.  
  219.        Me._bmp = bmp
  220.        Me._PixelCount = Me.[Count]
  221.  
  222.    End Sub
  223.  
  224. #End Region
  225.  
  226. #Region " Public Methods "
  227.  
  228.    ''' <summary>
  229.    ''' Returns a <c>'PixelData'</c> object containing information about each pixel in the image.
  230.    ''' </summary>
  231.    ''' <returns>List(Of PixelData).</returns>
  232.    Public Function GetPixelData() As List(Of PixelData)
  233.  
  234.        If Me._PixelData Is Nothing Then
  235.  
  236.            Me._PixelData = New List(Of PixelData)
  237.  
  238.            ' Lock the Bitmap bits.
  239.            Dim bmpRect As New Rectangle(0, 0, Me._bmp.Width, Me._bmp.Height)
  240.            Dim bmpData As BitmapData = Me._bmp.LockBits(bmpRect, ImageLockMode.ReadWrite, Me._bmp.PixelFormat)
  241.  
  242.            ' Get the address of the first line.
  243.            Dim Pointer As IntPtr = bmpData.Scan0
  244.  
  245.            ' Hold the bytes of the bitmap into a Byte-Array.
  246.            ' NOTE: This code is specific to a bitmap with 24 bits per pixels.
  247.            Dim bmpBytes As Integer = (Math.Abs(bmpData.Stride) * bmpRect.Height)
  248.            Dim rgbData(bmpBytes - 1) As Byte
  249.  
  250.            ' Copy the RGB values into the array.
  251.            Marshal.Copy(Pointer, rgbData, 0, bmpBytes)
  252.  
  253.            ' Unlock the Bitmap bits.
  254.            Me._bmp.UnlockBits(bmpData)
  255.  
  256.            ' Loop through each 24bpp-RGB value.
  257.            For rgbIndex As Integer = 2 To rgbData.Length - 1 Step 3
  258.  
  259.                ' Set the pixel Data.
  260.                Dim Pixel As New PixelData
  261.  
  262.                With Pixel
  263.  
  264.                    .Index = rgbIndex \ 3I
  265.  
  266.                    .Color = Color.FromArgb(red:=rgbData(rgbIndex),
  267.                                            green:=rgbData(rgbIndex - 1I),
  268.                                            blue:=rgbData(rgbIndex - 2I))
  269.  
  270.                    .Coordinates = New Point(X:=(.Index Mod bmpRect.Width),
  271.                                             Y:=(.Index - (.Index Mod bmpRect.Width)) \ bmpRect.Width)
  272.  
  273.                End With
  274.  
  275.                ' Add the PixelData into the list.
  276.                Me._PixelData.Add(Pixel)
  277.  
  278.            Next rgbIndex
  279.  
  280.        End If
  281.  
  282.        Return Me._PixelData
  283.  
  284.    End Function
  285.  
  286.    ''' <summary>
  287.    ''' Returns a <c>'PixelData'</c> object containing information about a range of pixels in the image.
  288.    ''' </summary>
  289.    ''' <returns>List(Of PixelData).</returns>
  290.    ''' <exception cref="System.Exception">Pixel index is out of range</exception>
  291.    Public Function GetPixelData(ByVal RangeMin As Integer,
  292.                                 ByVal RangeMax As Integer) As List(Of PixelData)
  293.  
  294.        If Not (Me._PixelCount >= RangeMin AndAlso Me._PixelCount <= RangeMax) Then
  295.            Throw New Exception("Pixel index is out of range.")
  296.            Return Nothing
  297.        End If
  298.  
  299.        ' Return the Pixel range.
  300.        Return (From Pixel As PixelData In Me.GetPixelData()
  301.                Where (Pixel.Index >= RangeMin AndAlso Pixel.Index <= RangeMax)).ToList
  302.  
  303.    End Function
  304.  
  305.    ''' <summary>
  306.    ''' Searchs for the specified pixel-color inside the image and returns all the matches.
  307.    ''' </summary>
  308.    ''' <param name="PixelColor">Indicates the color to find.</param>
  309.    ''' <returns>List(Of PixelData).</returns>
  310.    Public Function SearchColor(ByVal PixelColor As Color) As List(Of PixelData)
  311.  
  312.        Return (From Pixel As PixelData In Me.GetPixelData
  313.                Where Pixel.Color = PixelColor).ToList
  314.  
  315.    End Function
  316.  
  317. #End Region
  318.  
  319. #Region " Private Methods "
  320.  
  321.    ''' <summary>
  322.    ''' Counts the number of pixels that contains the image.
  323.    ''' </summary>
  324.    ''' <returns>The number of pixels.</returns>
  325.    Private Function [Count]() As Integer
  326.  
  327.        ' Lock the Bitmap bits.
  328.        Dim bmpRect As New Rectangle(0, 0, Me._bmp.Width, Me._bmp.Height)
  329.        Dim bmpData As BitmapData = Me._bmp.LockBits(bmpRect, ImageLockMode.ReadWrite, Me._bmp.PixelFormat)
  330.  
  331.        ' Get the address of the first line.
  332.        Dim Pointer As IntPtr = bmpData.Scan0
  333.  
  334.        ' Hold the bytes of the bitmap into a Byte-Array.
  335.        ' NOTE: This code is specific to a bitmap with 24 bits per pixels.
  336.        Dim bmpBytes As Integer = (Math.Abs(bmpData.Stride) * bmpRect.Height)
  337.        Dim rgbData(bmpBytes - 1) As Byte
  338.  
  339.        ' Copy the RGB values into the array.
  340.        Marshal.Copy(Pointer, rgbData, 0, bmpBytes)
  341.  
  342.        ' Unlock the Bitmap bits.
  343.        Me._bmp.UnlockBits(bmpData)
  344.  
  345.        Return rgbData.Count
  346.  
  347.    End Function
  348.  
  349. #End Region
  350.  
  351. #Region " Hidden Methods "
  352.  
  353.    ''' <summary>
  354.    ''' Serves as a hash function for a particular type.
  355.    ''' </summary>
  356.    <EditorBrowsable(EditorBrowsableState.Never)>
  357.    Public Shadows Sub GetHashCode()
  358.    End Sub
  359.  
  360.    ''' <summary>
  361.    ''' Determines whether the specified System.Object is equal to the current System.Object.
  362.    ''' </summary>
  363.    <EditorBrowsable(EditorBrowsableState.Never)>
  364.    Public Shadows Sub Equals()
  365.    End Sub
  366.  
  367.    ''' <summary>
  368.    ''' Returns a String that represents the current object.
  369.    ''' </summary>
  370.    <EditorBrowsable(EditorBrowsableState.Never)>
  371.    Public Shadows Sub ToString()
  372.    End Sub
  373.  
  374. #End Region
  375.  
  376. End Class
  377.  
  378. #End Region
7192  Programación / .NET (C#, VB.NET, ASP) / Re: Clickar a un color en: 10 Julio 2014, 09:10 am
Te hago la mitad del trabajo, ahora, para ubicar las coordenadas relativas a la imagen por el momento no se me ocurre el modo de hacerlo, pero algo se podrá hacer obteniendo el índice del pixel encontrado (cosa que hago) usandola en alguna fórmula aritmética con el ancho y alto de la imagen.

Public Class PixelData
        Public Index As Integer
        Public Color As Color
        Public Coordinates As Point
    End Class

    Friend Function GetPixelData(ByVal bmp As Bitmap) As List(Of PixelData)

        If Not bmp.PixelFormat = Imaging.PixelFormat.Format24bppRgb Then
            Throw New Exception("PixelFormat no soportado en esta función.")
        End If

        ' Lock the bitmap's bits.  
        Dim rect As New Rectangle(0, 0, bmp.Width, bmp.Height)
        Dim bmpdata As Drawing.Imaging.BitmapData =
            bmp.LockBits(rect, Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat)

        ' Get the address of the first line.
        Dim ptr As IntPtr = bmpdata.Scan0

        ' Declare an array to hold the bytes of the bitmap.
        ' This code is specific to a bitmap with 24 bits per pixels.
        Dim bytes As Integer = Math.Abs(bmpdata.Stride) * bmp.Height
        Dim rgbValues(bytes - 1) As Byte

        ' Copy the RGB values into the array.
        Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes)

        ' Unlock the bits.
        bmp.UnlockBits(bmpdata)

        ' Set the Data to return.
        Dim Pixels As New List(Of PixelData)

        ' Loop through each 24bpp-RGB value.
        For Index As Integer = 2 To rgbValues.Length - 1 Step 3

            Pixels.Add(New PixelData With
                       {
                           .Index = Index \ 3I,
                           .Color = Color.FromArgb(rgbValues(Index), rgbValues(Index - 1I), rgbValues(Index - 2I)),
                           .Coordinates = Point.Empty
                       })

        Next Index

        Return Pixels

    End Function


EDITO: Fórmula encontrada.

Nota: Lo he testeado con una imagen a resolución 2560x1600, el retorno de datos es practicamente instantaneo, la búsqueda puede variar según lo lejos que se encuentre el pixel en la iteración.

Código
  1.    ''' <summary>
  2.    ''' Stores specific pixel information of an image.
  3.    ''' </summary>
  4.    Friend Class PixelData
  5.  
  6.        ''' <summary>
  7.        ''' Gets or sets the pixel index.
  8.        ''' </summary>
  9.        ''' <value>The pixel index.</value>
  10.        Public Property Index As Integer
  11.  
  12.        ''' <summary>
  13.        ''' Gets or sets the pixel color.
  14.        ''' </summary>
  15.        ''' <value>The pixel color.</value>
  16.        Public Property Color As Color
  17.  
  18.        ''' <summary>
  19.        ''' Gets or sets the pixel coordinates relative to the image.
  20.        ''' </summary>
  21.        ''' <value>The pixel coordinates.</value>
  22.        Public Property Coordinates As Point
  23.  
  24.    End Class
  25.  
  26.    ''' <summary>
  27.    ''' Returns a <c>'PixelData'</c> object containing information about each pixel of an image.
  28.    ''' </summary>
  29.    ''' <param name="bmp">Indicates the Bitmap image to process.</param>
  30.    ''' <returns>List(Of PixelData).</returns>
  31.    ''' <exception cref="System.Exception">PixelFormat unsupported.</exception>
  32.    Friend Function GetPixelData(ByVal bmp As Bitmap) As List(Of PixelData)
  33.  
  34.        If Not bmp.PixelFormat = Imaging.PixelFormat.Format24bppRgb Then
  35.            Throw New Exception("PixelFormat unsupported.")
  36.        End If
  37.  
  38.        ' Lock the Bitmap bits.
  39.        Dim bmpRect As New Rectangle(0, 0, bmp.Width, bmp.Height)
  40.        Dim bmpData As Drawing.Imaging.BitmapData =
  41.            bmp.LockBits(bmpRect, Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat)
  42.  
  43.        ' Get the address of the first line.
  44.        Dim Pointer As IntPtr = bmpData.Scan0
  45.  
  46.        ' Hold the bytes of the bitmap into a Byte-Array.
  47.        ' NOTE: This code is specific to a bitmap with 24 bits per pixels.
  48.        Dim bmpBytes As Integer = (Math.Abs(bmpData.Stride) * bmpRect.Height)
  49.        Dim rgbData(bmpBytes - 1) As Byte
  50.  
  51.        ' Copy the RGB values into the array.
  52.        Runtime.InteropServices.Marshal.Copy(Pointer, rgbData, 0, bmpBytes)
  53.  
  54.        ' Unlock the Bitmap bits.
  55.        bmp.UnlockBits(bmpData)
  56.  
  57.        ' Instance the object to return.
  58.        Dim Pixels As New List(Of PixelData)
  59.  
  60.        ' Loop through each 24bpp-RGB value.
  61.        For rgbIndex As Integer = 2 To rgbData.Length - 1 Step 3
  62.  
  63.            ' Get the pixel values.
  64.            Dim PixelIndex As Integer = rgbIndex \ 3I
  65.            Dim PixelCoordX As Integer = PixelIndex Mod bmpRect.Width
  66.            Dim PixelCoordY As Integer = (PixelIndex - PixelCoordX) \ bmpRect.Width
  67.            Dim PixelColorR As Short = rgbData(rgbIndex)
  68.            Dim PixelColorG As Short = rgbData(rgbIndex - 1I)
  69.            Dim PixelColorB As Short = rgbData(rgbIndex - 2I)
  70.  
  71.            ' Set the pixel Data.
  72.            Dim Pixel As New PixelData
  73.            With Pixel
  74.                .Index = PixelIndex
  75.                .Color = Color.FromArgb(PixelColorR, PixelColorG, PixelColorB)
  76.                .Coordinates = New Point(PixelCoordX, PixelCoordY)
  77.            End With
  78.  
  79.            ' Add the PixelData into the list.
  80.            Pixels.Add(Pixel)
  81.  
  82.        Next rgbIndex
  83.  
  84.        Return Pixels
  85.  
  86.    End Function

Ejemplo de uso:

Código
  1.    Public Sub Test() Handles Button1.Click
  2.  
  3.        ' Create a new bitmap.
  4.        Dim bmp As Bitmap = Bitmap.FromFile("Imagen de la pantalla.bmp", False)
  5.  
  6.        ' Specify the RGB PixelColor to search.
  7.        Dim FindColor As Color = Color.FromArgb(255, 174, 201)
  8.  
  9.        ' Get the pixel data.
  10.        Dim Pixels As List(Of PixelData) = Me.GetPixelData(bmp)
  11.  
  12.        ' Loop through each pixel.
  13.        For Each Pixel As PixelData In Pixels
  14.  
  15.            If Pixel.Color.Equals(FindColor) Then
  16.  
  17.                Dim sb As New System.Text.StringBuilder
  18.                With sb
  19.  
  20.                    .AppendLine(String.Format("Index: {0}", CStr(Pixel.Index)))
  21.                    .AppendLine(String.Format("Color: {0}", Pixel.Color.ToString))
  22.                    .AppendLine(String.Format("Coord: {0}", Pixel.Coordinates.ToString))
  23.  
  24.                    MessageBox.Show(.ToString, "Pixel Search")
  25.  
  26.                    .Clear()
  27.  
  28.                End With
  29.  
  30.            End If
  31.  
  32.        Next Pixel
  33.  
  34.    End Sub

Saludos
7193  Informática / Hardware / Re: ¿ Cooler bueno, económico, y silencioso para CPU AMD Socket AM3+ ? en: 9 Julio 2014, 14:58 pm
Bueno, necesitaba una respuesta rápida (por miedo a que el problema fuese a mayores) y como no he podido obtener la ayuda que necesitaba, ya me respondo a mi mismo.

Al final, basandome en los comentarios de varios productos, he decidido comprado un Cooler Master Hyper 212 EVO.



Me podría haber permitido comprar un Cooler más caro, pero sin haber obtenido una opinión experta pues...tampoco voy a arriesgarme sin saber si hacia bien o mal, lo caro no siempre resulta mejor.

PD: Si alquien quiere que le cuente mi experiencia sobre el producto, después de haberlo instalado, que lo comente y con gusto le describiré los detalles.

Saludos!
7194  Informática / Hardware / Re: Duda pasta térmica en: 9 Julio 2014, 14:49 pm
alguna vez has tenido que leer algo parecido a lo que preguntabas.

Es posible, pero a aquello que creemos que no necesitamos aprender, o que directamente no nos interesa leer pues no le hacemos mucho caso y se olvida...
Además, yo no navego por los sub-foros de Hardware ni leo preguntas de ese estilo porque se que no puedo aportar ninguna ayuda.

PD: Gracias por decirme como limpiar la pasta, porque ya iba a preguntarlo xD.

Saludos!
7195  Informática / Hardware / Re: Duda pasta térmica en: 9 Julio 2014, 14:31 pm
@Electro, ¿A estas alturas, esto lo dices en serio........?  :rolleyes: :rolleyes: :rolleyes:

¿De que alturas estás hablando?, me doy cuenta que he sido un poco cazurro al hacer una pregunta tan básica (para quien sepa, claro), pero no lo veo motivo de burla, nunca se me ha dado bien el tema de Hardware, y simplemente me da miedo estropear un material tan... "sensible".

Gracias @engel lex y @Simorg

Saludos!
7196  Informática / Hardware / Duda pasta térmica en: 9 Julio 2014, 12:37 pm
Hola

Tengo una duda muy básica, ¿la paste térmica, se pone encima de la pasta ya existente?, ¿sin más?.

Es decir, yo me he comprado un AMD que tiene su pasta térmica puesta ya de serie (como es obvio xD) con su ventilador y tal encima, bien, yo me he comprado un ventildor para reemplazar el de serie, que además trae pasta térmica, y yo sé desanclar y montar un ventilador de CPU, pero no se nada al respecto de la pasta térmica, osea de la capa blanca del disipador (porque pasta térmica / disipador es lo mismo no?), ¿es tan sencillo como echar una capa por encima de la pasta que ya trae puesta el chipset?, ¿y como cuanta cantidad de debe poner?, no la quiero cagar, vaya, ¿pasaría algo grave si pongo demasiada pasta sin querer?.

Necesito palabras textuales que me aclaren esta duda, pero además de esto me gustaria que alguien pudiera compartir un video donde enseñen el montaje correcto de la pasta térmica (fotos no, porfavor, que ya vi unas cuantas y sigo sin aclararme).

Gracias por leer,
Esaludos!
7197  Programación / .NET (C#, VB.NET, ASP) / Re: Texto en richtextbox en: 9 Julio 2014, 11:38 am
Hay que tener en cuenta que el método sugerido por @engel lex, "ScrollToCaret", como su propio nombre indica lo único que hace es deslizar el ScrollBar hasta la posición del Caret (el Caret es el cursor de texto) así que usarlo por si solo no sería una solución viable según que caso, ya que si no modificas la posición del Caret, siempre va a escrollear a la misma posición

Si estás usando el método "AppendText" para adjuntar texto:
Código
  1. RichTextBox1.AppendText("Texto")
Entonces una llamada a "ScrollToCaret" será suficiente, porque el método "AppendText", además de adjuntar texto, pone la posición del Caret al final del texto adjuntado.

Por otro lado, si estás adjuntando texto de esta manera:
Código
  1. RichTextBox1.Text &= "Texto"
Entonces necesitas modificar manualmente la posición del Caret, para poder Scrollear hacia abajo.

Por eso, según el caso, te sugiero una de las siguientes soluciones, aunque de todas formas la última solución deberías evitarla siempre que puedas, ya que lo correcto es usar el método "AppendText":

· .AppendText:
Código
  1.    Private Sub RichTextBox_AutoScroll(ByVal sender As Object, ByVal e As EventArgs) _
  2.    Handles RichTextBox1.TextChanged
  3.  
  4.        If CBool(sender.TextLength) Then
  5.            sender.ScrollToCaret()
  6.        End If
  7.  
  8.    End Sub

· .Text &=
Código
  1.    Private Sub RichTextBox_AutoScroll(ByVal sender As Object, ByVal e As EventArgs) _
  2.    Handles RichTextBox1.TextChanged
  3.  
  4.        Dim _TextLength As Integer = sender.TextLength
  5.  
  6.        With sender
  7.  
  8.            If CBool(_TextLength) Then
  9.  
  10.                .SelectionStart = _TextLength
  11.                .ScrollToCaret()
  12.  
  13.            End If
  14.  
  15.        End With
  16.  
  17.    End Sub

Nota: Obviamente, si piensas escribir manualmente en el Control, entonces la solución con el método ".Text &=" de poco sirve. ya que estoy enviando el Caret al final del texto, siempre.

Saludos
7198  Programación / .NET (C#, VB.NET, ASP) / Re: Enviar texto de un richtextbox a un e-mail en: 8 Julio 2014, 22:45 pm
No especificas muchos datos, ni si pretendes abrir el cliente de correo predeterminado, o si lo quieres enviar usando solo código, ni con que servicio de correo POP3 o SMTP...

Ejemplo:

Código
  1.    ' GMailSender("Username@Gmail.com", "Password", "Email Subject", "Message Body", "Destiny@Address.com")
  2.  
  3.    Private Function GMailSender(ByVal sername As String, ByVal Password As String, ByVal Subject As String, ByVal Body As String, ByVal DestinyAddress As String) As Boolean
  4.        Try
  5.            Dim MailSetup As New System.Net.Mail.MailMessage
  6.            MailSetup.Subject = Subject
  7.            MailSetup.To.Add(DestinyAddress)
  8.            MailSetup.From = New System.Net.Mail.MailAddress(Username)
  9.            MailSetup.Body = Body
  10.            Dim SMTP As New System.Net.Mail.SmtpClient("smtp.gmail.com")
  11.            SMTP.Port = 587
  12.            SMTP.EnableSsl = True
  13.            SMTP.Credentials = New Net.NetworkCredential(Username, Password)
  14.            SMTP.Send(MailSetup)
  15.            Return True ' Email is sent OK
  16.        Catch ex As Exception
  17.            Throw New Exception(ex.Message)
  18.        End Try
  19.    End Function

En C#:
http://converter.telerik.com/

Saludos.
7199  Foros Generales / Dudas Generales / Re: ¿Qué son estos símbolos? en: 8 Julio 2014, 09:19 am
&#61687;&#61687;&#61687;&#61687;&#61687;&#61687

Son caracteres escapados de HTML: http://www.theukwebdesigncompany.com/articles/entity-escape-characters.php

Cada entidad corresponde a un caracter especifico y este se interpreta por el navegador (si no me equivoco), los puedes decodificar aquí: http://www.web2generators.com/html/entities
"&#61687" = ""

Sobre el caracter decodificado de la tecla "F0-F7" () aquí tienes info: http://www.htmlescape.net/f0/character_f0f7.html

PD: Cuando vi tu duda el otro día, iba a responderte para decirte que parecia que se tratase de un problema de decodificación de caracteres Unicode, pero luego le hice zoom al texto y me di cuenta de que no parece un error, al menos a mi no me lo parece, y más ahora que has aclarado que son caracteres escapados,es decir que los caracteres que se indican mostrar desde el source son esos, las teclas F0-F12 etc, no se porque razón ...supongo que el misterio se resolvería sabiendo de donde obtuviste el texto xD.

Saludos
7200  Programación / .NET (C#, VB.NET, ASP) / Re: REDUCIR CÓDIGO.NET en: 8 Julio 2014, 09:04 am
1. No estás liberando el FolderBrowserDialog que instancias.

Código
  1.    Private Sub btnexaminar_Click(sender As Object, e As EventArgs) Handles btnexaminar.Click
  2.  
  3.        Using Dir As New FolderBrowserDialog
  4.  
  5.            If Dir.ShowDialog = DialogResult.OK Then
  6.                TextBox1.Text = Dir.SelectedPath
  7.            End If
  8.  
  9.        End Using
  10.  
  11.    End Sub

2. Reducción de código de Botones:



Código
  1.    Private CMDThread As Threading.Thread = Nothing
  2.  
  3.    Friend ReadOnly Property MiDirectorio As String
  4.        Get
  5.            Return TextBox1.Text
  6.        End Get
  7.    End Property
  8.  
  9.    Private Sub btndat_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btndat.Click
  10.  
  11.        Me.CMDThread = New Threading.Thread(AddressOf Me.CMDAutomate)
  12.        Me.CopyFile("C:\Program Files\convert data\runpkr00.exe", IO.Path.Combine(Me.MiDirectorio, "\runpkr00.exe"))
  13.        CMDThread.Start()
  14.  
  15.    End Sub
  16.  
  17.    Private Sub btnrinex_Click(sender As Object, e As EventArgs) Handles btnrinex.Click
  18.  
  19.        Me.CMDThread = New Threading.Thread(AddressOf Me.CMDAutomaterin)
  20.        Me.CopyFile("C:\Program Files\convert data\teqc.exe", IO.Path.Combine(Me.MiDirectorio, "\teqc.exe"))
  21.        Me.CMDThread.Start()
  22.  
  23.    End Sub
  24.  
  25.    Private Sub btntqc_Click(sender As Object, e As EventArgs) Handles btntqc.Click
  26.  
  27.        Me.CMDThread = New Threading.Thread(AddressOf Me.CMDAutomateqc)
  28.        Me.CopyFile("C:\Program Files\convert data\teqc.exe", IO.Path.Combine(Me.MiDirectorio, "\teqc.exe"))
  29.        Me.CMDThread.Start()
  30.  
  31.    End Sub
  32.  
  33.    Private Sub CopyFile(ByVal sourcefile As String, ByVal destinationfile As String)
  34.  
  35.        If String.IsNullOrEmpty(Me.MiDirectorio) Then
  36.            MessageBox.Show("Debe seleccionar la ruta donde se encuentra la data", "Error",
  37.                            MessageBoxButtons.OKCancel, MessageBoxIcon.Error)
  38.  
  39.        Else
  40.            My.Computer.FileSystem.CopyFile(sourcefile, destinationfile,
  41.                                            FileIO.UIOption.OnlyErrorDialogs,
  42.                                            FileIO.UICancelOption.DoNothing)
  43.  
  44.        End If
  45.  
  46.    End Sub
  47.  

3. Reducción de código de Procesos

Eliminar todo esto repetido:
Código:
        Dim myprocess As New Process
        Dim StartInfo As New System.Diagnostics.ProcessStartInfo
        StartInfo.FileName = "cmd"
        StartInfo.RedirectStandardInput = True
        StartInfo.RedirectStandardOutput = True
        StartInfo.UseShellExecute = False
        StartInfo.CreateNoWindow = True
        myprocess.StartInfo = StartInfo

por:

Código
  1.    Friend MyProcess As New Process With
  2.    {
  3.        .StartInfo = New ProcessStartInfo With
  4.                     {
  5.                         .FileName = "cmd",
  6.                         .RedirectStandardInput = True,
  7.                         .RedirectStandardOutput = True,
  8.                         .UseShellExecute = False,
  9.                         .CreateNoWindow = True
  10.                     }
  11.    }

PD: Aun se puede simplificar más, tanto los botones como las tareas de los threads, pero creo que con eso ya te basta :P.

Saludos
Páginas: 1 ... 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 [720] 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 ... 1254
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines