- This topic has 0 replies, 1 voice, and was last updated 17 years ago by autopilot.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
March 20, 2007 at 6:30 am #187987autopilotMember
For use withVB 2005
The attached module is what I use to find the different parts of the Paltalk window. It is based on code that I found here a long time ago but can not find any more. I do not know who created it originally, but I have modified it to make it more versitile. If used with my automatic paltalk detection program, you should have all the pieces to use this.Below are 2 examples of how to use this module:
Private Sub SendPalText() RTB.Text = "Text to send" '******************* 'set rtb font & color if wanted here '******************* iHnd = FindWindowHnd(WindowClass, MyRoomName, _ RoomOutboundTextBoxClass, SendTxtIndex) SendMessageByString(iHnd, WM_SETTEXT, 0, RTB.Rtf) SendMessageByString(iHnd, WM_KEYDOWN, 13, 0) End Sub
Function FindNic() As String iHnd = FindWindowHnd(WindowClass, MyRoomName, SysListCtrlClass, _ NicListIndex) FindNic = GetListviewItem(iHnd) End Function
To use the FindNic sample, you will need to also have the GetListviewItem function (code from BattleStar-Galactica).
Structure LV_ITEMA Dim mask As Integer Dim iItem As Integer Dim iSubItem As Integer Dim state As Integer Dim stateMask As Integer Dim pszText As Integer Dim cchTextMax As Integer Dim iImage As Integer Dim lParam As Integer Dim iIndent As Integer End Structure Public Function GetListviewItem(ByVal lstviewhwnd As Integer) 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 itemIndex As Integer Dim tmpString As String = String.Empty Dim ProcessID As Integer Dim usernum As Integer Dim i As Short UserNic = String.Empty itemIndex = SendMessage(lstviewhwnd, LVM_GETNEXTITEM, _ -1, LVNI_SELECTED) usernum = SendMessage(lstviewhwnd, LVM_GETITEMCOUNT, _ 0, 0) '********************** 'init the string buffer '********************** ReDim strBuffer(MAX_LVMSTRING) '******************************************************** '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, MAX_LVMSTRING, _ 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_TEXT myItem.iSubItem = 2 myItem.pszText = pStrBufferMemory myItem.cchTextMax = MAX_LVMSTRING '******************************************************** '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_GETITEMTEXT, i, _ pMyItemMemory) result = ReadProcessMemory(pHandle, pStrBufferMemory, _ strBuffer(0), MAX_LVMSTRING, 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) Return tmpString End Function
Edit: we have a vb tag 😉
~Ghost
Edit: fixed variable names to match autodetecte project
autopilot -
AuthorPosts
Related
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.