vb.net get pal room name & send text

You can talk about VB programming here

vb.net get pal room name & send text

Postby jimmyng » Sun Aug 22, 2010 8:50 pm


hi guy
anyone tried to findpalwindows & get text chat in vb.net please help
i tried to convert source from vb6 to vb.net but however it give alot off error please help


thnks
jimmyng
imFiles Newbie
imFiles Newbie
 
Posts: 28
Joined: Sun Feb 12, 2006 4:41 pm

Re: vb.net get pal room name & send text

Postby autopilot » Sun Aug 22, 2010 9:31 pm

User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 356
Joined: Sat Sep 23, 2006 7:19 pm

Re: vb.net get pal room name & send text

Postby jimmyng » Sun Aug 22, 2010 11:56 pm

Thank Autopilot for ur reply

do you still have these sample code with you please post & how to find pal windows too
thank in advance
jimmyng
imFiles Newbie
imFiles Newbie
 
Posts: 28
Joined: Sun Feb 12, 2006 4:41 pm

Re: vb.net get pal room name & send text

Postby autopilot » Mon Aug 23, 2010 6:39 am

jimmyng wrote:do you still have these sample code with you please post & how to find pal windows too

i dont have the samples or screen shots, so hopefully loco has good backups and restores them.

all the code samples you need are in the posts i pointed you to before. i am done with those too lazy to read and learn for themselves.
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 356
Joined: Sat Sep 23, 2006 7:19 pm

Re: vb.net get pal room name & send text

Postby jimmyng » Thu Aug 26, 2010 5:38 pm

hi autopilot
i tried this code it seem working fine ,,,,however when i run it click on button some time it return with text sometime nothing please help...


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'ReadTxtHnd()

Dim sChatText As String = GetLastLineTextChat(ReadTxtHnd)
Me.RichTextBox2.Text = (sChatText)
End Sub

'--------------------------------------------------------------------

Public Function GetLastLineTextChat(ByVal hwnd As Integer) As String
Dim iLastLine As Integer
DimstrBuffer As New StringBuilder(255) 'String

iLastLine = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0)

sChatText = SendMessageString(hwnd, EM_GETLINE,iLastLine - 2,strBuffer)
Return strBuffer.ToString
End Function
'------------------------------------------------------------------------------------
Public Function ReadTxtHnd() As Integer ' Incoming Chat Box
iHnd = mdlGetHnd.SubFormHndByClassNameWithMWClassWithPartialMWCaption(mdlPalInfo.ChatRoomClass, Me.cbxRoomName.Text, mdlPalInfo.SplitterClass, mdlPalInfo.SplitterIndex)
' MsgBox(iHnd)
iHnd = mdlGetHnd.SubFormHndByClassNameWithMWHnd(iHnd, mdlPalInfo.ChatTextClass, mdlPalInfo.ReadTextIndex)
' MsgBox(iHnd)
' Me.RichTextBox2.Text = sChatText
Return iHnd

End Function


jimmyng
imFiles Newbie
imFiles Newbie
 
Posts: 28
Joined: Sun Feb 12, 2006 4:41 pm

Re: vb.net get pal room name & send text

Postby Chike » Thu Aug 26, 2010 6:44 pm

The first and second bytes (in your example) sourd be 255 and 0 repectively before sending EM_GETLINE message.
http://msdn.microsoft.com/en-us/library/bb761584(VS.85).aspx
Image
Chike
imFiles Master
imFiles Master
 
Posts: 581
Joined: Sun May 13, 2007 6:20 pm

Re: vb.net get pal room name & send text

Postby autopilot » Thu Aug 26, 2010 11:13 pm

the only thing i see wrong with your code, and it should not cause intermitant working, is your sendmessage call
Code: Select all
sChatText = SendMessageString(hwnd, EM_GETLINE,iLastLine - 2,strBuffer)

SendMessage returns an integer and not a string, but VB should do the type convertion without causing any errors.

show us your SendMessageString decleration
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 356
Joined: Sat Sep 23, 2006 7:19 pm

Re: vb.net get pal room name & send text

Postby jimmyng » Fri Aug 27, 2010 1:39 am

HI,
this is how i did but it return intermitant & don't know why :x :x :cry: :cry:
please help ...


Code: Select all
 Public Declare Function GetWindow Lib "user32" (ByVal hWnd As Integer, ByVal wCmd As Integer) As Integer
    Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
    Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Public ClassName As String = String.Empty
    Public Const StringBufferLength As Integer = 255
    Public Const GW_CHILD As Long = 5
    Public Const GW_HWNDNEXT = 2
    'Public Const WM_GETTEXTLENGTH = &HE
    'Public Const WM_GETTEXT = &HD
    Public Const EM_GETLINECOUNT = &HBA
    Public Const EM_GETLINE = &HC4

'------------------------------------------------------------------------

Public Function GetLastLineTextChat(ByVal hwnd As Integer) As String
Dim iLastLine As Integer
DimstrBuffer As New StringBuilder(255) 'String

iLastLine = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0)

sChatText = SendMessageString(hwnd, EM_GETLINE,iLastLine - 2,strBuffer)
Return strBuffer.ToString
End Function
'------------------------------------------------------------------------------------


'  <<<<<Form1>>>
'--------------------------------------------------------------
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'ReadTxtHnd()

Dim sChatText As String = GetLastLineTextChat(ReadTxtHnd)
Me.RichTextBox2.Text = (sChatText)
End Sub

'------------------------------------------------------
Public Function ReadTxtHnd() As Integer ' Incoming Chat Box
iHnd = mdlGetHnd.SubFormHndByClassNameWithMWClassWithPartialMWCaption(mdlPalInfo.ChatRoomClass, Me.cbxRoomName.Text, mdlPalInfo.SplitterClass, mdlPalInfo.SplitterIndex)
' MsgBox(iHnd)
iHnd = mdlGetHnd.SubFormHndByClassNameWithMWHnd(iHnd, mdlPalInfo.ChatTextClass, mdlPalInfo.ReadTextIndex)
' Me.RichTextBox2.Text = sChatText
Return iHnd
jimmyng
imFiles Newbie
imFiles Newbie
 
Posts: 28
Joined: Sun Feb 12, 2006 4:41 pm

Re: vb.net get pal room name & send text

Postby jimmyng » Fri Aug 27, 2010 1:55 am

Got it work!!! Thank :lol: :lol:
jimmyng
imFiles Newbie
imFiles Newbie
 
Posts: 28
Joined: Sun Feb 12, 2006 4:41 pm

Re: vb.net get pal room name & send text

Postby jimmyng » Fri Aug 27, 2010 1:58 am

autopilot <<<2C684080P7817032W >>this your
jimmyng
imFiles Newbie
imFiles Newbie
 
Posts: 28
Joined: Sun Feb 12, 2006 4:41 pm

Re: vb.net get pal room name & send text

Postby autopilot » Fri Aug 27, 2010 4:20 pm

jimmyng wrote:Got it work!!! Thank :lol: :lol:

Glad to hear it! What did you find to be the problem?
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 356
Joined: Sat Sep 23, 2006 7:19 pm

Re: vb.net get pal room name & send text

Postby jimmyng » Fri Aug 27, 2010 9:55 pm

it work but seem still unstable for me did you tried the old way like use :

Code: Select all
 Textlen = SendMessage(Ihwnd, WM_GETTEXTLENGTH, 0, 0)
 
   zText = Space$(Textlen)
    Textlen = SendMessage(Ihwnd, WM_GETTEXT, Textlen, ByVal zText)
    GetRoomText = Left$(zText, Textlen)


this<< byVal zText)>> is not allow how to fix this issue
jimmyng
imFiles Newbie
imFiles Newbie
 
Posts: 28
Joined: Sun Feb 12, 2006 4:41 pm

Re: vb.net get pal room name & send text

Postby autopilot » Sat Aug 28, 2010 3:59 am

What operating system are you using?
User avatar
autopilot
Forum Moderator
Forum Moderator
 
Posts: 356
Joined: Sat Sep 23, 2006 7:19 pm

Re: vb.net get pal room name & send text

Postby Chike » Sat Aug 28, 2010 4:16 am

By doing what you do you set the first word of the buffer to 32x256+32=8224.
If you're looking for memory corruption you might just get it.
Image
Chike
imFiles Master
imFiles Master
 
Posts: 581
Joined: Sun May 13, 2007 6:20 pm

Re: vb.net get pal room name & send text

Postby jimmyng » Sun Aug 29, 2010 7:50 pm

i tried this way work fine for me

Code: Select all
Dim Textlen = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, Nothing)
        Dim zText As New StringBuilder(Textlen)
        Textlen = SendMessageString(hwnd, WM_GETTEXT, Textlen, zText)


this still intermiant

iLastLine = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0)

sChatText = SendMessageString(hwnd, EM_GETLINE,iLastLine - 2,strBuffer)

use: VS 2010 (win7)
jimmyng
imFiles Newbie
imFiles Newbie
 
Posts: 28
Joined: Sun Feb 12, 2006 4:41 pm

Next

Return to Visual Basic Programming

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests