- This topic has 9 replies, 3 voices, and was last updated 15 years ago by Chike.
-
AuthorPosts
-
May 18, 2009 at 9:11 pm #187347AdminAdministrator
I am working on a paltalk talk timer lol and I was trying to do it one way, which so far is kinda like a disaster 🙂 so now i am going another way, but to do that I want to get the user nick which can be done with this code, but can i use the same code to get also the user index, ya know its position, like 0,1,2 ect check the code to get the nick
in the code ya will see this line
Text16 = Here where i need to add a code to get the user index ;)
wha the heck i need to do to get the nick index before i added 🙄
Public Function GetListviewItem(ByVal lstviewhwnd As Long) As String Dim result As Long Dim myItem As LV_ITEMA Dim pHandle As Long Dim pStrBufferMemory As Long Dim pMyItemMemory As Long Dim strBuffer() As Byte Dim Index As Long Dim tmpString, tmp2 As String Dim strLength As Long Dim ProcessID As Long Dim ItemCount, i As Long '********************** '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) ItemCount = SendMessage(lstviewhwnd, LVM_GETITEMCOUNT, 0&, 0&) For i = 0 To ItemCount - 1 result = WriteProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0) '************************************************************* 'send the get the item message and write back the memory space '************************************************************* result = SendMessage(lstviewhwnd, LVM_GETITEMTEXT, i, ByVal 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)) tmp2 = tmp2 & Chr(strBuffer(Index)) Next Index tmp2 = Replace(tmp2, "@", "") Text17 = tmp2 Text16 = Here where i need to add a code to get the user index ;) tmp2 = "" 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) If Len(tmpString) > 0 Then GetListviewItem = tmpString End Function
And I am calling with this
Function NickGet() Dim dlggroupchatwindowclass As Long, wtlsplitterwindow As Long, atldd As Long Dim syslistview As Long On Error Resume Next dlggroupchatwindowclass = FindWindow("DlgGroupChat Window Class", Form1.Text1) wtlsplitterwindow = FindWindowEx(dlggroupchatwindowclass, 0&, "wtl_splitterwindow", vbNullString) wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString) wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString) wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString) wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString) atldd = GetWindow(wtlsplitterwindow, GW_CHILD) syslistview = FindWindowEx(atldd, 0&, "syslistview32", vbNullString) Call GetListviewItem(syslistview) End Function
Thanks for ya help 🙂
May 18, 2009 at 9:33 pm #187356ChikeMemberThere’s a LVM_FINDITEM but since it’s sub item 2 u probably need to loop and compare it yourself.
Why you need it for? the mic is always 1st.May 18, 2009 at 10:10 pm #187355AdminAdministratorI am trying to get the user status liek if they talking ect… and I think i did it 🙂 i made it liek this on the GetListviewItem function I change some part of the code to this
Call getuserstatus2
Text17.Text = CStr(CLng(Text17.Text) + 1)
tmp2 = Replace(tmp2, "@", "")
Text16 = tmp2
tmp2 = ""ya see i added another texbox and it starts at 0 then it adds one for every next lol 🙂 then i use another code to get the status call getuserstatus2 i think was gallatica that made it and call it with this
Private Function getuserstatus2()
Dim dlggroupchatwindowclass As Long, wtlsplitterwindow As Long, atldd As Long
Dim syslistview As Long
On Error Resume Next
dlggroupchatwindowclass = FindWindow("DlgGroupChat Window Class", Form1.Combo1.Text)
wtlsplitterwindow = FindWindowEx(dlggroupchatwindowclass, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "wtl_splitterwindow", vbNullString)
atldd = GetWindow(wtlsplitterwindow, GW_CHILD)
syslistview = FindWindowEx(atldd, 0&, "syslistview32", vbNullString)
Call GetUserStat2(syslistview, Text17)
'Call GetUserStat(syslistview, 1)
End Functionand the fucntion for that is this
Public Function GetUserStat2(ByVal lstviewhwnd As Long, ByVal item As Integer) As String
Dim result As Long
Dim myItem As LV_ITEMA
Dim pHandle As Long
Dim pMyItemMemory As Long
Dim ProcessID As Long
' Dim ItemCount, i As Long
'***********************************************************
'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)
'************************************************************************************
'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_STATE
myItem.iItem = item
myItem.iSubItem = 1
myItem.stateMask = &HFFFF
'**********************************************************
'write the structure into the remote process's memory space
'**********************************************************
pMyItemMemory = VirtualAllocEx(pHandle, 0, Len(myItem), MEM_COMMIT, PAGE_READWRITE)
'ItemCount = SendMessage(lstviewhwnd, LVM_GETITEMCOUNT, 0&, 0&)
result = WriteProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0)
'*************************************************************
'send the get the item message and write back the memory space
'*************************************************************
result = SendMessage(lstviewhwnd, LVM_GETITEM, item, ByVal pMyItemMemory)
result = ReadProcessMemory(pHandle, pMyItemMemory, myItem, Len(myItem), 0)
Text11 = myItem.iImage ' image index in listview of paltalk (example :5 raise hand, 7 mute speaker, 4 holding mic)
'
'**************************************************
'deallocate the memory and close the process handle
'**************************************************
result = VirtualFreeEx(pHandle, pMyItemMemory, 0, MEM_RELEASE)
result = CloseHandle(pHandle)
End Functionnow i made it so the program only will add users with their hands up, just add this on a textbox
If Text11 = "5" Then
List2.AddItem Text16
End IfAnd it works perfect 🙂 aigh I should be finish by next week is gonna kick asz lol
May 18, 2009 at 11:07 pm #187354ChikeMemberAnd why GetUserStat2 is not declared “As Integer”?
Best combine them to get the name and image at the same time, one call for text and the other for image will save you some virtualalloc/free and openprocess/closehandle calls, and
return one with the function and the other ByRef or both ByRef and the function return a boolen if it failed or succeeded.
If you doing it all in a loop it’s even better if you arrange your lists between the virtualalloc/free, to save even more time/cpu.
And i don’t think you need LVIF_STATE i don’t see you use the state at all.May 18, 2009 at 11:57 pm #187353AdminAdministratorah is the GetUserStat2 is a function 🙂 I was trying to put them all togeher on the GetListviewItem function and not success lol 🙂 but if i add them will it search for 5 cause i also need to search for 8 and 4 🙂 heehhe 😆
May 19, 2009 at 12:12 am #187352ChikeMemberWell i need to see the code to understand what u tryin to do.
Basiacally you are only interested in the 1st item if u check for mic.
BTW the mic icon not always steady on so u need to check several times a second, and not decide it dropped immediately if it’s not on but give it a time out. Save last time u saw it on and only if not on for 5 seconds then it’s down.
Also users may cover mic or reddot with a hand up.May 19, 2009 at 4:28 am #187351DepartureMemberthink about it loco, the person holding the mic is always at index 0 in the subitem of the systemlistview, so as chike suggested you need to get the image index number of the subitem index 0 (username) I don’t remember what subitem the images are in paltalk(integer) but you need to get this to determine if the user on top the list has the mic or not, and yes very good pick up by chike to note the fact the mic is not stable all the time and therefor needs a time out period.
May 19, 2009 at 1:09 pm #187350ChikeMemberFirst you need a plan, every good program begin with a good design.
Do you want it to habdle the queue for mic automatically or manually? e.g. it picks up the 1st hand up to be next or the admin chooses from the list’ or it can be auto with manual ovveride. Does it needs to be prepared to handle mic jumpers and admins reddot? This adds some complications.
Other features?
After you have it all decided make a states/events flow chart (yes yes on paper, board or with a software,) and user interface required, then coding is much easier.
This process is very important part of programing. It saves time and potential bugs and unneeded coding, even though you may still find flows you haven’t thank of and go back to the drwaing board.May 19, 2009 at 1:34 pm #187349AdminAdministratorDeps, I already got it so it check the first nick to see if they talking or hands up, the list that i am getting with this code is the waiting list, so lets say ya start the program it will automatically add the one that is talking to the a textbox as the current talker, the others one with their hands up will be added to the waiting list 🙂 now once the time is over the next in line in the waiting list which is the one in the waiting listbox with inedx one will be aloud to talk, so if lets say the third one in the waiting list jusmps the mic they wiull be told to let the one in first to talk other whise they will be mute.
Ah this the tricky part the damn jumpers that are not in the list will be mute automatically, also the program will not be updating the waiting list continually, it will only updated after the first line of people waiting to talk is empty, so the program will check if waiting list is empty then call function to full waiting list again that way it makes sure there arent people the just put their hands up to jump the mic lol
man is goign to be a mess lol
May 19, 2009 at 8:56 pm #187348AdminAdministratorah forget that waiting list lol too much but chek this mess out i havent clean it but ya can see where i am goign 🙂
-
AuthorPosts
Related
- You must be logged in to reply to this topic.