VB 6.0 Connecting to Listview via Index

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #186576
    Admin
    Administrator

    Ok so I decided to update the Admin Bot, but I want to do it using via index, so far I can send and get text via index but to deal with the nick list Im still using the old fashion way

    Dim dlggroupchatwindowclass As Long, splitterwindowex As Long, classcpanecontainerex As Long
    Dim atladf As Long, atladff As Long, syslistview As Long
    Dim parent, child, alt As Long
    dlggroupchatwindowclass = FindWindow("dlggroupchat window class", Form1.Combo1.Text)
    splitterwindowex = FindWindowEx(dlggroupchatwindowclass, 0&, "splitterwindowex", vbNullString)
    splitterwindowex = FindWindowEx(splitterwindowex, 0&, "splitterwindowex", vbNullString)
    splitterwindowex = FindWindowEx(splitterwindowex, 0&, "splitterwindowex", vbNullString)
    splitterwindowex = FindWindowEx(splitterwindowex, 0&, "splitterwindowex", vbNullString)
    splitterwindowex = FindWindowEx(splitterwindowex, 0&, "splitterwindowex", vbNullString)
    classcpanecontainerex = FindWindowEx(splitterwindowex, 0&, "classcpanecontainerex", vbNullString)
    classcpanecontainerex = FindWindowEx(splitterwindowex, classcpanecontainerex, "classcpanecontainerex", vbNullString)
    atladf = FindWindowEx(classcpanecontainerex, 0&, "atl:00a2df60", vbNullString)
    atladff = FindWindowEx(atladf, 0&, "atl:00a2dff0", vbNullString)
    Call GetListviewItem(atladff)

    I though that using the listview index, which is 1 I could do something like this

    Dim iPHnd As Long
    iPHnd = getPalSubForm(WindowClass, Combo1.Text, SplittrWindow10, SplittrIndex10)
    ListHandle = ChatHnd(iPHnd, listIndex)

    with declaring in the form

    Const listindex As Integer = 1
    #186583
    Admin
    Administrator

    K I figure it out, I think 🙂 after being a lazy asz and doing search in the forums ehhehehehe
    I use this function on the form

    Private Function SystenViewHandle() As Long
    Dim iPHnd As Long
    iPHnd = getPalSubForm(WindowClass, Combo1.Text, SplittrWindow10, SplittrIndex10)
    SystenViewHandle = GetTheClassHnd(iPHnd, SysListView32index, "atl:00a2df60")
    Debug.Print ("SystenViewHandle- " & SystenViewHandle) ' for testing
    End Function

    and in the module

    Public Function GetTheClassHnd(ByVal ParentTargethwnd As Long, ByVal TargetIndex As Long, TargetCls As String) As Long
    'Returns a class's handle
    Dim retVal As Long
    mTargetSubClass = "atl:00a2dff0"
    mTargetSubClassIndex = TargetIndex
    IndexCount = 1
    retVal = EnumChildWindows(ParentTargethwnd, AddressOf EnumChildProc, TargetIndex)
    GetTheClassHnd = mSubFormHnd
    End Function

    and i’m calling with this

    Function NickGet()
    Dim iHnd As Long
    iHnd = SystenViewHandle
    Call GetListviewItem(iHnd)
    End Function

    My only concern is that paltalk will change atl:00a2dff0 and atl:00a2df60 with every new Build 🙄

    #186582
    Chike
    Member

    Why you send the atl name and then use another?
    Did you see the post I made on how to find the controlls by their control ID?

    #186581
    Admin
    Administrator

    lol you right I was using api spy and guess it should had be done that way, but if I only use atl:00a2dff0 it works fine.

    I haven’t read that post yet, where is it. another thing how about highlighting nicks with their index I tried using this in the old vb 6.0 programs in the form1(beacuse if I leave it in the module that’s in I have to declare a bunch of stuff :)) but I get an error

    Public Function MessageCrossProcess(ByVal hwnd As Long)
    Dim lProcID As Long
    Dim hProc As Long
    Dim lxprocLVITEM As Long
    Dim LVITEM As LV_ITEM
    Dim lItemPos As Long
    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) ' make sure we have read write permissions in the process space
    If hProc 0 Then
    lxprocLVITEM = VirtualAllocEx(hProc, 0, LenB(LVITEM), 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
    LVITEM.mask = LVIF_STATE
    LVITEM.state = True
    LVITEM.stateMask = LVIS_SELECTED Or LVIS_FOCUSED ' Just enforcing the selection better than in original version by moving the focus as well
    ' Copy the local LV_ITEM into the space we reserved in the foreign process
    WriteProcessMemory hProc, ByVal lxprocLVITEM, ByVal VarPtr(LVITEM), LenB(LVITEM), 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 version
    ' Aigh Peeps this wha you need to change in order to higlight the item you want :)
    lItemPos = "0" ' first item
    SendMessage hwnd, LVM_SETITEMSTATE, lItemPos, ByVal lxprocLVITEM
    ' Clean up
    VirtualFreeEx hProc, ByVal lxprocLVITEM, LenB(LVITEM), MEM_RELEASE
    CloseHandle hProc
    End If
    End If
    End Function
    Public Function MessageCrossProcess2(ByVal hwnd As Long)
    Dim lProcID As Long
    Dim hProc As Long
    Dim lxprocLVITEM As Long
    Dim LVITEM As LV_ITEM
    Dim lItemPos As Long
    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) ' make sure we have read write permissions in the process space
    If hProc 0 Then
    lxprocLVITEM = VirtualAllocEx(hProc, 0, LenB(LVITEM), 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
    LVITEM.mask = LVIF_STATE
    LVITEM.state = True
    LVITEM.stateMask = LVIS_SELECTED Or LVIS_FOCUSED ' Just enforcing the selection better than in original version by moving the focus as well
    ' Copy the local LV_ITEM into the space we reserved in the foreign process
    WriteProcessMemory hProc, ByVal lxprocLVITEM, ByVal VarPtr(LVITEM), LenB(LVITEM), 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 version
    ' Aigh Peeps this wha you need to change in order to higlight the item you want :)
    lItemPos = Form1.Text22.Text ' first item
    SendMessage hwnd, LVM_SETITEMSTATE, lItemPos, ByVal lxprocLVITEM
    ' Clean up
    VirtualFreeEx hProc, ByVal lxprocLVITEM, LenB(LVITEM), MEM_RELEASE
    CloseHandle hProc
    End If
    End If
    End Function
    ' New example looks for a window with class SysListView32 that is hosted
    ' by a window whose caption matches the contents of strInWindowWithCaption
    Public Function FindListView(strInWindowWithCaption As String) As Long
    EnumWindows AddressOf EnumWindowsProc, StrPtr(strInWindowWithCaption)
    FindListView = hWndlvw
    End Function
    Private Function SystenViewHandle() As Long
    Dim iPHnd As Long
    Dim WindowClass As Long
    iPHnd = getPalSubForm(WindowClass, Form1.Combo1.Text, SplittrWindow10, SplittrIndex10)
    SystenViewHandle = GetTheClassHnd(iPHnd, SysListView32index, "atl:00a2df60")
    Debug.Print ("SystenViewHandle- " & SystenViewHandle) ' for testing
    End Function
    Private Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As String) As Long
    Dim strCaption As String
    Dim lLen As Long
    Dim hWndlvw As Long
    hWndlvw = SystenViewHandle
    ' If we've found a window with the SysListView32 class
    ' check to see if parent window caption is the one we are looking for
    If hWndlvw 0 Then
    lLen = GetWindowTextLength(hwnd)
    If lLen > 0 Then
    strCaption = Space(lLen)
    GetWindowText hwnd, strCaption, lLen + 1
    End If
    End If
    EnumWindowsProc = (hWndlvw = 0 And strCaption lParam)
    End Function

    I get an error in this part, invalid use of addressof

    Public Function FindListView(strInWindowWithCaption As String) As Long
    EnumWindows AddressOf EnumWindowsProc, StrPtr(strInWindowWithCaption)
    FindListView = hWndlvw
    End Function
    #186580
    Chike
    Member
    #186579
    Admin
    Administrator

    Man I got the idea of the post which is a genius idea, I just don’t know how to implement it. i tried adding it to a form and module to play with it and figure it out and the code turns red, like is misconfiguration 🙂 this is for vb 6 right?

    #186578
    Chike
    Member

    No it’s for VB.NET but there should be not much difference, Use Long instead intptr, and the parameter (ctl) should also be Long.
    Maybe there is a bit difference in external function declarations but it should not be a problem.
    I don’t have VB6 installed, not even on my XP I think so I cannot test it.

    #186577
    Admin
    Administrator

    Ah K 🙂 that’s why I gonna check it than, thanks

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.