get last comment not last line

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #186876
    light 2012
    Member

    hi
    the problem in getlastline code

    If the sent text is so long that it takes 2 or 3 lines, then only the last line will be returned.
    this affect the auto answer(responder) and swearBot
    Ex:

    paluser11:hi what’s your problem ?
    PalUser22:the problem in getlastline code
    Gets the last line ,,,,doesn’t get the full comment
    If the sent text is so long that it takes 2 or 3 lines, then only the last line will be returned

    I want to get the last comment
    PalUser22:the problem in getlastline code
    Gets the last line ,,,,doesn’t get the full comment
    If the sent text is so long that it takes 2 or 3 lines, then only the last line will be returned

    not last line

    #186895
    light 2012
    Member

    this solution by String:
    You can get around some of this by stretching the chat room window to its maximum width. Also, removing the text formatting for incoming text also will help.
    .
    but this solution doesn’t work always
    How to get a full comment by code
    I saw this in some programs

    #186894
    String
    Member

    The only other thing I can think of, is this… but I really don’t think its a good solution for this problem.

    In your GetLastLine function ( or whatever you call your function to get the last line) you’ll notice a line of code that looks something like this:

    Call SendMessageString(iHnd, EM_GETLINE, iLastLine - 2, strBuffer)

    Notice the -2
    This code is saying to retrieve the next to last line from the text, as the last line is always empty.

    So, you could test each string that you receive from your GetLastLine function to see if it contains the character “:”. The existence of a “:” would tell you that the last line received contained a username ( username : Hello world) and so, is probably the full line of text. If the last line received did NOT contain a “:”, you could assume that you are only receiving the wrapped portion of the string. You could then write some code to get the text from one more line above ( -3). That would give you the text from the line above the previous line you received. Confused? I am……

    But, doing it this way would assume that the text has only wrapped once, and that the wrapped text doesn’t contain a “:”.

    That’s really all I can come up with. This topic has been discussed quite a bit here on the forum and no really fool proof way of doing it has been provided. Perhaps the methods mentioned by Departure in your other thread will yield a better way to do this.

    #186893
    light 2012
    Member

    Thank you String , I will try

    #186892
    Chike
    Member

    I have one proposed a way to get ALL lines that have not been read before, as much it is possible as paltalk start cutting the lines from top when the room test reach a certaim size.
    I have already proposed a solution for that.
    Too lazy to search it, you do it 😛

    #186891
    String
    Member

    I believe this is the post Chike mentioned above. I’d forgotten about it, and I’ve even posted in it haha.

    #186890
    Chike
    Member

    Actually there is no need to delete all room text.
    It is possible to delete from the top like paltalk does, and keep track of line count so nothing is ever missed.
    I probably was lazy that time.

    #186889
    Departure
    Member

    basically what the others said, find the text character “:” and #13#10 which is a tab + return carriage which normally indicates a new line, so find this new line before the return carriage and get the position of text from there, this will be your last line, exception possibly could be if someone used the char “:” in there text and also had a return carriage just before it.

    to be honest this is the easiest way but not the best way as you are filling your buffer with all the text from the room and then parsing it. not to mention all this is done on timer, plus the fact you need to compare if you have received that last line or not in your parsing function, this method is very resource hungry.. get paltalk to do the “dirty” work for you as use hooks

    #186888

    Don’t you say here winsock hooks don’t work anymore?

    #186887
    Chike
    Member

    @usenet7 wrote:

    Don’t you say here winsock hooks don’t work anymore?

    Where did you see “winsock” in his post?

    #186886
    Departure
    Member

    as chike said…. I was reffering to API hooking or code hook, BUT you can still hook winsock and capture the packets and parse them out for room/pm text, Only problem with using winsock hook for room text is you still need to parse, admittedly not as much parsing as you need for “lastLine” method but winsock hooking also brings a large detection rate from AV’s which would not make much sense for public applications, the last thing you want is users coming back accusing you of planting virus/trojan in your releases. I will be releasing some sources and tutorials about “hooking” and i am sure chike, string, loco and the other vb coders will convert and improve the code if they think it suits there needs..

    #186885
    light 2012
    Member

    Not finished yet I need your help and your experience
    I got the last line and line before the last and worked compared

    code:

    Public Function GetLastLineTextChat(ByVal hwnd As Long) As String
    Dim lngCount As Long
    Dim lngLineIndex As Long
    Dim lngLength As Long
    Dim strBuffer As String
    Dim strRichText As String
    Dim strBuffer2 As String
    'Get Line count
    lngCount = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0)
    strBuffer = SPACE(256)
    strBuffer2 = SPACE(256)
    'resize buffer
    
    'get line text
    
    Call SendMessageStr(hwnd, EM_GETLINE, lngCount - 3, ByVal strBuffer)
    Call SendMessageStr(hwnd, EM_GETLINE, lngCount - 2, ByVal strBuffer2)
    GetLastLineTextChat = strBuffer & vbNewLine & strBuffer2
    
    End Function
    
    Public Function GetLastLine()
    On Error Resume Next
    Dim mywindowclass As Long
    Dim wtlsplitterwindow As Long, classcpanecontainerex As Long, atlffdd As Long
    Dim atlfe As Long
    Dim atlaxwin As Long
    Dim X As Long
    Dim richedita As Long
    
    mywindowclass = FindWindow("DlgGroupChat Window Class", Form1.Text7.Text)
    wtlsplitterwindow = FindWindowEx(mywindowclass, 0&, "SplitterWindowEx", vbNullString)
    wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "SplitterWindowEx", vbNullString)
    wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "SplitterWindowEx", vbNullString)
    wtlsplitterwindow = FindWindowEx(wtlsplitterwindow, 0&, "SplitterWindowEx", vbNullString)
    classcpanecontainerex = FindWindowEx(wtlsplitterwindow, 0&, "classcpanecontainerex", vbNullString)
    If classcpanecontainerex = 0 Then
    atlfe = GetWindow(wtlsplitterwindow, GW_CHILD)
    Else
    atlffdd = GetWindow(classcpanecontainerex, GW_CHILD)
    atlfe = GetWindow(atlffdd, GW_CHILD)
    End If
    atlfe = GetWindow(atlfe, GW_HWNDNEXT)
    atlaxwin = FindWindowEx(atlfe, 0&, "atlaxwin90", vbNullString)
    atlaxwin = FindWindowEx(atlfe, atlaxwin, "atlaxwin90", vbNullString)
    X = FindWindowEx(atlaxwin, 0&, "#32770", vbNullString)
    richedita = FindWindowEx(X, 0&, "richedit20w", vbNullString)
    
    Form1.RichTextBox11.Text = GetLastLineTextChat(richedita)
    
    Dim MyArr
    
    MyArr = Split(Form1.RichTextBox11.Text, vbCrLf)
    Dim F As Integer
    For F = 0 To UBound(MyArr)
    If Search(MyArr(0), ": ") 0 And Search(MyArr(1), ": ") = 0 Then
    Form1.RichTextBox5.Text = MyArr(0) & MyArr(1)
    End If
    If Search(MyArr(0), ": ") 0 And Search(MyArr(1), ": ") 0 Then
    Form1.RichTextBox5.Text = MyArr(1)
    End If
    Next
    
    End Function
    
    Private Function Search(ByVal TextSearchIn As String, ByVal txtSearchFor As String) As Long
    Dim lResultOfInStr As Long
    
    lResultOfInStr = InStr(1, TextSearchIn, txtSearchFor)
    Search = lResultOfInStr
    'MsgBox Search
    End Function

     

    #186884
    String
    Member

    I wont be at my normal machine till after the weekend, so I’m unable to test any code. But, if i understand exactly what your trying to do, your going about it the long way. I’m assuming all the code in red is code that isn’t working? In the future, enclose your code within the [*code] tags provided. Its so much easier to read.

    In your GetLastLineTextChat function, You code looks like:

    'get line text
    Call SendMessageStr(hwnd, EM_GETLINE, lngCount - 3, ByVal strBuffer)
    Call SendMessageStr(hwnd, EM_GETLINE, lngCount - 2, ByVal strBuffer2)
    GetLastLineTextChat = strBuffer & vbNewLine & strBuffer2

    I wouldn’t bother getting the line above ( -3) unless I needed to. Find out if your last line string contains a “:” or not, then, if it doesn’t, get the line above. Like:

    'get line text
    Call SendMessageStr(hwnd, EM_GETLINE, lngCount - 2, ByVal strBuffer2)
    If InStr(1, strBuffer2, ": ", vbTextCompare) = 0 Then
    Call SendMessageStr(hwnd, EM_GETLINE, lngCount - 3, ByVal strBuffer)
    GetLastLineTextChat = strBuffer & vbNewLine & strBuffer2
    Else
    GetLastLineTextChat = strBuffer2
    End If

    I don’t think you need all the code in red at the bottom.

    #186883
    light 2012
    Member

    🙂 Thank you String

    #186882
    light 2012
    Member

     

    Call SendMessageStr(hwnd, EM_GETLINE, lngCount - 2, ByVal strBuffer2)
    If InStr(1, strBuffer2, ": ", vbTextCompare) = 0 Then
    Call SendMessageStr(hwnd, EM_GETLINE, lngCount - 3, ByVal strBuffer)
    GetLastLineTextChat = strBuffer & vbNewLine & strBuffer2
    Else
    GetLastLineTextChat = strBuffer2
    End If
    
    Public Function GetLastLine()
    On Error Resume Next
    
    Dim splitterwindowex As Long, classcpanecontainerex As Long, atlaae As Long
    Dim atlabb As Long, atlaxwin As Long, x As Long
    Dim richeditw As Long
    Dim mywindowclass As Long
    
    mywindowclass = FindWindow("DlgGroupChat Window Class", Form1.Combo1.Text)
    splitterwindowex = FindWindowEx(mywindowclass, 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)
    atlaae = FindWindowEx(classcpanecontainerex, 0&, "atl:00a1ae40", vbNullString)
    atlabb = FindWindowEx(atlaae, 0&, "atl:00a1b3b0", vbNullString)
    atlaxwin = FindWindowEx(atlabb, 0&, "atlaxwin90", vbNullString)
    atlaxwin = FindWindowEx(atlabb, atlaxwin, "atlaxwin90", vbNullString)
    x = FindWindowEx(atlaxwin, 0&, "#32770", vbNullString)
    richeditw = FindWindowEx(x, 0&, "richedit20w", vbNullString)
    
    Form1.Text.Text = GetLastLineTextChat(richeditw)

    when i used this code

    Form1.Text.Text = GetLastLineTextChat(richeditw)

    Why text1=first line not first and second line in last comment?

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