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 Temas
Páginas: 1 [2]
11  Programación / Programación Visual Basic / MBR en: 16 Febrero 2009, 19:54 pm
Se puede modificar el MBR de un Pen Drive desde el code con Visual Basic para hacerlo Booteable ?

Gracias y saludos
12  Programación / Programación Visual Basic / Pasar variables Entre Aplicaciones (SRC) en: 10 Febrero 2009, 16:28 pm
Hola, dejo un ejemplo de como mandar una variable por memoria desde una aplicacion a otra y viceversa. Uso SendMessage con SETTEXT para enviar y SendMessage con GETTEXT para recibir.
Hay que compilar los dos Proyectos (Proyecto1 y Proyecto2) y luego ejecutar Proyecto1.

Actualizado 27/11/2010

http://www.megaupload.com/?d=J3G98NQ0




Saludos
13  Programación / Programación Visual Basic / Interceptar Click "ajenos" con SendMessage (Ejemplo) en: 20 Enero 2009, 01:42 am
Este es un simple ejemplo de como interceptar Clcks en botones de una aplicación externa, en este caso la calculadora de windows XP (en vista y seven hay que cambiar las clases) usando la constante BM_GETSTATE para SendMessage cuyo valor de retorno es de 512 si el button recibe un click, retorno de 620 si el button tiene el foco y retono 0 si no tiene foco, son retornos "especiales" para la calculadora ya que los retornos de casi todos los button de otras aplicaciones son de 44 si reciben el click o de 108 si el click se provoca con la barra espaciadora. se pueden saber los retornos con:

MsgBox SendMessage(Hndl, BM_GETSTATE, 0, 0) 

otras constantes para aprovechar

Private Const BM_GETSTATE = &HF2
Private Const WM_SETFOCUS = &H7
Private Const WM_KILLFOCUS = &H8
Private Const WM_ENABLE = &HA

Código:

Option Explicit

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long


Private Const BM_GETSTATE = &HF2

Private Sub Form_Load()
' cierro las calculadodas abiertas
While FindWindow("SciCalc", vbNullString) <> 0
Call SendMessage(FindWindow("SciCalc", vbNullString), &H112, &HF060&, 0)
Wend
Shell "calc"
Timer1.Interval = 100
End Sub

Private Sub Form_Unload(Cancel As Integer)
' cierro las calculadodas abiertas
While FindWindow("SciCalc", vbNullString) <> 0
Call SendMessage(FindWindow("SciCalc", vbNullString), &H112, &HF060&, 0)
Wend
End Sub

Private Sub Form_DblClick()
Shell "calc"
End Sub

Private Sub Timer1_Timer()

Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, &H2 Or &H1)

Dim Hndl As Long: Dim i As Long: Dim x As Long
Dim H(0 To 9) As Long: Dim ch(0 To 9) As Long

Hndl = FindWindow("scicalc", vbNullString)
If Hndl <> 0 Then
   
  For i = 0 To 9
    H(i) = FindWindowEx(Hndl, 0, vbNullString, i)
    ch(i) = SendMessage(H(i), BM_GETSTATE, 0, 0)
    If ch(i) = 512 Then Me.Cls: Me.Print "FOCO BOTON " & i
    If ch(i) = 620 Then
      Me.Cls: Me.Print "CLICK EN BOTON " & i
      x = GetTickCount: While GetTickCount < x + 450: DoEvents: Wend
    End If
  DoEvents
  Next i
   
  If ch(0) = 0 And ch(1) = 0 And ch(2) = 0 And ch(3) = 0 And ch(4) = 0 _
  And ch(5) = 0 And ch(6) = 0 And ch(7) = 0 And ch(8) = 0 And ch(9) = 0 _
  Then Me.Cls: Me.Print "NINGUN BOTON NUMÉRICO TIENE FOCO"
 
Else
   Me.Cls: Me.Print "CALCULADORA CERRADA"
End If

End Sub



Saludos

   
14  Programación / Programación Visual Basic / Windows7 (Beta1) y VB 6.0 en: 10 Enero 2009, 20:30 pm
Termino de bajar la version Beta 1 del windows7 (en ingles), me pareció otra version del "vista" con menos requerimientos de harware, bueno, lo primero que hice fue probar algunas Apis (funcionaron todas las que usé) y lo segundo instalar VB6 Studio, me tiró un par de carteles  sobre Setup.exe y Acmboot.exe (mi ingles es limitado) pero se instaló completa y a primera "vista" funciona.

las version 32 bits (x86) y la version 64 bits (x64) se pueden bajar desde:

http://www.mundowindows.com/

como es obvio, son imagenes iso para dvd de 2.43 GB y 3.15 GB


PD1: segun la informacion que tengo Microsoft limitará a 2.500.000 las activaciones de esta version, el que lo quiera, a apurarse


PD2: Tal vez el mensaje no se encuadre totalmente el este foro pero quize compartir la información con la gente del foro donde participo.

Saludos
15  Programación / Programación Visual Basic / Cerrar todas las Ventanas (C/S Taskkill) en: 7 Enero 2009, 21:23 pm
Con este código intento cerrar todas Aplicaciones (no procesos) con ventanas (visibles con y sin bordes) que se encuentran abiertas, con el Api SendMesssage (que me permite guardar los cambios) o con Taskkill (que cierra todo sin pedir permiso, ignorando todos los cambios), por lo tanto no se olviden de guardar todo antes de aplicar con Taskkill.

La pregunta es como puedo evitar que se cierre el explorer cuando tengo que cerrar las pantallas sin bordes, para no tener que ejecutarlo de nuevo al final ?,

Private Sub Command1_Click()
EnumWindows AddressOf EnumWindowsProc, ByVal 0&
If Check1.Value = 1 Then
  Dim x As Long: x = GetTickCount: While GetTickCount < x + 500: Wend
  Shell "explorer.exe"
End If
End Sub


No doy con la clase del explorer para poder agregarla al if de EnumWindowsProc 

Public Function EnumWindowsProc(ByVal Hwnd As Long, ByVal lParam As Long) As Boolean
  If TaskWindow(Hwnd) Then
    If GetClsName(Hwnd) <> "Shell_TrayWnd" or GetClsName(Hwnd) <> "Classe_explorer" Then
...
...
...

  EnumWindowsProc = True
End Function

Nota1: Hay que compilar y guardar para ejecutarlo
Nota2: CTL-ALT-SUP (Aministrador, aplicaciones, tarea neva..., explorer, aceptar) si hace falta volver el explorer


Formulario
Código:

Option Explicit

Private Sub Form_Load()
   
   If App.PrevInstance Then End
   Call SetWindowPos(Me.Hwnd, -1, 0, 0, 0, 0, &H2 Or &H1)
   
   MsgBox "Ejecutar Compilado " + vbCrLf + vbCrLf + "Taskkill no Guarda cambios en las Aplicaciones abiertas, cierra directamente", vbCritical, "Atención"
   
   Me.Caption = "Ejecutar Compilado": Me.Top = 1680: Me.Left = 1560
   Option1.Caption = "Cerrar con  Taskill   (No pide ni guarda nada, cierra todo)"
   Option2.Caption = "Cerrar con API  SendMessage  (Pedirá guardar Cambios)"
   Check1.Caption = "Incluir  Ventanas  sin  Bordes   ( Cerrará el explorer )"
   Option1.Left = 120: Option1.Width = 4465: Option1.Top = 960
   Option2.Value = True
   Option2.Left = 120: Option2.Width = 4465: Option2.Top = 360
   Check1.Left = 120: Check1.Width = 4465: Check1.Top = 2460
   Command1.Caption = "Aceptar"
   Command1.Left = 1560: Command1.Top = 1680

End Sub

Private Sub Command1_Click()
 
EnumWindows AddressOf EnumWindowsProc, ByVal 0&
 
If Check1.Value = 1 Then
  Dim x As Long: x = GetTickCount: While GetTickCount < x + 500: Wend
  Shell "explorer.exe"
End If

End Sub


Módulo
Código:

Option Explicit
Declare Function GetTickCount Lib "kernel32" () As Long
Declare Function SetWindowPos Lib "user32" (ByVal Hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal Hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal Hwnd As Long, ByVal wIndx As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal Hwnd As Long, lpdwprocessid As Long) As Long
Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetModuleFileNameExA Lib "PSAPI.DLL" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFilename As String, ByVal nSize As Long) As Long
Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
Const IsTask = &H10000000 Or &H800000 'solo ventanas visibles y con bordes
Const IsTask2 = &H10000000 ' solo ventanas visibles

Public Function EnumWindowsProc(ByVal Hwnd As Long, ByVal lParam As Long) As Boolean
  If TaskWindow(Hwnd) Then
    If GetClsName(Hwnd) <> "Shell_TrayWnd" Then
      If Form1.Option1.Value = True Then
        Dim idProc As Long: Call GetWindowThreadProcessId(Hwnd, idProc)
        Dim Handle_Proceso As Long: Handle_Proceso = OpenProcess(&H400 + &H10, 0, idProc)
        Dim Buffer As String: Buffer = Space(255)
        Dim ret As Long: ret = GetModuleFileNameExA(Handle_Proceso, 0, Buffer, 255)
        Dim ruta As String: ruta = Left(Buffer, ret)
        Call CloseHandle(Handle_Proceso)
        If Mid(ruta, InStrRev(ruta, "\") + 1) <> App.EXEName + ".exe" Then
          Shell "cmd.exe /c Taskkill /f /IM " + Mid(ruta, InStrRev(ruta, "\") + 1)
        End If
      End If
      If Form1.Option2.Value = True Then
        If Hwnd <> Form1.Hwnd Then Call SendMessage(Hwnd, &H112, &HF060&, 0)
      End If
    End If
  End If
 
  'If EnumWindowsProc = False Then Open App.Path & "\archivo.txt" For Append As #1: Print #1, GetClsName(Hwnd): Close #1
 
  EnumWindowsProc = True

End Function

Private Function TaskWindow(hwCurr As Long) As Long
  Dim lngStyle As Long: lngStyle = GetWindowLong(hwCurr, (-16))
  If Form1.Check1.Value = 0 Then If (lngStyle And IsTask) = IsTask Then TaskWindow = True
  If Form1.Check1.Value = 1 Then If (lngStyle And IsTask2) = IsTask2 Then TaskWindow = True
End Function

Private Function GetClsName(handle As Long) As String
    Dim lpClassName As String: lpClassName = Space(256)
    Dim RetVal As Long: RetVal = GetClassName(handle, lpClassName, 256)
    GetClsName = Left$(lpClassName, RetVal)
End Function


Sauludos

16  Programación / Programación Visual Basic / Matar Proceso con Una linea (SRC) en: 4 Enero 2009, 02:58 am
No hay mucho que agregar, solo hace falta el nombre del ejecutable del proceso y para el que no sepa reestablecer el explorer luego de ejecutar el code del ejemplo (desaparecen los iconos, barra de inicio, menús de contexto, Etc, Etc) lo haga desde CTL-ALT-SUP (Aministrador, aplicaciones, tarea neva..., explorer, aceptar)

Private Sub Form_Load()
Shell "cmd.exe /c Taskkill /f /IM " + "EXPLORER.EXE"
End Sub

PD: para enumerar los procesos que esten corriendo "WMI" o "API EnumProcesses"

Saludos

17  Programación / Programación Visual Basic / Handle de un Label en: 11 Diciembre 2008, 19:05 pm
Hola, alguien sabe como conocer el Hwn de un label creado con VB6 ?

Saludos

18  Programación / Programación Visual Basic / Evitar que cierren mi Aplicación (SRC). en: 6 Diciembre 2008, 06:17 am
Hola, con este code Trato de evitar que cierren mi aplicacion  o un proceso "X" desde el Administrador de tareas de XP, en el Timer1 busco el HWn del"SyslistView32" de  procesos en el administrador, luego con la funcion "GetItemSelected" busco el numero de item que el usuario intenta seleccionar, con este item y la funcion "ListViewGetText" obtengo el string del item que se seleccionó, si este string es igual al nombre de mi aplicación (en este caso App.EXEName + ".exe" o EXPLORER.EXE) automaticamente con la funcion SelectedItem selecciono el item siguiente , pero solo cuando el usuario selecciona mi aplicación o el proceso que no se quiera cerrar.

If t = App.EXEName + ".exe" Then Call SelectedItem(Handle, x)
If t = "EXPLORER.EXE" Then Call SelectedItem(Handle, x)

Para que funcione hay que compilar el proyecto, y ejucutar el exe creado.

Por último lo probé en windows Xp (pro) , seria bueno probarlo en otros windows.


FORMULARIO (MODIFICADO EL 09/12/2008)

Código:

Option Explicit

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)


Dim Handle As Long: Dim x As Long
Dim t As String: Dim t2 As String

Private Sub Form_Load()

App.TaskVisible = False
Timer1.Interval = 15

End Sub

Private Sub Timer1_Timer()


Handle = FindWindow("#32770", vbNullString)
Handle = FindWindowEx(Handle, 0, "#32770", vbNullString)
Handle = FindWindowEx(Handle, 0, "SyslistView32", vbNullString)


  x = GetItemSelected(Handle)
  t = ListViewGetText(Handle, 0, x - 1)
 
  'Me.Caption = FindWindow("#32770", vbNullString) & "  " & x & "  " & Len(t)
 
  If FindWindow("#32770", vbNullString) <> 0 And x <> 0 And t = "" Then
    Call SendMessage(FindWindow("#32770", vbNullString), &H112, &HF060&, 0)
    keybd_event &H12, 0, 0, 0: keybd_event &H12, 0, &H2, 0
  End If
  If FindWindow("#32770", vbNullString) <> 0 And x <> 0 And t = "" Then
    If FindWindow("#32768", vbNullString) <> 0 Then
      Call SendMessage(FindWindow("#32770", vbNullString), &H112, &HF060&, 0)
      keybd_event &H12, 0, 0, 0: keybd_event &H12, 0, &H2, 0
    End If
  End If
   
  If t = App.EXEName + ".exe" Then Call SelectedItem(Handle, x)
  If t = "EXPLORER.EXE" Then Call SelectedItem(Handle, x)

End Sub




MODULO

Código:

Option Explicit
Private Type LVITEM
    mask As Long
    iItem As Long
    iSubitem As Long
    state As Long
    stateMask As Long
    pszText As Long
    cchTextMax As Long
    iImage As Long
    lParam As Long
    iIndent As Long
End Type
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function VirtualFreeEx Lib "kernel32" (ByVal hProcess As Long, lpAddress As Any, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Public Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long
Private Const LVIF_IMAGE = &H2
Private Const LVIF_TEXT = &H1
Private Const LVM_FIRST As Long = &H1000
Private Const LVM_GETITEM As Long = (LVM_FIRST + 5)
Private Const LVM_GETITEMCOUNT = (LVM_FIRST + 4)
Private Const LVM_GETITEMSTATE = (LVM_FIRST + 44)
Private Const LVIS_SELECTED = &H2
Private Const LVM_SETITEMSTATE = (LVM_FIRST + 43)
Private Const LVIF_STATE = &H8&
Private Const PAGE_READWRITE = &H4&
Private Const MEM_RESERVE = &H2000
Private Const MEM_COMMIT = &H1000
Private Const MEM_RELEASE = &H8000
Private Const PROCESS_VM_OPERATION = &H8
Private Const PROCESS_VM_READ = &H10
Private Const PROCESS_VM_WRITE = &H20
Private hWndlvw As Long
Function ListViewGetText(ByVal hwnd As Long, ByVal iSubitem As Integer, ByVal iItem As Integer) As String
    Dim lngProcID As Long, lngProcHandle As Long
    Dim typLvItem As LVITEM, strLvItem As String
    Dim lngVarPtr1 As Long, lngVarPtr2 As Long
    Dim lngMemVar1 As Long, lngMemVar2 As Long
    Dim lngMemLen1 As Long, lngMemLen2 As Long
    Call GetWindowThreadProcessId(hwnd, lngProcID)
    If lngProcID <> 0 Then
        lngProcHandle = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, lngProcID)
        If lngProcHandle <> 0 Then
            strLvItem = String(255, vbNullChar)
            lngVarPtr1 = StrPtr(strLvItem)
            lngVarPtr2 = VarPtr(typLvItem)
            lngMemLen1 = LenB(strLvItem)
            lngMemLen2 = LenB(typLvItem)
            lngMemVar1 = VirtualAllocEx(lngProcHandle, 0, lngMemLen1, MEM_RESERVE Or MEM_COMMIT, PAGE_READWRITE)
            lngMemVar2 = VirtualAllocEx(lngProcHandle, 0, lngMemLen2, MEM_RESERVE Or MEM_COMMIT, PAGE_READWRITE)
            With typLvItem
                .cchTextMax = 255
                .iItem = iItem
                .iSubitem = iSubitem
                .mask = LVIF_TEXT
                .pszText = lngMemVar1
            End With
            Call WriteProcessMemory(lngProcHandle, ByVal lngMemVar1, ByVal lngVarPtr1, lngMemLen1, 0)
            Call WriteProcessMemory(lngProcHandle, ByVal lngMemVar2, ByVal lngVarPtr2, lngMemLen2, 0)
            Call SendMessage(hwnd, LVM_GETITEM, ByVal 0, ByVal lngMemVar2)
            Call ReadProcessMemory(lngProcHandle, ByVal lngMemVar1, ByVal lngVarPtr1, lngMemLen1, 0)
            strLvItem = StrConv(strLvItem, vbUnicode)
            strLvItem = Left(strLvItem, InStr(1, strLvItem, vbNullChar) - 1)
            ListViewGetText = strLvItem
            Call VirtualFreeEx(lngProcHandle, ByVal lngMemVar1, lngMemLen1, MEM_RELEASE)
            Call VirtualFreeEx(lngProcHandle, ByVal lngMemVar2, lngMemLen2, MEM_RELEASE)
            Call CloseHandle(lngProcHandle)
        End If
    End If
End Function
Private Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
    hWndlvw = FindWindowEx(hwnd, 0&, "ListView20WndClass", "")
    EnumWindowsProc = (hWndlvw = 0) 'Stop when we find first listview
End Function

'Public Function FindListView() As Long
'    EnumWindows AddressOf EnumWindowsProc, 0&
'    FindListView = hWndlvw
'End Function

Public Function SelectedItem(ByVal hwnd As Long, ItemPos As Long)
    Dim lProcID As Long
    Dim hProc As Long
    Dim lxprocLVITEM As Long
    Dim LV_ITEM As LVITEM
   
   
    GetWindowThreadProcessId hwnd, lProcID ' Get the process ID in which the ListView is running
    If lProcID <> 0 Then
        hProc = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, lProcID) ' makwe sure we have read write permissions in the process space
        If hProc <> 0 Then
            lxprocLVITEM = VirtualAllocEx(hProc, 0, LenB(LV_ITEM), MEM_RESERVE Or MEM_COMMIT, PAGE_READWRITE) ' Grab enough memory in the other procedure's space to hold our LV_ITEM
           
            ' Set up our local LV_ITEM to change the selected item
            LV_ITEM.mask = LVIF_STATE
            LV_ITEM.state = True
            LV_ITEM.stateMask = LVIS_SELECTED
           
            ' Copy the local LV_ITEM into the space we reserved in the foreign process
            WriteProcessMemory hProc, ByVal lxprocLVITEM, ByVal VarPtr(LV_ITEM), LenB(LV_ITEM), 0
           
            ' Now send the message, but pass the address of the copy of our LV_ITEM that now exists in the foreign process instead of our local versiony
           
            SendMessage hwnd, LVM_SETITEMSTATE, ItemPos, ByVal lxprocLVITEM
           
            ' Clean up
            VirtualFreeEx hProc, ByVal lxprocLVITEM, LenB(LV_ITEM), MEM_RELEASE
            CloseHandle hProc
        End If
    End If
End Function
Function GetListViewCount(ByVal hwnd As Long) As Long
GetListViewCount = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, ByVal 0)
End Function
Function GetItemSelected(hwnd As Long) As Long
Dim i As Long, Index As Long
For i = 1 To GetListViewCount(hwnd)
Index = SendMessage(hwnd, LVM_GETITEMSTATE, i - 1, ByVal LVIS_SELECTED)
If Index > 0 Then
GetItemSelected = i
Exit For
End If
Next
End Function



PD 1: Las Funciones "GetItemSelected" y "ListViewGetText" me las pasó Leandro hace unos meses.

PD 2: Si el code le sirve a alguien y lo podemos mejorar seria buenisimo, y si no sirve lo descartamos

EDITADO 09/12/2008

PD 3: A continuación dejo el código original del formulario que publiqué en este mensaje, mantengo este code (que modifiqué mas arriba) porque las respuestas de Seba123neo y de Leandro que siguen a continuación se refieren a este code, pero repito el que vale es el code del formulario que está mas arriba

FORMULARIO ORIGINAL (no válido)

'---------------------------------------------------------------------------------------
Option Explicit

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function ShowWindow _
Lib "user32" _
(ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long

Private Const SW_HIDE = 0

Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Private Const WM_SYSCOMMAND = &H112
Private Const SC_CLOSE = &HF060&

Private Declare Function IsWindowEnabled Lib "user32" _
(ByVal hwnd As Long) As Long

Private Declare Function EnableWindow Lib "user32" _
(ByVal hwnd As Long, ByVal fEnable As Long) As Long

Dim Handle As Long
Dim Handle2 As Long

Dim Index As Long

Dim ret As Long


Private Sub Form_Load()

Timer1.Interval = 25
Timer2.Interval = 25
Timer2.Enabled = False
'Me.Hide

End Sub

Private Sub Timer1_Timer()

Handle = FindWindow("#32770", vbNullString)
Handle = FindWindowEx(Handle, 0, "#32770", vbNullString)
Handle = FindWindowEx(Handle, 0, "SyslistView32", vbNullString)

Dim x As Long: x = GetItemSelected(Handle)
Dim t As String: t = ListViewGetText(Handle, 0, x - 1)

If t = "EXPLORER.EXE" Or t = "Project1.exe" Or t = "Project1" Then

  Timer2.Enabled = True
  'Handle = FindWindow("#32770", vbNullString)
  'Call SendMessage(Handle, WM_SYSCOMMAND, SC_CLOSE, CLng(0))

  Handle = FindWindow("#32770", vbNullString)
  Handle = FindWindowEx(Handle, 0, "#32770", vbNullString)
  Handle = FindWindowEx(Handle, 0, "Button", "&Terminar proceso")

  ret = IsWindowEnabled(Handle)
  If ret = 1 Then Call EnableWindow(Handle, 0)


  Handle = FindWindow("#32770", vbNullString)
  Handle = FindWindowEx(Handle, 0, "#32770", vbNullString)
  Handle = FindWindowEx(Handle, 0, "Button", "&Finalizar tarea")

  ret = IsWindowEnabled(Handle)
  If ret = 1 Then Call EnableWindow(Handle, 0)

Else

  Timer2.Enabled = False

End If

End Sub

 
Private Sub Timer2_Timer()


Handle2 = FindWindow("#32768", vbNullString)
Call ShowWindow(Handle2, SW_HIDE)

End Sub

`-------------------------------------------------------------------------------------------
19  Programación / Programación Visual Basic / Color del Pixel en donde está el Mouse en: 30 Octubre 2008, 00:29 am
'Hola alguien me puede ayudar para saber de que color es el pixel en que se encuentra el puntero del mouse, estoy intentando con el sig.code pero no sale.

Código:

Option Explicit
Private Type POINTAPI
    X As Long
    Y As Long
End Type
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim ret As Long
Dim Handle As Long
Dim Cor As POINTAPI
Dim hhdc As Long
 
Private Sub Form_Load()
Timer1.Interval = 10
End Sub
 
Private Sub Timer1_Timer()

'Obtengo la coordenada del Mouse
 ret = GetCursorPos(Cor)
'Recupero el HWND del comntrol asociado a esa coordenada
Handle = WindowFromPoint(Cor.X, Cor.Y)
'Obtengo el hdc del control
hhdc = GetDC(Handle)
Label1.Caption = Hex(GetPixel(hhdc, Cor.X, Cor.Y))
Label2 = Cor.X & "  " & Cor.Y

End Sub


'Gracias & Saludos
Páginas: 1 [2]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines