Skip to content

saaminathan

Forum Replies Created

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #186753
    saaminathan
    Member

    Hi Chike

    I have successfully opened a IM window but having difficulty in sending a auto IM message. Below is the code i have generated but ts doesnt send the IM. Please assist. Thank you

     

    In below code, i select a list of names as playername and then open an IM window for their name .

    playername = ListBox30.Items(ListBox30.SelectedIndex)

    HighlightNic(playername)
    PostMessage(FindWindow(mdlPalInfo.ChatRoomClass, CtrlRoomSelector1.RoomName), WM_COMMAND, mdlPalInfo.IMfromRoomCommand, 0)

    ChatRTB1.Text = gamemsg
    imsentchat = GetChild(mdlPalInfo.ChatRoomClass, playername, mdlPalInfo.SendTextUD) <—–[[ The issue is here. The command doesnt get the IM window handle with the playername]]
    SendPalTxt(imsentchat, ChatRTB1.Rtf)

     

    #186755
    saaminathan
    Member

    BTW you can simply ListBox28.Items.AddRange(NicArray) instead of looping and probably get rid of the if too

    Hi Chike

    Thank you for the tip. I have another query. How do i lower hand and how do i get the handle for lowerhand ?

    Thank you

     

    #186757
    saaminathan
    Member

    Hi Chike

    I checked the issue and resolved it.. Now everything working perfectly.

    #186759
    saaminathan
    Member

    Hi Chike and Loco

    Thank you for all the assistance. I have completed the code to get the mic status. But I get the following exception and nothing resolves it. Please assist.

    An unhandled exception of type ‘System.NullReferenceException’ occurred in Paltalk Bot.exe

    Additional information: Object reference not set to an instance of an object.

    Private Sub GetAllUserList()
    Dim i As Integer
    Dim NicArray() As String
    ‘Empty the listbox
    ListBox28.Items.Clear()
    ‘Add nics to a listbox
    Dim iHnd As IntPtr = mdlHnd.GetChild(ChatRoomClass, Me.CtrlRoomSelector1.RoomName, NicListID)
    If iHnd <> IntPtr.Zero Then
    NicArray = mdlSysListView.GetAllSLVItems(iHnd)
    If NicArray.Length > 0 Then                       <————- This is the line with the exception
    For i = 0 To NicArray.Length – 1
    ListBox28.Items.Add(NicArray(i))
    Next
    End If
    End If
    End Sub

    #186762
    saaminathan
    Member

    Hi Chike,

     

    I got it and have read the flags. Thank you very much.

    #186763
    saaminathan
    Member

    Hi Chike

    Below is the updated code. It returns an empty string. What might be wrong?

    Public Function GetSLVSelectedImageItem(ByVal lstviewhwnd As IntPtr) As String
    Dim result As Integer
    Dim myItem As LV_ITEMA
    Dim pHandle As Integer
    Dim pStrBufferMemory As Integer
    Dim pMyItemMemory As Integer
    Dim strBuffer() As Byte
    Dim index As Integer
    Dim tmpString As String = String.Empty
    Dim ProcessID As Integer
    Dim usernum, itemIndex As Integer
    Dim i As Short
    itemIndex = SendMessage(lstviewhwnd, LVM_GETNEXTITEM, -1, LVNI_SELECTED)
    usernum = SendMessage(lstviewhwnd, LVM_GETITEMCOUNT, 0, 0)
    '**********************
    'init the string buffer
    '**********************
    ReDim strBuffer(StringBufferLength)
    '***********************************************************
    'open a handle to the process and allocate the string buffer
    '***********************************************************
    Call GetWindowThreadProcessId(lstviewhwnd, ProcessID)
    pHandle = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, ProcessID)
    pStrBufferMemory = VirtualAllocEx(pHandle, 0, StringBufferLength, MEM_COMMIT, PAGE_READWRITE)
    '************************************************************************************
    'initialize the local LV_ITEM structure
    'The myItem.iSubItem member is set to the index of the column that is being retrieved
    '************************************************************************************
    myItem.mask = LVIF_IMAGE Or LVIF_TEXT
    myItem.iItem = i
    myItem.iSubItem = 0
    
    '**********************************************************
    'write the structure into the remote process's memory space
    '**********************************************************
    
    pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem) + StringBufferLength, MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE)
    pStrBufferMemory = pMyItemMemory + Len(myItem)
    
    '*************************************************************
    '*************************************************************
    '*************************************************************
    
    ' i = itemIndex
    '*************************************************************
    'send the get the item message and write back the memory space
    '*************************************************************
    myItem.pszText = pStrBufferMemory
    myItem.cchTextMax = StringBufferLength
    result = SendMessage(lstviewhwnd, LVM_GETITEM, 0, pMyItemMemory)
    ' result = SendMessage(lstviewhwnd, LVM_GETITEM, i, pMyItemMemory)
    
    result = ReadProcessMemory(pHandle, pStrBufferMemory, strBuffer(0), StringBufferLength, 0)
    result = ReadProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0)
    '**************************************************
    'turn the byte array into a string and send it back
    '**************************************************
    For index = LBound(strBuffer) To UBound(strBuffer)
    If Chr(strBuffer(index)) = vbNullChar Then Exit For
    tmpString = tmpString & Chr(strBuffer(index))
    Next index
    tmpString = Trim(tmpString)
    MsgBox(tmpString)
    '**************************************************
    'deallocate the memory and close the process handle
    '**************************************************
    result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE)
    result = VirtualFreeEx(pHandle, pStrBufferMemory, 0, MEM_RELEASE)
    result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE)
    result = CloseHandle(pHandle)
    If Len(tmpString) > 0 Then GetSLVSelectedImageItem = tmpString
    Return tmpString
    End Function
    #186765
    saaminathan
    Member

    Hi Chike

    I have changed the code as per your suggestion but then the string returned by the function is empty. what did i do wrong here? Thank you in advance.

    My code below :

    Public Function GetSLVSelectedImageItem(ByVal lstviewhwnd As IntPtr) As String
    Dim result As Integer
    Dim myItem As LV_ITEMA
    Dim pHandle As Integer
    Dim pStrBufferMemory As Integer
    Dim pMyItemMemory As Integer
    Dim strBuffer() As Byte
    Dim index As Integer
    Dim tmpString As String = String.Empty
    Dim ProcessID As Integer
    Dim usernum, itemIndex As Integer
    Dim i As Short
    itemIndex = SendMessage(lstviewhwnd, LVM_GETNEXTITEM, -1, LVNI_SELECTED)
    usernum = SendMessage(lstviewhwnd, LVM_GETITEMCOUNT, 0, 0)
    '**********************
    'init the string buffer
    '**********************
    ReDim strBuffer(StringBufferLength)
    '***********************************************************
    'open a handle to the process and allocate the string buffer
    '***********************************************************
    Call GetWindowThreadProcessId(lstviewhwnd, ProcessID)
    pHandle = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, ProcessID)
    pStrBufferMemory = VirtualAllocEx(pHandle, 0, StringBufferLength, MEM_COMMIT, PAGE_READWRITE)
    '************************************************************************************
    'initialize the local LV_ITEM structure
    'The myItem.iSubItem member is set to the index of the column that is being retrieved
    '************************************************************************************
    myItem.mask = LVIF_IMAGE
    myItem.iSubItem = 0
    myItem.pszText = pStrBufferMemory
    myItem.cchTextMax = StringBufferLength
    '**********************************************************
    'write the structure into the remote process's memory space
    '**********************************************************
    pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem), MEM_COMMIT, PAGE_READWRITE)
    result = WriteProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0)
    
    '*************************************************************
    '*************************************************************
    '*************************************************************
    i = itemIndex
    '*************************************************************
    'send the get the item message and write back the memory space
    '*************************************************************
    result = SendMessage(lstviewhwnd, LVM_GETITEM, i, pMyItemMemory)
    result = ReadProcessMemory(pHandle, pStrBufferMemory, strBuffer(0), StringBufferLength, 0)
    result = ReadProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0)
    '**************************************************
    'turn the byte array into a string and send it back
    '**************************************************
    For index = LBound(strBuffer) To UBound(strBuffer)
    If Chr(strBuffer(index)) = vbNullChar Then Exit For
    tmpString = tmpString & Chr(strBuffer(index))
    Next index
    tmpString = Trim(tmpString)
    '**************************************************
    'deallocate the memory and close the process handle
    '**************************************************
    result = VirtualFreeEx(pHandle, pStrBufferMemory, 0, MEM_RELEASE)
    result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE)
    result = CloseHandle(pHandle)
    If Len(tmpString) > 0 Then GetSLVSelectedImageItem = tmpString
    Return tmpString
    End Function
    End Module
    #186769
    saaminathan
    Member

    Oh my bad. Sorry Chike.

    Thank you for the quick reply.

    Will check and try now.

    #186771
    saaminathan
    Member

    Hi Loco

    Thank you for the code snippet, how do I read the flags from the user list? Please advise or show some sample code.

    #186773
    saaminathan
    Member

    Hi Loco

    Thank you for the source code. are you still updating the code? I want to learn how to check who is on the mic and how many people have their hands raised. Any references or suggestions?

Viewing 10 posts - 1 through 10 (of 10 total)