Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - Eleкtro

#7571
Scripting / Re: leer y ejecutar
15 Diciembre 2013, 19:34 PM
Código (dos) [Seleccionar]
@Echo OFF

FOR /F "Tokens=2 Delims==" %%# IN (
' Type "Archivo.txt" ^| Find.exe /I "winningteam" '
) DO (

If %%# EQU 1 (
Echo Encontrado "1"
REM Ejecutar proceso 1.
)

If %%# EQU 2 (
Echo Encontrado "2"
REM Ejecutar proceso 2.
)

       If %%# NEQ 1 If %%# NEQ 2 (
           Echo El numero encontrado es distinto.
   )
)

Pause&Exit


Saludos
#7572
Cita de: MaX2 en 12 Diciembre 2013, 18:37 PM
en el caso de que la primera carpeta que es la que contiene todas las demas, cambie de nombre, o sea, yo la llamo "Aplicacion", pero si alguien en lugar de llamarla así la llama "Programa" los iconos ya no se mostrarían, se podria hacer algo en este caso?

No, eso ya es algo imposible, si los nombres no fuesen demasiado distintos podrías usar los nombres cortos DOS 8.3 http://en.wikipedia.org/wiki/8.3_filename , pero en tu caso no es posible adivinar el nombre de una carpeta que no se conoce...en un INI.

Cita de: MaX2 en 12 Diciembre 2013, 18:37 PMY también esta la posibilidad de que alguien utilice todo el lapiz usb para tener solo esta aplicación, por lo que decide de copiarlo todo en el raíz, vamos sin estar dentro de una carpeta, hay solución para este caso?

La única solución es especificar la ruta de la raiz del dispositivo, en el parámetro del INI:

IconResource=\..\Librería.dll,48

No puedes especificar dos valores distintos para un mismo parámetro.

Como sugerencia podrías poner los archivos en modo solo lectura, así los menos intleigentes no los podrían copiar fácilmente a otro directorio, o si son algo inteligentes deducirían que si están en solo lectrua es por alguna buena razón xD.

Saludos
#7573
Nueva versión 2.0

· Añadido:

- Nuevos elementos en la UI.


· Mejorado:

 - Básicamente he vuelto a diseñar la aplicación desde cero, con la base que ya tenía de la GUI.

 - Todo el código ha sido reescrito desde cero, reestructurado, mejorado y simplificado, ahora obtiene las urls de forma muy ligera al utilizar la librería HTMLAgilityPack, reálmente es muy veloz el parseo.


· Corregido:

- Si habia alguna minucia por corregir en las antiguas versiones ya se ha hecho al escribir el código desde cero.


En el post principal he compartido imágenes de la nueva versión, y el enlace de descarga es este:

-> http://elektrostudios.tk//MP3Crank%20Leecher.zip

Saludos
#7574
Elektro Listbox, un ListBox User Control para WindowsForms.

Características:

· Estado ReadOnly, al activarse no se podrá seleccionar ningún item, pero a diferencia del estado Disabled se podrá seguir usando la scrollbar.
· Propiedades para especificar un color para los items seleccionados/deseleccionados en diferentes estados (Enabled / Disabled / ReadOnly)
· Método para seleccionar múltiples items sin saltar a la posición del item como sucede con el ListBox por defecto.
· Método para comprobar si existen duplicados en los items.
· Método para eliminar los items duplicados.
· Método para Seleccionar/Deseleccionar todos los items de una vez.

Una imagen:



Que lo disfruteis.

EDITO: Código extendido y mejorado.

Código (vbnet) [Seleccionar]

'  /*                   *\
' |#*  Elektro ListBox  *#|
'  \*  ***************  */
'
' // By Elektro H@cker
'
' -----------
' Properties:
' -----------
'
' ReadOnly
' ReadOnly_Enabled_Cursor
' ReadOnly_Disabled_Cursor
' State_Enabled_ItemSelected_BackColor
' State_Enabled_ItemSelected_ForeColor
' State_Enabled_ItemUnselected_BackColor
' State_Enabled_ItemUnselected_ForeColor
' State_Disabled_ItemSelected_BackColor
' State_Disabled_ItemSelected_ForeColor
' State_Disabled_ItemUnselected_BackColor
' State_Disabled_ItemUnselected_ForeColor
' State_ReadOnly_ItemSelected_BackColor
' State_ReadOnly_ItemSelected_ForeColor
' State_ReadOnly_ItemUnselected_BackColor
' State_ReadOnly_ItemUnselected_ForeColor
'
' --------
' Methods:
' --------
'
' HasDuplicatedItems
' RemoveDuplicatedItems
' SetSelected_WithoutJump
' MoveItem
'
' -------
' Events:
' -------
'
' ReadOnlyChanged

Public Class ElektroListBox : Inherits ListBox

#Region " Members "

#Region " Variables "

    ''' <summary>
    ''' Indicates the BackColor to paint the selected ListBox items when the ListBox is enabled.
    ''' </summary>
    Private _State_Enabled_ItemSelected_BackColor As SolidBrush = New SolidBrush(ListBox.DefaultBackColor)

    ''' <summary>
    ''' Indicates the ForeColor to paint the selected ListBox items when the ListBox is enabled.
    ''' </summary>
    Private _State_Enabled_ItemSelected_ForeColor As SolidBrush = New SolidBrush(ListBox.DefaultForeColor)

    ''' <summary>
    ''' Indicates the BackColor to paint the unselected ListBox items when the ListBox is enabled.
    ''' </summary>
    Private _State_Enabled_ItemUnselected_BackColor As SolidBrush = New SolidBrush(ListBox.DefaultBackColor)

    ''' <summary>
    ''' Indicates the Forecolor to paint the unselected ListBox items when the ListBox is enabled.
    ''' </summary>
    Private _State_Enabled_ItemUnselected_ForeColor As SolidBrush = New SolidBrush(ListBox.DefaultForeColor)

    ''' <summary>
    ''' Indicates the BackColor to paint the selected ListBox items when the ListBox is disabled.
    ''' </summary>
    Private _State_Disabled_ItemSelected_BackColor As SolidBrush = New SolidBrush(ListBox.DefaultBackColor)

    ''' <summary>
    ''' Indicates the Forecolor to paint the selected ListBox items when the ListBox is disabled.
    ''' </summary>
    Private _State_Disabled_ItemSelected_ForeColor As SolidBrush = New SolidBrush(ListBox.DefaultForeColor)

    ''' <summary>
    ''' Indicates the BackColor to paint the unselected ListBox items when the ListBox is disabled.
    ''' </summary>
    Private _State_Disabled_ItemUnselected_BackColor As SolidBrush = New SolidBrush(ListBox.DefaultBackColor)

    ''' <summary>
    ''' Indicates the Forecolor to paint the unselected ListBox items when the ListBox is disabled.
    ''' </summary>
    Private _State_Disabled_ItemUnselected_ForeColor As SolidBrush = New SolidBrush(ListBox.DefaultForeColor)

    ''' <summary>
    ''' Indicates the BackColor to paint the selected ListBox items when the ListBox is ReadOnly.
    ''' </summary>
    Private _State_ReadOnly_ItemSelected_BackColor As SolidBrush = New SolidBrush(ListBox.DefaultBackColor)

    ''' <summary>
    ''' Indicates the Forecolor to paint the selected ListBox items when the ListBox is ReadOnly.
    ''' </summary>
    Private _State_ReadOnly_ItemSelected_ForeColor As SolidBrush = New SolidBrush(ListBox.DefaultForeColor)

    ''' <summary>
    ''' Indicates the BackColor to paint the unselected ListBox items when the ListBox is ReadOnly.
    ''' </summary>
    Private _State_ReadOnly_ItemUnselected_BackColor As SolidBrush = New SolidBrush(ListBox.DefaultBackColor)

    ''' <summary>
    ''' Indicates the Forecolor to paint the unselected ListBox items when the ListBox is ReadOnly.
    ''' </summary>
    Private _State_ReadOnly_ItemUnselected_ForeColor As SolidBrush = New SolidBrush(ListBox.DefaultForeColor)

    ''' <summary>
    ''' Stores a value indicating whether the Listbox is in ReadOnly mode.
    ''' </summary>
    Private _ReadOnly As Boolean = False

    ''' <summary>
    ''' Stores the Cursor to use when the ListBox enters to ReadOnly mode.
    ''' </summary>
    Private _ReadOnly_Enabled_Cursor As Cursor = Cursors.No

    ''' <summary>
    ''' Stores the Cursor to use when the ListBox exits from ReadOnly mode.
    ''' </summary>
    Private _ReadOnly_Disabled_Cursor As Cursor = Cursors.Default

#End Region

#Region " Properties "

    ''' <summary>
    ''' Indicates the BackColor to paint the selected ListBox items when the ListBox is enabled.
    ''' </summary>
    Public Property State_Enabled_ItemSelected_BackColor As Color
        Get
            Return _State_Enabled_ItemSelected_BackColor.Color
        End Get
        Set(value As Color)
            If Not _State_Enabled_ItemSelected_BackColor.Color = value Then
                _State_Enabled_ItemSelected_BackColor = New SolidBrush(value)
                Me.Invalidate(False)
            End If
        End Set
    End Property

    ''' <summary>
    ''' Indicates the ForeColor to paint the selected ListBox items when the ListBox is enabled.
    ''' </summary>
    Public Property State_Enabled_ItemSelected_ForeColor As Color
        Get
            Return _State_Enabled_ItemSelected_ForeColor.Color
        End Get
        Set(value As Color)
            If Not _State_Enabled_ItemSelected_ForeColor.Color = value Then
                _State_Enabled_ItemSelected_ForeColor = New SolidBrush(value)
                Me.Invalidate(False)
            End If
        End Set
    End Property

    ''' <summary>
    ''' Indicates the BackColor to paint the unselected ListBox items when the ListBox is enabled.
    ''' </summary>
    Public Property State_Enabled_ItemUnselected_BackColor As Color
        Get
            Return _State_Enabled_ItemUnselected_BackColor.Color
        End Get
        Set(value As Color)
            If Not _State_Enabled_ItemUnselected_BackColor.Color = value Then
                _State_Enabled_ItemUnselected_BackColor = New SolidBrush(value)
                Me.Invalidate(False)
            End If
        End Set
    End Property

    ''' <summary>
    ''' Indicates the Forecolor to paint the unselected ListBox items when the ListBox is enabled.
    ''' </summary>
    Public Property State_Enabled_ItemUnselected_ForeColor As Color
        Get
            Return _State_Enabled_ItemUnselected_ForeColor.Color
        End Get
        Set(value As Color)
            If Not _State_Enabled_ItemUnselected_ForeColor.Color = value Then
                _State_Enabled_ItemUnselected_ForeColor = New SolidBrush(value)
                Me.Invalidate(False)
            End If
        End Set
    End Property

    ''' <summary>
    ''' Indicates the BackColor to paint the selected ListBox items when the ListBox is disabled.
    ''' </summary>
    Public Property State_Disabled_ItemSelected_BackColor As Color
        Get
            Return _State_Disabled_ItemSelected_BackColor.Color
        End Get
        Set(value As Color)
            If Not _State_Disabled_ItemSelected_BackColor.Color = value Then
                _State_Disabled_ItemSelected_BackColor = New SolidBrush(value)
                Me.Invalidate(False)
            End If
        End Set
    End Property

    ''' <summary>
    ''' Indicates the Forecolor to paint the selected ListBox items when the ListBox is disabled.
    ''' </summary>
    Public Property State_Disabled_ItemSelected_ForeColor As Color
        Get
            Return _State_Disabled_ItemSelected_ForeColor.Color
        End Get
        Set(value As Color)
            If Not _State_Disabled_ItemSelected_ForeColor.Color = value Then
                _State_Disabled_ItemSelected_ForeColor = New SolidBrush(value)
                Me.Invalidate(False)
            End If
        End Set
    End Property

    ''' <summary>
    ''' Indicates the BackColor to paint the unselected ListBox items when the ListBox is disabled.
    ''' </summary>
    Public Property State_Disabled_ItemUnselected_BackColor As Color
        Get
            Return _State_Disabled_ItemUnselected_BackColor.Color
        End Get
        Set(value As Color)
            If Not _State_Disabled_ItemUnselected_BackColor.Color = value Then
                _State_Disabled_ItemUnselected_BackColor = New SolidBrush(value)
                Me.Invalidate(False)
            End If
        End Set
    End Property

    ''' <summary>
    ''' Indicates the Forecolor to paint the unselected ListBox items when the ListBox is disabled.
    ''' </summary>
    Public Property State_Disabled_ItemUnselected_ForeColor As Color
        Get
            Return _State_Disabled_ItemUnselected_ForeColor.Color
        End Get
        Set(value As Color)
            If Not _State_Disabled_ItemUnselected_ForeColor.Color = value Then
                _State_Disabled_ItemUnselected_ForeColor = New SolidBrush(value)
                Me.Invalidate(False)
            End If
        End Set
    End Property

    ''' <summary>
    ''' Indicates the BackColor to paint the selected ListBox items when the ListBox is ReadOnly.
    ''' </summary>
    Public Property State_ReadOnly_ItemSelected_BackColor As Color
        Get
            Return _State_ReadOnly_ItemSelected_BackColor.Color
        End Get
        Set(value As Color)
            If Not _State_ReadOnly_ItemSelected_BackColor.Color = value Then
                _State_ReadOnly_ItemSelected_BackColor = New SolidBrush(value)
                Me.Invalidate(False)
            End If
        End Set
    End Property

    ''' <summary>
    ''' Indicates the Forecolor to paint the selected ListBox items when the ListBox is ReadOnly.
    ''' </summary>
    Public Property State_ReadOnly_ItemSelected_ForeColor As Color
        Get
            Return _State_ReadOnly_ItemSelected_ForeColor.Color
        End Get
        Set(value As Color)
            If Not _State_ReadOnly_ItemSelected_ForeColor.Color = value Then
                _State_ReadOnly_ItemSelected_ForeColor = New SolidBrush(value)
                Me.Invalidate(False)
            End If
        End Set
    End Property

    ''' <summary>
    ''' Indicates the BackColor to paint the unselected ListBox items when the ListBox is ReadOnly.
    ''' </summary>
    Public Property State_ReadOnly_ItemUnselected_BackColor As Color
        Get
            Return _State_ReadOnly_ItemUnselected_BackColor.Color
        End Get
        Set(value As Color)
            If Not _State_ReadOnly_ItemUnselected_BackColor.Color = value Then
                _State_ReadOnly_ItemUnselected_BackColor = New SolidBrush(value)
                Me.Invalidate(False)
            End If
        End Set
    End Property

    ''' <summary>
    ''' Indicates the Forecolor to paint the unselected ListBox items when the ListBox is ReadOnly.
    ''' </summary>
    Public Property State_ReadOnly_ItemUnselected_ForeColor As Color
        Get
            Return _State_ReadOnly_ItemUnselected_ForeColor.Color
        End Get
        Set(value As Color)
            If Not _State_ReadOnly_ItemUnselected_ForeColor.Color = value Then
                _State_ReadOnly_ItemUnselected_ForeColor = New SolidBrush(value)
                Me.Invalidate(False)
            End If
        End Set
    End Property

    ''' <summary>
    ''' Gets or sets a value indicating whether the Listbox is in ReadOnly mode.
    ''' </summary>
    Public Property [ReadOnly]() As Boolean
        Get
            Return _ReadOnly
        End Get
        Set(value As Boolean)
            If Not _ReadOnly = value Then
                _ReadOnly = value
                RaiseEvent ReadOnlyChanged(Me, New ReadOnlyChangedEventArgs With
                                               {.IsReadOnly = value})
            End If
        End Set
    End Property

    ''' <summary>
    ''' Gets or sets the Cursor to use when the ListBox enters in ReadOnly mode.
    ''' </summary>
    Public Property ReadOnly_Enabled_Cursor As Cursor
        Get
            Return _ReadOnly_Enabled_Cursor
        End Get
        Set(value As Cursor)
            If Not _ReadOnly_Enabled_Cursor = value Then
                _ReadOnly_Enabled_Cursor = value
                DesignTimeInvalidator(False)
            End If
        End Set
    End Property

    ''' <summary>
    ''' Gets or sets the Cursor to use when the ListBox exits from ReadOnly mode.
    ''' </summary>
    Public Property ReadOnly_Disabled_Cursor As Cursor
        Get
            Return _ReadOnly_Disabled_Cursor
        End Get
        Set(value As Cursor)
            If Not _ReadOnly_Disabled_Cursor = value Then
                _ReadOnly_Disabled_Cursor = value
                DesignTimeInvalidator(False)
            End If
        End Set
    End Property

#End Region

#Region " Enumerations "

    ''' <summary>
    ''' Indicates the state of a Listbox Item.
    ''' </summary>
    Public Enum ItemState

        ''' <summary>
        ''' Select the listbox Item.
        ''' </summary>
        Selected = 0

        ''' <summary>
        ''' Unselect the listbox Item.
        ''' </summary>
        Unselected = 1

    End Enum

    ''' <summary>
    ''' Indicates the items to select.
    ''' </summary>
    Public Enum ListBoxItems As Short

        ''' <summary>
        ''' Select all items of the ListBox.
        ''' </summary>
        All = 1

        ''' <summary>
        ''' Select any ListBox items.
        ''' </summary>
        None = 2

    End Enum

    ''' <summary>
    ''' Indicates some Known Windows Message Identifiers to manage.
    ''' </summary>
    Private Enum KnownMessages As Integer
        WM_LBUTTONDOWN = &H201
        WM_KEYDOWN = &H100
    End Enum

#End Region

#Region " Events "

    ''' <summary>
    ''' Event raised when the ReadOnly state of the ListBox changes.
    ''' </summary>
    Private Event ReadOnlyChanged As EventHandler(Of ReadOnlyChangedEventArgs)
    Private Class ReadOnlyChangedEventArgs : Inherits EventArgs
        Public Property IsReadOnly As Boolean
    End Class

#End Region

#End Region

#Region " Constructor "

    Public Sub New()
        Me.DoubleBuffered = True
        Me.DrawMode = DrawMode.OwnerDrawFixed
    End Sub

#End Region

#Region " Public Methods "

    ''' <summary>
    ''' Returns a value indicating whether the ListBox items contains duplicates.
    ''' </summary>
    Public Function HasDuplicatedItems() As Boolean
        Return Me.Items.Count - Me.Items.Cast(Of String).Distinct().Count
    End Function

    ''' <summary>
    ''' Remove all duplicated items in ListBox.
    ''' </summary>
    Public Sub RemoveDuplicatedItems()

        If HasDuplicatedItems() Then
            Dim ItemArray As IEnumerable(Of String) = Me.Items.Cast(Of String).Distinct()
            Me.Items.Clear()
            Me.Items.AddRange(ItemArray.ToArray)
        End If

    End Sub

    ''' <summary>
    ''' Selects or unselects a ListBox Item without jumping to the Item position.
    ''' </summary>
    ''' <param name="ItemIndex">Indicates the index of the Item to set.</param>
    ''' <param name="ItemState">Indicates the state for the item.</param>
    Public Sub SetSelected_WithoutJump(ItemIndex As Integer, ItemState As ItemState)

        Dim i As Integer = Me.TopIndex ' Store the selected item index.
        Me.BeginUpdate() ' Disable drawing on control.
        Me.SetSelected(ItemIndex, ItemState) ' Select the item.
        Me.TopIndex = i ' Jump to the previous selected item.
        Me.EndUpdate() ' Eenable drawing.

    End Sub

    ''' <summary>
    ''' Selects or unselects ListBox Items without jumping to the Item position.
    ''' </summary>
    ''' <param name="ItemIndex">Indicates the index of the Items to set.</param>
    ''' <param name="ItemState">Indicates the state for the items.</param>
    Public Sub SetSelected_WithoutJump(ItemIndex As Integer(), ItemState As ItemState)

        Dim i As Integer = Me.TopIndex ' Store the selected item index.
        Me.BeginUpdate() ' Disable drawing on control.

        For Each Index As Integer In ItemIndex

            Select Case ItemState

                Case ItemState.Selected
                    Me.SetSelected(Index, True) ' Select the item.

                Case ItemState.Unselected
                    Me.SetSelected(Index, False) ' Unselect the item.

            End Select

        Next Index

        Me.TopIndex = i ' Jump to the previous selected item.
        Me.EndUpdate() ' Eenable drawing.

    End Sub

    ''' <summary>
    ''' Selects or unselects all ListBox Item without jumping to the Item position.
    ''' </summary>
    ''' <param name="ListBoxItems">Indicates the Items to set.</param>
    ''' <param name="ItemState">Indicates the state for the items.</param>
    Public Sub SetSelected_WithoutJump(ListBoxItems As ListBoxItems, ItemState As ItemState)

        Dim i As Integer = Me.TopIndex ' Store the selected item index.
        Me.BeginUpdate() ' Disable drawing on control.

        Select Case ItemState

            Case ItemState.Selected ' Select all the items.

                For Item As Integer = 0 To Me.Items.Count - 1
                    Me.SetSelected(Item, True)
                Next Item

            Case ItemState.Unselected ' Unselect all the items.
                Me.SelectedItems.Clear()

        End Select

        Me.TopIndex = i ' Jump to the previous selected item.
        Me.EndUpdate() ' Eenable drawing.

    End Sub

    ''' <summary>
    ''' Moves an item to other position.
    ''' </summary>
    ''' <param name="ItemPosition">Indicates the position to move from.</param>
    ''' <param name="NewItemPosition">Indicates the new position for the item.</param>
    Public Sub MoveItem(ByVal ItemPosition As Integer, ByVal NewItemPosition As Integer)

        Dim oldItem As Object = Me.Items.Item(ItemPosition)
        Dim newItem As Object = Me.Items.Item(NewItemPosition)

        Me.Items.Item(ItemPosition) = newItem
        Me.Items.Item(NewItemPosition) = oldItem

    End Sub

#End Region

#Region " Private Methods "

    ''' <summary>
    ''' Invalidates the Control to update changes at Design-Time.
    ''' </summary>
    ''' <param name="InvalidateChildren">Indicates whether to invalidate the child controls of the control.</param>
    Private Sub DesignTimeInvalidator(InvalidateChildren As Boolean)

        If Me.DesignMode Then
            Me.Invalidate(InvalidateChildren)
        End If

    End Sub

#End Region

#Region " Event Handlers "

    ''' <summary>
    ''' This happens when the ListBox 'ReadOnly' state has changed.
    ''' </summary>
    Private Sub OnReadOnly() _
    Handles Me.ReadOnlyChanged

        Me.BeginUpdate()

        If Me.ReadOnly Then
            Me.Cursor = _ReadOnly_Enabled_Cursor
        Else
            Me.Cursor = _ReadOnly_Disabled_Cursor
        End If

        Me.EndUpdate()

    End Sub

    ''' <summary>
    ''' Colorize the ListBox Items.
    ''' </summary>
    Private Sub Colorize(ByVal sender As Object, ByVal e As DrawItemEventArgs) _
    Handles Me.DrawItem

        If Me.Items.Count <> 0 Then

            If Me.Enabled AndAlso Not Me.ReadOnly Then

                e.DrawBackground()

                If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
                    e.Graphics.FillRectangle(_State_Enabled_ItemSelected_BackColor, e.Bounds)
                    e.Graphics.DrawString(Me.GetItemText(Me.Items(e.Index)), e.Font, _State_Enabled_ItemSelected_ForeColor, e.Bounds)

                ElseIf (e.State And DrawItemState.Selected) = DrawItemState.None Then
                    e.Graphics.FillRectangle(_State_Enabled_ItemUnselected_BackColor, e.Bounds)
                    e.Graphics.DrawString(Me.GetItemText(Me.Items(e.Index)), e.Font, _State_Enabled_ItemUnselected_ForeColor, e.Bounds)

                End If

                e.DrawFocusRectangle()

            ElseIf Not Me.Enabled Then

                e.DrawBackground()

                If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
                    e.Graphics.FillRectangle(_State_Disabled_ItemSelected_BackColor, e.Bounds)
                    e.Graphics.DrawString(Me.GetItemText(Me.Items(e.Index)), e.Font, _State_Disabled_ItemSelected_ForeColor, e.Bounds)

                ElseIf (e.State And DrawItemState.Selected) = DrawItemState.None Then
                    e.Graphics.FillRectangle(_State_Disabled_ItemUnselected_BackColor, e.Bounds)
                    e.Graphics.DrawString(Me.GetItemText(Me.Items(e.Index)), e.Font, _State_Disabled_ItemUnselected_ForeColor, e.Bounds)

                End If

                e.DrawFocusRectangle()

            ElseIf Me.ReadOnly Then

                e.DrawBackground()

                If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
                    e.Graphics.FillRectangle(_State_ReadOnly_ItemSelected_BackColor, e.Bounds)
                    e.Graphics.DrawString(Me.GetItemText(Me.Items(e.Index)), e.Font, _State_ReadOnly_ItemSelected_ForeColor, e.Bounds)

                ElseIf (e.State And DrawItemState.Selected) = DrawItemState.None Then
                    e.Graphics.FillRectangle(_State_ReadOnly_ItemUnselected_BackColor, e.Bounds)
                    e.Graphics.DrawString(Me.GetItemText(Me.Items(e.Index)), e.Font, _State_ReadOnly_ItemUnselected_ForeColor, e.Bounds)

                End If

                e.DrawFocusRectangle()

            End If

        End If

    End Sub

#End Region

#Region " Windows Messages "

    ''' <summary>
    ''' Processes the Windows Messages for this window.
    ''' </summary>
    Protected Overrides Sub WndProc(ByRef m As Message)

        If Me.[ReadOnly] AndAlso (m.Msg = KnownMessages.WM_LBUTTONDOWN OrElse m.Msg = KnownMessages.WM_KEYDOWN) Then
            Return ' Disable left click on the ListBox.
        End If

        MyBase.WndProc(m)

    End Sub

#End Region

End Class
#7575
Hola

Con la librería NAudio (entre otras muchas librerías) puedes controlar/averiguar el volumen de un dispositivo de salida específico, o del volumen maestro del PC.

-> http://naudio.codeplex.com/

La librería está muy bien documentada, incluye ejemplos en C#, y además hay muchos más ejemplos de uso esparcidos por google, no creo que te cueste encontrar la manera.

Aquí tienes un ejemplo en VBNET de otra librería (CoreAudioApi) más relacionado con tu pregunta, el código es algo antiguo y feo, pero la función que hago (que puedes sacar del source) es medir el nivel de volumen del sonido maestro del PC, quizás te sirva más que NAudio:

-> Volium Autor: EleKtro H@cker

Citar

Saludos

#7576
Cita de: Danyfirex en 10 Diciembre 2013, 05:18 AMhttp://es.lmgtfy.com/?q=send+mouse+click+C%23

Cita de: pablomillon en 14 Diciembre 2013, 22:57 PMYa busque pero aun no encuentro

Sin comentarios.

Cita de: pablomillon en 14 Diciembre 2013, 22:57 PMte agradecería si me pudiras decir los codigos

No es todo copiar y hacer click (nunca mejor dicho); en la url que te han proporcionado tienes todo lo necesario, coge el ejemplo que más te guste, intenta solucionarlo por ti mismo, y si no lo consigues muestra tus progresos para que te corrijamos los fallos.

Saludos
#7577
Para comprobar si la conectividad a una web está disponible y mostrar un mensaje de Status en un control...

Ejemplo de uso:

Código (vbnet) [Seleccionar]
    Private Sub Test()

        MsgBox(Is_Connectivity_Avaliable("Google.com"))

        Dim t As New Threading.Thread(AddressOf CheckConnectivity)
        t.Start()

    End Sub

    Private Sub CheckConnectivity()
        Do Until Is_Connectivity_Avaliable("qwertyqwertyqwerty.com", 10, Label1)
            Application.DoEvents()
        Loop
    End Sub


Código (vbnet) [Seleccionar]
    Private Function Is_Connectivity_Avaliable(ByVal url As String,
                                               Optional ByVal RetryInterval As Integer = -1,
                                               Optional ByVal StatusControl As Control = Nothing) As Boolean

        Dim NoNetworkMessage As String = "Network connection is not avaliable."
        Dim NoWebsiteMessage As String = "WebSite is not avaliable."
        Dim NoNetworkRetryMessage As String = "Network connection is not avaliable, retrying in {0} seconds..."
        Dim NoWebsiteRetryMessage As String = "WebSite is not avaliable, retrying in {0} seconds..."
        Dim YesNetworkMessage As String = "Network connection established."
        Dim YesWebsiteMessage As String = "WebSite connection established."

        Select Case My.Computer.Network.IsAvailable

            Case False ' No network device avaliable

                If RetryInterval = -1 Then ' Do not retry
                    NetworkAvaliable(NoNetworkMessage, False, StatusControl)
                    Return False

                Else ' Retry

                    For X As Integer = 0 To RetryInterval
                        NetworkAvaliable(String.Format(NoNetworkRetryMessage, RetryInterval - X), True, StatusControl)
                    Next X

                    Is_Connectivity_Avaliable(url, RetryInterval, StatusControl)

                End If ' RetryInterval

            Case True ' Network device is avaliable

                ' Inform that network device is avaliable.
                NetworkAvaliable(YesNetworkMessage, False, StatusControl)

                Try ' Try connect to the given url
                    My.Computer.Network.Ping(url)

                    ' Inform that Website connection is avaliable.
                    NetworkAvaliable(YesWebsiteMessage, False, StatusControl)
                    Return True

                Catch ex As Net.NetworkInformation.PingException

                    If RetryInterval = -1 Then ' Do not retry
                        NetworkAvaliable(NoWebsiteMessage, False, StatusControl)
                        Return False

                    Else ' Retry

                        For X As Integer = 0 To RetryInterval
                            NetworkAvaliable(String.Format(NoWebsiteRetryMessage, RetryInterval - X), True, StatusControl)
                        Next X

                        Is_Connectivity_Avaliable(url, RetryInterval, StatusControl)

                    End If ' RetryInterval

                Catch ex As InvalidOperationException

                    If RetryInterval = -1 Then ' Do not retry
                        NetworkAvaliable(NoNetworkMessage, False, StatusControl)
                        Return False

                    Else ' Retry

                        For X As Integer = 0 To RetryInterval
                            NetworkAvaliable(String.Format(NoNetworkRetryMessage, RetryInterval - X), True, StatusControl)
                        Next

                        Is_Connectivity_Avaliable(url, RetryInterval, StatusControl)

                    End If ' RetryInterval

                End Try

        End Select

    End Function

    Private Sub NetworkAvaliable(ByVal Message As String,
                                 ByVal Wait As Boolean,
                                 Optional ByVal StatusControl As Control = Nothing)

        If Wait Then Threading.Thread.Sleep(1000)

        If StatusControl IsNot Nothing Then
            StatusControl.Invoke(Sub() StatusControl.Text = Message)
        Else
            Debug.WriteLine(Message)
        End If

    End Sub





Un snippet para colorear los elementos de un Listbox, esto lo posteé hace tiempo pero lo he extendido...

Código (vbnet) [Seleccionar]
#Region " [ListBox] Colorize Items "

' [ [ListBox] Colorize Items ]
'
' // By Elektro H@cker
'
' Instructions:
' 1. Set ListBox "Drawmode" property to "OwnerDrawFixed" to make this work.
'    ListBox1.DrawMode = DrawMode.OwnerDrawFixed
'
' Examples :
'
' Colorize only selected item:
' Colorize_Item(ListBox1, Colorize_ListBox_Items.Selected, Brushes.YellowGreen, Brushes.Black)
'
' Colorize all Non-Selected items
' Colorize_Item(ListBox1, Colorize_ListBox_Items.Non_Selected, Brushes.Red, Brushes.YellowGreen)
'
' Colorize all items:
' Colorize_Item(ListBox1, Colorize_ListBox_Items.All, Brushes.Yellow, Brushes.Yellow)
'
' Colorize any item:
' Colorize_Item(ListBox1, Colorize_ListBox_Items.None, Nothing, Nothing)
'
' Colorize specific items:
' Colorize_Item(ListBox1, {0, (ListBox1.Items.Count \ 2), (ListBox1.Items.Count - 1)}, Brushes.HotPink, Nothing)


    ' Stores the brush colors to paint their items
    Private ListBox_BackColor As Brush = Brushes.YellowGreen
    Private ListBox_ForeColor As Brush = Brushes.Black

    Private Enum ListBoxItems As Short
        Selected = 0
        Non_Selected = 1
        All = 2
        None = 3
    End Enum

    ''' <summary>
    ''' Colorizes the items of a ListBox.
    ''' </summary>
    ''' <param name="ListBox">Indicates the ListBox control.</param>
    ''' <param name="Colorize">Indicates the items to colorize them.</param>
    ''' <param name="BackColor">Indicates the backcolor for the colorized items.</param>
    ''' <param name="Forecolor">Indicates the forecolor for the colorized items.</param>
    Private Sub Colorize_Item(ByVal ListBox As ListBox, _
                              ByVal Colorize As ListBoxItems, _
                              ByVal BackColor As Brush,
                              ByVal Forecolor As Brush)

        ' Stores the Enum value
        ListBox.Tag = Colorize.ToString

        ListBox_BackColor = BackColor
        ListBox_ForeColor = Forecolor

    End Sub

    ''' <summary>
    ''' Colorizes the items of a ListBox.
    ''' </summary>
    ''' <param name="ListBox">Indicates the ListBox control.</param>
    ''' <param name="Colorize">Indicates the items to colorize them.</param>
    ''' <param name="BackColor">Indicates the backcolor for the colorized items.</param>
    ''' <param name="Forecolor">Indicates the forecolor for the colorized items.</param>
    Private Sub Colorize_Item(ByVal ListBox As ListBox,
                              ByVal Colorize As Integer(),
                              ByVal BackColor As Brush,
                              ByVal Forecolor As Brush)

        ' Stores the index items
        ListBox.Tag = String.Join(Convert.ToChar(Keys.Space), Colorize)

        ListBox_BackColor = BackColor
        ListBox_ForeColor = Forecolor

    End Sub

    ' ListBox [DrawItem]
    Private Sub ListBox_DrawItem(ByVal sender As Object, ByVal e As DrawItemEventArgs) _
    Handles ListBox_Genres.DrawItem

        e.DrawBackground()

        Select Case sender.tag

            Case ListBoxItems.Selected.ToString ' Colorize Selected Items

                If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
                    e.Graphics.FillRectangle(ListBox_BackColor, e.Bounds)
                    e.Graphics.DrawString(sender.GetItemText(sender.Items(e.Index)), e.Font, ListBox_ForeColor, e.Bounds)
                Else
                    Using b As New SolidBrush(e.ForeColor)
                        e.Graphics.DrawString(sender.GetItemText(sender.Items(e.Index)), e.Font, b, e.Bounds)
                    End Using
                End If

            Case ListBoxItems.Non_Selected.ToString ' Colorize Non-Selected Items

                If (e.State And DrawItemState.Selected) = DrawItemState.None Then
                    e.Graphics.FillRectangle(ListBox_BackColor, e.Bounds)
                    e.Graphics.DrawString(sender.GetItemText(sender.Items(e.Index)), e.Font, ListBox_ForeColor, e.Bounds)
                Else
                    Using b As New SolidBrush(e.ForeColor)
                        e.Graphics.DrawString(sender.GetItemText(sender.Items(e.Index)), e.Font, b, e.Bounds)
                    End Using
                End If

            Case ListBoxItems.All.ToString ' Colorize all

                e.Graphics.FillRectangle(ListBox_BackColor, e.Bounds)
                e.Graphics.DrawString(sender.GetItemText(sender.Items(e.Index)), e.Font, ListBox_ForeColor, e.Bounds)

            Case ListBoxItems.None.ToString ' Colorize none

                Using b As New SolidBrush(ListBox.DefaultBackColor)
                    e.Graphics.FillRectangle(b, e.Bounds)
                End Using

                Using b As New SolidBrush(ListBox.DefaultForeColor)
                    e.Graphics.DrawString(sender.GetItemText(sender.Items(e.Index)), e.Font, b, e.Bounds)
                End Using

            Case Else ' Colorize at specific index

                If Not String.IsNullOrEmpty(sender.tag) _
                AndAlso sender.tag.ToString.Split.Contains(CStr(e.Index)) Then

                    e.Graphics.FillRectangle(ListBox_BackColor, e.Bounds)
                    e.Graphics.DrawString(sender.GetItemText(sender.Items(e.Index)), e.Font, ListBox_ForeColor, e.Bounds)

                Else

                    Using b As New SolidBrush(e.ForeColor)
                        e.Graphics.DrawString(sender.GetItemText(sender.Items(e.Index)), e.Font, b, e.Bounds)
                    End Using

                End If

        End Select
     
        e.DrawFocusRectangle()

    End Sub

#End Region





Otro snippet que he extendido, para ordenar los los items de un ListView:

Código (vbnet) [Seleccionar]
    ''' <summary>
    ''' Sorts the column content of a ListView.
    ''' </summary>
    ''' <param name="LV">Indicates the ListView to sort.</param>
    ''' <param name="Column">Indicates the columnd to index.</param>
    ''' <param name="Order">Indicates the sort order.</param>
    Private Sub SortListView(ByVal LV As ListView,
                             ByVal Column As Integer,
                             ByVal Order As SortOrder)

        LV.ListViewItemSorter = New ListViewSorter(Column, Order)
        LV.Sort()

    End Sub

    ' ListView [ColumnClick]
    Private Sub ListView_ColumnClick(ByVal sender As Object, ByVal e As ColumnClickEventArgs) _
    Handles ListView1.ColumnClick

        If String.IsNullOrEmpty(sender.Columns.Item(0).Tag) Then
            sender.Columns.Item(0).Tag = SortOrder.Ascending.ToString
        Else
            sender.Columns.Item(0).Tag =
                [Enum].GetValues(GetType(SortOrder)).
                Cast(Of Integer).
                Where(Function(n) n <> [Enum].Parse(GetType(SortOrder), sender.Columns.Item(0).Tag)).
                First()
        End If

        SortListView(sender, e.Column, [Enum].Parse(GetType(SortOrder), sender.Columns.Item(0).Tag))

    End Sub

#Region " ListViewSorter "

    Public Class ListViewSorter : Implements IComparer

        Private ColumnIndex As Integer
        Private SortOrder As SortOrder

        Public Sub New(ByVal ColumnIndex As Integer,
                       ByVal SortOrder As SortOrder)

            Me.ColumnIndex = ColumnIndex
            Me.SortOrder = SortOrder

        End Sub

        Public Function Sort(ByVal x As Object,
                             ByVal y As Object) As Integer _
        Implements IComparer.Compare

            Dim item_x As ListViewItem = DirectCast(x, ListViewItem)
            Dim item_y As ListViewItem = DirectCast(y, ListViewItem)
            Dim string_x As String
            Dim string_y As String

            string_x = If(Not item_x.SubItems.Count <= ColumnIndex,
                          item_x.SubItems(ColumnIndex).Text,
                          "")

            string_y = If(Not item_y.SubItems.Count <= ColumnIndex,
                          item_y.SubItems(ColumnIndex).Text,
                          "")

            Select Case SortOrder

                Case SortOrder.Ascending

                    If Double.TryParse(string_x, New Double) AndAlso Double.TryParse(string_y, New Double) Then
                        Return Double.Parse(string_x).CompareTo(Double.Parse(string_y))

                    ElseIf Date.TryParse(string_x, New Date) AndAlso Date.TryParse(string_y, New Date) Then
                        Return DateTime.Parse(string_x).CompareTo(DateTime.Parse(string_y))

                    Else
                        Return String.Compare(string_x, string_y, False)

                    End If

                Case Else

                    If Double.TryParse(string_x, New Double) AndAlso Double.TryParse(string_y, New Double) Then
                        Return Double.Parse(string_y).CompareTo(Double.Parse(string_x))

                    ElseIf Date.TryParse(string_x, New Date) AndAlso Date.TryParse(string_y, New Date) Then
                        Return DateTime.Parse(string_y).CompareTo(DateTime.Parse(string_x))

                    Else
                        Return String.Compare(string_y, string_x, False)

                    End If

            End Select

        End Function

    End Class

#End Region
#7578
@Osmart

No se tolera revivir temas antiguos si no es por parte del autor o para aportar información esencial al mismo.

Debes formular tu pregunta en un nuevo post.

PD: Te recomiendo una lectura a las reglas de este subforo: Normas del tablón ( LEER ANTES DE POSTEAR )

Saludos
#7579
¿Cual es el mensaje de error?

Prueba a setear el parámetro -n, que lo usarías como segundos de espera (el valor es en segundos, no milisegundos):

Código (dos) [Seleccionar]
Set /A "MAXwait=10"
Set /A "MINwait=5"
Ping LOCALHOST -n %wait% 1>NUL


Saludos!
#7580
Unos snippets para el control GeckoFX https://bitbucket.org/geckofx/ la cual necesita (una versión específica de) XulRunner http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/

- Navega a una url y espera a que la página se haya cargado complétamente.

Código (vbnet) [Seleccionar]
   ' [GeckoFX] - Navigate And Wait
   '
   ' // By Elektro H@cker
   '
   ' Usage Examples:
   ' NavigateAndWait(GeckoWebBrowser1, "www.google.com") : MsgBox("Page fully loaded!")

   Private WebPageLoaded As Boolean = False

   ''' <summary>
   ''' Navigates to an url and waits the page to be loaded.
   ''' </summary>
   ''' <param name="url">Indicates the url to navigate.</param>
   Public Sub NavigateAndWait(Byval Browser as Gecko.GeckoWebBrowser,
                              Byval url As String,
                              Optional loadFlags As Gecko.GeckoLoadFlags = Gecko.GeckoLoadFlags.None,
                              Optional referrer As String = Nothing,
                              Optional postData As Gecko.GeckoMIMEInputStream = Nothing)

       Me.WebPageLoaded = False

       AddHandler Browser.DocumentCompleted, AddressOf GeckoWebBrowserDocumentCompleted
       Browser.Navigate(url, loadFlags, referrer, postData)

       Do Until Me.WebPageLoaded
           Application.DoEvents()
       Loop

       RemoveHandler Browser.DocumentCompleted, AddressOf GeckoWebBrowserDocumentCompleted

   End Sub

   ' GeckoWebBrowser [DocumentCompleted]
   Private Sub GeckoWebBrowserDocumentCompleted(ByVal sender As Object, e As EventArgs)

       Me.WebPageLoaded = True

   End Sub



- Elimina todas las cookies que haya generado el navegador

Código (vbnet) [Seleccionar]
   ' [GeckoFX] - Remove All Cookies

   Private Sub RemoveAllCookies()
       Dim CookieMan As nsICookieManager2
       CookieMan = Xpcom.GetService(Of nsICookieManager2)("@mozilla.org/cookiemanager;1")
       CookieMan = Xpcom.QueryInterface(Of nsICookieManager2)(CookieMan)
       CookieMan.RemoveAll()
   End Sub


- Establece algunas preferencias interesantes del navegador

Código (vbnet) [Seleccionar]
   Private Sub SetNavigatorPreferences()

       ' Pipelining reduces network load and can reduce page loading times over high-latency connections,
       ' but not all servers support it.
       ' Some servers may even behave incorrectly if they receive pipelined requests.
       ' If a proxy server is not configured, this preference controls whether to attempt to use pipelining.
       ' Value = Attempt to use pipelining in HTTP 1.1 connections or not.
       Gecko.GeckoPreferences.Default("network.http.pipelining") = True

       ' Many problems with pipelining are related to broken proxy servers sitting between the user and the destination web site.
       ' Since this is not a problem with SSL, it is possible to turn on pipelining for SSL websites only.
       ' This preference controls whether to use pipelining for secure websites, regardless of network.http.pipelining.
       ' Value = Use HTTP pipelining for secure websites or not.
       Gecko.GeckoPreferences.Default("network.http.pipelining.ssl") = True

       ' Value = The maximum number of requests to pipeline at once when pipelining is enabled.
       Gecko.GeckoPreferences.Default("network.http.pipelining.maxrequests") = 10

       ' Value = Total number of HTTP connections the application can make to a single server.
       Gecko.GeckoPreferences.Default("network.http.max-connections-per-server") = 20

       ' HTTP keep-alive connections can be re-used for multiple requests,
       ' as opposed to non-keep-alive connections, which are limited to one request.
       ' Using keep-alive connections improves performance.
       ' Value = The maximum number of HTTP keep-alive connections the application can have open at once to a single server. (Default: 2)
       Gecko.GeckoPreferences.Default("network.http.max-persistent-connections-per-server") = 5

       ' Display what's been received of a page before the entire page has been downloaded.
       ' Value = The number of milliseconds to wait before first displaying the page. (Default: 250)
       Gecko.GeckoPreferences.Default("nglayout.initialpaint.delay") = 0

       ' Value = Attempt to use pipelining in HTTP 1.1 connections to the proxy server or not.
       Gecko.GeckoPreferences.Default("network.http.proxy.pipelining") = True

       ' Rather than wait until a page has completely downloaded to display it to the user,
       ' Mozilla applications will periodically render what has been received to that point.
       ' Because reflowing the page every time additional data is received greatly slows down total page load time,
       ' a timer was added so that the page would not reflow too often.
       ' Value = The maximum number of times the content will do timer-based reflows.
       ' After this number has been reached, the page will only reflow once it is finished downloading.
       Gecko.GeckoPreferences.Default("content.notify.backoffcount") = 5

       ' Value = Displays the full path of a installed plugin file or not.
       Gecko.GeckoPreferences.Default("plugin.expose_full_path") = True

       ' Value = The delay in milliseconds between hovering over a menu option with a submenu and the submenu appearing.
       Gecko.GeckoPreferences.Default("ui.submenuDelay") = 0

       ' Pages that were recently visited are stored in memory in such a way that they don't have to be re-parsed (this is different from the memory cache).
       ' This improves performance when pressing Back and Forward.
       ' Value = The maximum number of pages stored in memory.
       Gecko.GeckoPreferences.Default("Browser.sessionhistory.max_total_viewers") = 5

       ' Value = The maximum number of pages in the browser's session history,
       ' the maximum number of URLs you can traverse purely through the Back/Forward buttons. Default value is 50.
       Gecko.GeckoPreferences.Default("Browser.sessionhistory.max_entries") = 60

       ' When a program is minimized and left for a period of time,
       ' Windows will swap memory the program is using from RAM onto the hard disk in anticipation that other programs might need RAM.
       ' Value = Determines whether to mark memory as preferably swappable, from a minimized Mozilla Windows application.
       Gecko.GeckoPreferences.Default("config.trim_on_minimize") = True

       ' Mozilla applications will periodically retrieve a blocklist from the server specified in extensions.blocklist.url.
       ' While Mozilla 's add-on system is a powerful feature, it can also be a vector for malware.
       ' Specific extensions can be blocklisted from a central server (by default, addons.mozilla.org).
       ' Value = Determines wheter to retrieve a blocklist to restrict extension installation.
       Gecko.GeckoPreferences.Default("extensions.blocklist.enabled") = False

   End Sub