- This topic has 25 replies, 6 voices, and was last updated 12 years ago by Departure.
-
AuthorPosts
-
July 24, 2012 at 2:13 pm #186845AdminAdministrator
String i did that 🙂 still when it was out of focus it didn’t work, aigh i think this is what you guys mean to do I added this code
Private Function SendTextHandle() As Integer
Dim iPHnd As Integer
iPHnd = mdlGetHnd.SubFormHndByClassNameWithMWClassWithPartialMWCaption(mdlPalInfo.ChatRoomClass, Me.CtrlRoomSelector1.RoomName, mdlPalInfo.SplitterClass, mdlPalInfo.SplitterIndex)
SendTextHandle = mdlGetHnd.SubFormHndByClassNameWithMWHnd(iPHnd, mdlPalInfo.ChatTextClass, mdlPalInfo.SendTextIndex)
Debug.Print("SendTextHandle - " & SendTextHandle) ' for testing
End Function
Sub TxtSendPal(ByRef DisHere As String)
Dim iHnd As Integer
'Send Text
iHnd = SendTextHandle
SendMessageByString(iHnd, WM_SETTEXT, 0, DisHere)
SendMessage(iHnd, WM_KEYDOWN, 13, 0)
End SubAnd I call it with
TxtSendPal((ChatRTB1.Rtf))
ChatRTB1.Focus()But the text in the rooms comes out with the char thingy like this
{rtf1ansiansicpg1252deff0deflang1033{fonttbl{f0fnilfcharset0 Tahoma;}}
{colortbl ;red255green0blue0;red146green0blue109;red36green0blue219;}
viewkind4uc1pardcf1bf0fs24 ercf2 trecf3 trcf0par
}Here how it is now 🙂
July 24, 2012 at 2:32 pm #186844AdminAdministratorLol I fix it 🙂 I change auto thingy to work with string thingy and got this
Private Function SendTxtHnd() As IntPtr
Dim iPHnd As Integer
iPHnd = mdlGetHnd.SubFormHndByClassNameWithMWClassWithPartialMWCaption(mdlPalInfo.ChatRoomClass, Me.CtrlRoomSelector1.RoomName, mdlPalInfo.SplitterClass, mdlPalInfo.SplitterIndex)
SendTxtHnd = mdlGetHnd.SubFormHndByClassNameWithMWHnd(iPHnd, mdlPalInfo.ChatTextClass, mdlPalInfo.SendTextIndex)
End Function
Private Sub SendPalTxt(ByVal EBHnd As IntPtr, ByVal RTF As String)
Dim iResult As Integer
' Send sext to send text window
iResult = SendMessage(EBHnd, WM_SETTEXT, 0, RTF)
' simulate enter key press
iResult = SendMessage(EBHnd, WM_KEYDOWN, 13, 0)
' simulate enter key release
iResult = SendMessage(EBHnd, WM_KEYUP, 13, 0)
End Sub
Private Sub SendChat()
SendPalTxt(SendTxtHnd, ChatRTB1.Rtf)
ChatRTB1.Focus()
End Suband call it with
SendChat()
So no more weird sht char :swift:
July 25, 2012 at 2:28 pm #186843AdminAdministratorHey Auto, I know you gonna work on the selecting nick thing next, but I got a quick question this code in your quickkeys program the module
mdlSysListView.vbDeclare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As Integer, ByVal flAllocationType As Integer, ByVal flProtect As Integer) As IntPtr
Declare Function VirtualFreeEx Lib "kernel32" (ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As Integer, ByVal dwFreeType As Integer) As Integer
Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As LV_ITEMA, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As LV_ITEMA, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Byte, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As StringBuilder, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcId As Integer) As IntPtr
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As IntPtr, ByRef lpdwProcessId As Integer) As Integer
Const StringBufferLength As Integer = 255
Const LVM_FIRST As Integer = &H1000
Const LVM_GETITEMCOUNT As Integer = (LVM_FIRST + 4)
Const LVM_GETNEXTITEM As Integer = (LVM_FIRST + 12)
Const LVM_FINDITEM As Long = (LVM_FIRST + 13)
Const LVM_SETITEMPOSITION As Integer = (LVM_FIRST + 15)
Const LVM_GETITEMPOSITION As Integer = (LVM_FIRST + 16)
Const LVM_GETITEMTEXT As Integer = (LVM_FIRST + 45)
Const LVM_SORTITEMS As Integer = (LVM_FIRST + 48)
Const LVM_GETSELECTEDCOUNT As Integer = (LVM_FIRST + 50)
Const LVM_GETITEM As Integer = (LVM_FIRST + 75)
Const LVNI_SELECTED As Integer = &H2
Const LVFI_PARAM As Integer = &H1
Const LVIF_TEXT As Integer = &H1
Const LVM_FINDITEMW As Integer = (LVM_FIRST + 83)
Const LVIS_SELECTED As Integer = &H2
Const LVIF_STATE As Integer = &H8
Const LVM_SETITEMSTATE As Integer = (LVM_FIRST + 43)
Const PROCESS_VM_OPERATION As Integer = &H8S
Const PROCESS_VM_READ As Integer = &H10S
Const PROCESS_VM_WRITE As Integer = &H20S
Const MEM_COMMIT As Integer = &H1000S
Const PAGE_READWRITE As Integer = &H4S
Const MEM_RELEASE As Integer = &H8000S
Const MEM_RESERVE As Integer = &H2000S
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 SLVItemIndex(ByVal lstviewhwnd As IntPtr, ByVal Item As String, ByRef ItemIndex As Integer) As Boolean
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 ItemCount As Integer
Dim i As Short
ItemCount = 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_TEXT
myItem.iSubItem = 2
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)
'*************************************************************
'*************************************************************
'*************************************************************
For i = 0 To ItemCount - 1
'*************************************************************
'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), 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)
If LCase(tmpString) = LCase(Item) Or LCase(tmpString) = "@" & LCase(Item) Then
ItemIndex = i
SLVItemIndex = True
Exit For
End If
tmpString = String.Empty
Next
'**************************************************
'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)
End Function
Public Function HighLightSLVItem(ByVal hwnd As IntPtr, ByVal ItemIndex As Integer) As Boolean
'found at
Dim lProcID As Integer
Dim hProc As IntPtr
Dim lxprocLVITEM As Integer
Dim LVITEM As LV_ITEMA
Dim lItemPos As Integer
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, Len(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
' Copy the local LV_ITEM into the space we reserved in the foreign process
WriteProcessMemory(hProc, lxprocLVITEM, LVITEM, Len(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 versiony
lItemPos = ItemIndex ' first item
SendMessage(hwnd, LVM_SETITEMSTATE, lItemPos, lxprocLVITEM)
' Clean up
VirtualFreeEx(hProc, lxprocLVITEM, Len(LVITEM), MEM_RELEASE)
CloseHandle(hProc)
HighLightSLVItem = True
End If
End If
End Function
Public Function GetSLVSelectedItem(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_TEXT
myItem.iSubItem = 2
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_GETITEMTEXT, 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 GetSLVSelectedItem = tmpString
Return tmpString
End FunctionAre you suppose to call it with this function?
Function FindNic() As String
Dim iHnd As IntPtr = mdlGetHnd.SubFormHndByClassNameWithMWClassWithPartialMWCaption(mdlPalInfo.ChatRoomClass, Me.CtrlRoomSelector1.RoomName, mdlPalInfo.NicListClass, mdlPalInfo.NicListIndex)
Return mdlSysListView.GetSLVSelectedItem(iHnd)
End FunctionBy using this command
FindNic(nick.text) To select the nick?July 26, 2012 at 12:08 am #186842autopilotMemberFunction FindNic() As String
the fact that it is a function means it returns a value, but the fact that there is nothing in the brackets () after FindNic means that you are not passing anything into that function.
Return mdlSysListView.GetSLVSelectedItem(iHnd)
the return line is what is being returned by the function. mdlSysListView.GetSLVSelectedItem should tell you that the function gets the selected nic from the room nic list.
Dim SelectedNic as String = FindNic()
July 26, 2012 at 2:54 am #186841AdminAdministratorlol Duh 🙂 i see it now, K I just wait til ya update to select the nick than, cause that sht is hard 🙄
July 26, 2012 at 12:51 pm #186840autopilotMemberBecause nics jump around in the nic list (raise/lower hand, cam up/down, etc), I don’t try to enum the nics to “select” the one I want. In stead, I send the letters of the name to the nic list. This causes the nic to get selected automatically. Then I get the selected nic and compare it to the nic I am looking for. If it matches, then proceed with the bounce/dot.
July 26, 2012 at 8:59 pm #186839AdminAdministratorThat sounds better and less code, but still it be cool to get the nicks from the nick list room for other stuff.
July 27, 2012 at 2:43 am #186838autopilotMemberI put together a very basic project to show how to select a nic in the room nic list. You can find it at DemoPalNicList[VB2010].
July 27, 2012 at 5:35 am #186837AdminAdministratorWorking perfectly Thanks alot, now i can finish the paltalk bot
July 27, 2012 at 4:36 pm #186836autopilotMemberJuly 30, 2012 at 5:12 pm #186835wazzzupMembersomething news 😉 nice job loco …
-
AuthorPosts
Related
- You must be logged in to reply to this topic.