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


Tema destacado: Los 10 CVE más críticos (peligrosos) de 2020


  Mostrar Mensajes
Páginas: 1 ... 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 [818] 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 ... 1254
8171  Programación / Scripting / Re: Sobre archivos .Bat en: 14 Octubre 2013, 15:23 pm
For /F

-> http://ss64.com/nt/for_f.html

Código:
For /F %%X in ('Ver') Do ()...

Saludos
8172  Programación / Scripting / Re: cambiar icono de archivo .vbs en: 14 Octubre 2013, 11:31 am
Cualquier icono de extensión de archivo se puede modificar mediante el registro, pero esa técnica no sirve para lo que el usuario necesita, porque implica estas cosas:

1. Disponer de un archivo de icono por separado, es decir, el archivo VBS y el archivo ICO (o depender de un archivo del sistema de Windows, las DLL de Windows contienen todos los iconos del sistema)

2. Ejecutar el código necesario para modificar el registro, es decir, habría que ejecutar un script en la máquina para modificar la ruta del icono de la extensión del archivo, en el registro.

3. Disponer de permisos de usuario para poder modificar claves del registro.

4. Reiniciar el PC o reiniciar Explorer y posíblemente vaciar la caché de iconos para que los cambios surgan efecto al instante.

El usuario habla de modificar el archivo de forma permanente sin realizar otros cambios, símplemente mover el archivo a otro PC y que tenga el icono, y eso requiere convertirlo a executable, que es el que puede almacenar el recurso de icono que deseemos.

Saludos!
8173  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 14 Octubre 2013, 07:14 am
Añadir la funcionalidad 'Find Next' y 'Find Previous' en un RichTextBox,
Le añadi soporte para poder utilizar expresiones regulares y también para poder resaltar el text seleccionado en colores :).



Código
  1. #Region " [RichTextBox] FindNext "
  2.  
  3.    ' [ FindNext ]
  4.    '
  5.    ' //By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    '
  9.    ' RichTextBox1.Text = "Hello World!, Hello World!, Hello World!"
  10.    '
  11.    ' FindNext(RichTextBox1, "hello", FindDirection.Down, RegexOptions.IgnoreCase, Color.LightBlue, Color.Black)
  12.    ' FindNext(RichTextBox1, "hello", FindDirection.Up, RegexOptions.IgnoreCase, Color.Red, Color.Black)
  13.    '
  14.    ' Private Sub RichTextBox_Enter(sender As Object, e As EventArgs) ' Handles RichTextBox1.Enter
  15.    '    ' Restore Selection Colors before search next match.
  16.    '    sender.SelectionBackColor = DefaultBackColor
  17.    '    sender.SelectionColor = DefaultForeColor
  18.    ' End Sub
  19.  
  20.    Public Enum FindDirection
  21.        Up = 0
  22.        Down = 1
  23.    End Enum
  24.  
  25.    ' FindNext
  26.    Private Sub FindNext(ByVal [Control] As RichTextBox, _
  27.                               ByVal SearchText As String, _
  28.                               ByVal Direction As FindDirection, _
  29.                               Optional ByVal IgnoreCase As System.Text.RegularExpressions.RegexOptions = RegexOptions.None, _
  30.                               Optional ByVal Highlight_BackColor As Color = Nothing, _
  31.                               Optional ByVal Highlight_ForeColor As Color = Nothing)
  32.  
  33.        If [Control].TextLength = 0 Then Exit Sub
  34.  
  35.        ' Start searching at 'SelectionStart'.
  36.        Dim Search_StartIndex As Integer = [Control].SelectionStart
  37.  
  38.        ' Stores the MatchIndex count
  39.        Dim matchIndex As Integer = 0
  40.  
  41.        ' Flag to check if it's first find call
  42.        Static First_Find As Boolean = True
  43.  
  44.        ' Checks to don't ommit the selection of first match if match index is exactly at 0 start point.
  45.        If First_Find _
  46.            AndAlso Search_StartIndex = 0 _
  47.            AndAlso Direction = FindDirection.Down Then
  48.            Search_StartIndex = -1
  49.            First_Find = False
  50.        ElseIf Not First_Find _
  51.            AndAlso Search_StartIndex = 0 _
  52.            AndAlso Direction = FindDirection.Down Then
  53.            First_Find = False
  54.            Search_StartIndex = 0
  55.        End If
  56.  
  57.        ' Store the matches
  58.        Dim matches As System.Text.RegularExpressions.MatchCollection = _
  59.            System.Text.RegularExpressions.Regex.Matches([Control].Text, _
  60.                                                         SearchText, _
  61.                                                         IgnoreCase Or If(Direction = FindDirection.Up, _
  62.                                                                          RegexOptions.RightToLeft, _
  63.                                                                          RegexOptions.None))
  64.  
  65.        If matches.Count = 0 Then First_Find = True : Exit Sub
  66.  
  67.        ' Restore Highlight colors of previous selection
  68.        [Control].SelectionBackColor = [Control].BackColor
  69.        [Control].SelectionColor = [Control].ForeColor
  70.  
  71.        ' Set next selection Highlight colors
  72.        If Highlight_BackColor = Nothing Then Highlight_BackColor = [Control].BackColor
  73.        If Highlight_ForeColor = Nothing Then Highlight_ForeColor = [Control].ForeColor
  74.  
  75.        ' Set the match selection
  76.        For Each match As System.Text.RegularExpressions.Match In matches
  77.  
  78.            matchIndex += 1
  79.  
  80.            Select Case Direction
  81.  
  82.                Case FindDirection.Down
  83.                    If match.Index > Search_StartIndex Then ' Select next match
  84.                        [Control].Select(match.Index, match.Length)
  85.                        Exit For
  86.                    ElseIf match.Index <= Search_StartIndex _
  87.                    AndAlso matchIndex = matches.Count Then ' Select first match
  88.                        [Control].Select(matches.Item(0).Index, matches.Item(0).Length)
  89.                        Exit For
  90.                    End If
  91.  
  92.                Case FindDirection.Up
  93.                    If match.Index < Search_StartIndex Then ' Select previous match
  94.                        [Control].Select(match.Index, match.Length)
  95.                        Exit For
  96.                    ElseIf match.Index >= Search_StartIndex _
  97.                    AndAlso matchIndex = matches.Count Then ' Select last match
  98.                        [Control].Select(matches.Item(0).Index, matches.Item(0).Length)
  99.                        Exit For
  100.                    End If
  101.  
  102.            End Select
  103.  
  104.        Next match
  105.  
  106.        ' Set the current selection BackColor
  107.        [Control].SelectionBackColor = Highlight_BackColor
  108.        ' Set the current selection ForeColor
  109.        [Control].SelectionColor = Highlight_ForeColor
  110.        ' Scroll to Caret/Cursor selection position
  111.        [Control].ScrollToCaret()
  112.  
  113.    End Sub
  114.  
  115. #End Region


EDITO:

Aquí dejo una versión alternativa, no soporta RegEx y no soporta búsqueda hacia arriba,
el código no es peor, símplemente si no se requiere el uso de búsqueda por RegEx ni buscar hacia arriba entonces es preferible usar este snippet.

Código
  1. #Region " [RichTextBox] FindNext String "
  2.  
  3.    ' [ FindNext String ]
  4.    '
  5.    ' //By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    '
  9.    ' FindNext(RichTextBox1, "Hello", RichTextBoxFinds.MatchCase, Color.LightBlue, Color.Black)
  10.    '
  11.    ' Private Sub RichTextBox_Enter(sender As Object, e As EventArgs) ' Handles RichTextBox1.Enter
  12.    '    ' Restore Selection Colors before search next match.
  13.    '    sender.SelectionBackColor = DefaultBackColor
  14.    '    sender.SelectionColor = DefaultForeColor
  15.    ' End Sub
  16.  
  17.    ' FindNext
  18.    Private Sub FindNext(ByVal [Control] As RichTextBox, _
  19.                        ByVal SearchText As String, _
  20.                        ByVal IgnoreCase As RichTextBoxFinds, _
  21.                        Optional ByVal Highlight_BackColor As Color = Nothing, _
  22.                        Optional ByVal Highlight_ForeColor As Color = Nothing)
  23.  
  24.        ' Start searching at 'SelectionStart'.
  25.        Dim Search_StartIndex As Integer = [Control].SelectionStart
  26.        Static Next_Count As Integer = 0
  27.  
  28.        ' Restore Highlight colors of previous selection
  29.        [Control].SelectionBackColor = [Control].BackColor
  30.        [Control].SelectionColor = [Control].ForeColor
  31.  
  32.        ' Set next selection Highlight colors
  33.        If Highlight_BackColor = Nothing Then Highlight_BackColor = [Control].BackColor
  34.        If Highlight_ForeColor = Nothing Then Highlight_ForeColor = [Control].ForeColor
  35.  
  36.        ' If is not first FindNext call then...
  37.        If Next_Count <> 0 Then
  38.            Search_StartIndex += SearchText.Length
  39.        Else ' If is first FindNext call then...
  40.            Next_Count += 1
  41.        End If
  42.  
  43.        ' Set Search_StartIndex
  44.        Search_StartIndex = _
  45.        [Control].Find(SearchText, Search_StartIndex, IgnoreCase)
  46.        ' ...And prevent search at End Of File
  47.        If Search_StartIndex = -1 Then
  48.            Search_StartIndex = _
  49.            [Control].Find(SearchText, 0, IgnoreCase)
  50.        End If
  51.  
  52.        If Search_StartIndex = -1 Then
  53.            Exit Sub ' No matches found
  54.        End If
  55.  
  56.        ' Set the match selection
  57.        [Control].Select(Search_StartIndex, SearchText.Length)
  58.        ' Set the BackColor
  59.        [Control].SelectionBackColor = Highlight_BackColor
  60.        ' Set the ForeColor
  61.        [Control].SelectionColor = Highlight_ForeColor
  62.        ' Scroll to Caret/Cursor position
  63.        [Control].ScrollToCaret()
  64.  
  65.    End Sub
  66.  
  67. #End Region
8174  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 14 Octubre 2013, 04:37 am
@MauriH

Vuelve a leer este post hasta el final: http://foro.elhacker.net/net/libreria_de_snippets_posteen_aqui_sus_snippets-t378770.0.html;msg1891125#msg1891125

He subido un proyecto de prueba a Mediafire.

Saludos
8175  Programación / Scripting / MOVIDO: programa ENCRYPTOR en: 14 Octubre 2013, 04:12 am
El tema ha sido movido a Dudas Generales.

http://foro.elhacker.net/index.php?topic=400603.0
8176  Programación / Scripting / Re: cambiar icono de archivo .vbs en: 14 Octubre 2013, 04:12 am
Necesitas empaquetar el VBS en un archivo executable, es decir, necesitas convertir el VBS a EXE, y luego modificar el recurso de Icono principal de ese EXE.

-> ExeScript Editor

Saludos
8177  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 13 Octubre 2013, 14:50 pm
Con estas funciones podemos acceder a la información de la ScrollBar integrada de un control (la scrollbar vertical de un RichTextBox por ejemplo), para averiguar si la barra está scrolleada hacia abajo del todo, o hacia arriba del todo, o si ha sobrepasado el límite de abajo/arriba (aunque esto último creo que no pede suceder, pero bueno).

Esto es útil para prevenir el molesto efecto de "rebote" del método ScrollToCaret cuando intentamos scrollear la ScrollBar de un richtextbox cuando ha llegado al límite.

Ejemplo de uso:
Código
  1.        RichTextBox1.Select(RichTextBox1.TextLength - 1, 1)
  2.        If Not ScrollBarInfo.IsAtBottom(RichTextBox1) Then
  3.            RichTextBox1.ScrollToCaret()
  4.        End If


Código
  1. Public Class ScrollBarInfo
  2.  
  3.    <System.Runtime.InteropServices.DllImport("user32")> _
  4.    Private Shared Function GetScrollInfo(hwnd As IntPtr, nBar As Integer, ByRef scrollInfo As SCROLLINFO) As Integer
  5.    End Function
  6.  
  7.    Private Shared scrollInf As New SCROLLINFO()
  8.  
  9.    Private Structure SCROLLINFO
  10.        Public cbSize As Integer
  11.        Public fMask As Integer
  12.        Public min As Integer
  13.        Public max As Integer
  14.        Public nPage As Integer
  15.        Public nPos As Integer
  16.        Public nTrackPos As Integer
  17.    End Structure
  18.  
  19.    Private Shared Sub Get_ScrollInfo(control As Control)
  20.        scrollInf = New SCROLLINFO()
  21.        scrollInf.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(scrollInf)
  22.        scrollInf.fMask = &H10 Or &H1 Or &H2 'SIF_RANGE = &H1, SIF_PAGE= &H2, SIF_TRACKPOS = &H10
  23.        GetScrollInfo(control.Handle, 1, scrollInf)
  24.    End Sub
  25.  
  26.    Public Shared Function ReachedBottom(control As Control) As Boolean
  27.        Get_ScrollInfo(control)
  28.        Return scrollInf.max = scrollInf.nTrackPos + scrollInf.nPage
  29.    End Function
  30.  
  31.    Public Shared Function ReachedTop(control As Control) As Boolean
  32.        Get_ScrollInfo(control)
  33.        Return scrollInf.nTrackPos < 0
  34.    End Function
  35.  
  36.    Public Shared Function IsAtBottom(control As Control) As Boolean
  37.        Get_ScrollInfo(control)
  38.        Return scrollInf.max = (scrollInf.nTrackPos + scrollInf.nPage) - 1
  39.    End Function
  40.  
  41.    Public Shared Function IsAtTop(control As Control) As Boolean
  42.        Get_ScrollInfo(control)
  43.        Return scrollInf.nTrackPos = 0
  44.    End Function
  45.  
  46. End Class
8178  Foros Generales / Foro Libre / Re: [Proyecto] Wikia local / offline en: 13 Octubre 2013, 12:10 pm
http://community.wikia.com/wiki/Help:Database_download
8179  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 13 Octubre 2013, 11:51 am
He descubierto este mensaje de Windows para mover el ScrollBar de un control pudiendo especificar la cantidad de lineas a mover, y la dirección.

Código
  1.    <System.Runtime.InteropServices.DllImport("user32.dll")> _
  2.    Private Shared Function SendMessage(hWnd As IntPtr, wMsg As UInteger, wParam As UIntPtr, lParam As IntPtr) As Integer
  3.    End Function
  4.  
  5.    ' Examples:
  6.    '
  7.    ' SendMessage(RichTextBox1.Handle, &HB6, 0, 1)  ' Move 1 line to down
  8.    ' SendMessage(RichTextBox1.Handle, &HB6, 0, 5)  ' Move 5 lines to down
  9.    ' SendMessage(RichTextBox1.Handle, &HB6, 0, -1) ' Move 1 line to up
  10.    ' SendMessage(RichTextBox1.Handle, &HB6, 0, -5) ' Move 5 lines to up
8180  Programación / Scripting / Re: (Solucionado) [Batch] Randomizar lineas en un txt? en: 13 Octubre 2013, 09:41 am
Creo que no existe esa información en la estructura M3U, no estoy seguro, pero no creo que cueste tanto abrir la wikipedia, buscar, e informarse: http://en.wikipedia.org/wiki/M3U

Citar
Código:
Directive 	Description                                      	Example
#EXTM3U File header. Must be the first line of the file! #EXTM3U

#EXTINF Track information, including runtime and title. #EXTINF:191,Artist Name - Track Title


Para especificar el tiempo de duración tienes que crear otro tipo de lista multimedia, por ejemplo "pls", y eso requiere escribir el código desde cero para adaptarlo a la estructura de la nueva lista multimedia.

Pero además, usando Batch no es posible obtener la información de duración de un archivo multimedia, ya te lo dije que pides cosas que con Batch no es posible y va siendo hora de que uses otro lenguaje.

De todas formas puedes usar la aplicación MediaInfo desde la consola para obtener la duración de un archivo multimedia: http://mediaarea.net/es/MediaInfo/Download/Windows

Saludos
Páginas: 1 ... 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 [818] 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 ... 1254
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines