
November 20th, 2005, 10:40 PM
| | | no result with WM_GETTEXT
Hello,
I try to read the content of an open Notepad window, but I don't get WM_GETTEXT to work with Visual Basic .NET. I have the correct handle for the Notepad window and get the number of signs with wm_gettextlength, but no results for wm_gettext.
Here is how I try it:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Object, ByVal lParam As Object) As Integer
Public Const WM_GETTEXT = &HD
Public Const WM_GETTEXTLENGTH = &HE
dim length, NotepadResult as String
length = SendMessage(handle2, WM_GETTEXTLENGTH, Nothing, 0)
SendMessage(handle2, WM_GETTEXT, length, NotepadResult)
Anyone knows how to get this to work?
Thanks in advance for any help!
Regards
Sebastian | 
November 20th, 2005, 10:40 PM
| | | Re: no result with WM_GETTEXT
* Seb Schöps <nospam@internet.com> scripsit:[color=blue]
> I try to read the content of an open Notepad window, but I don't get WM_GETTEXT to work with Visual Basic
> .NET. I have the correct handle for the Notepad window and get the number of signs with wm_gettextlength, but no
> results for wm_gettext.
>
> Here is how I try it:
>
> Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As
> Integer, ByVal wParam As Object, ByVal lParam As Object) As Integer[/color]
Declare 'wParam' and 'lParam' as 'Int32' and pass a 0.
[color=blue]
> Public Const WM_GETTEXT = &HD
> Public Const WM_GETTEXTLENGTH = &HE
>
> dim length[/color]
'... As Int32'.
[color=blue]
> , NotepadResult as String
>
> length = SendMessage(handle2, WM_GETTEXTLENGTH, Nothing, 0)[/color]
\\\
NotepadResult = Strings.StrDup(length, " "c)
///
[color=blue]
> SendMessage(handle2, WM_GETTEXT, length, NotepadResult)[/color]
\\\
MsgBox(NotepadResult)
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/> | 
November 20th, 2005, 10:40 PM
| | | Re: no result with WM_GETTEXT
Thanks Herfried,
that solved my problem.
But I had to declare lParam as String:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Object, ByVal
lParam As String) As Integer
Thanks again!
Regards
Sebastian
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schrieb im Newsbeitrag
news:OAAxL$2ZEHA.2812@TK2MSFTNGP11.phx.gbl...[color=blue]
> * Seb Schöps <nospam@internet.com> scripsit:[color=green]
> > I try to read the content of an open Notepad window, but I don't get[/color][/color]
WM_GETTEXT to work with Visual Basic[color=blue][color=green]
> > .NET. I have the correct handle for the Notepad window and get the[/color][/color]
number of signs with wm_gettextlength, but no[color=blue][color=green]
> > results for wm_gettext.
> >
> > Here is how I try it:
> >
> > Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"[/color][/color]
(ByVal hWnd As IntPtr, ByVal wMsg As[color=blue][color=green]
> > Integer, ByVal wParam As Object, ByVal lParam As Object) As Integer[/color]
>
> Declare 'wParam' and 'lParam' as 'Int32' and pass a 0.
>[color=green]
> > Public Const WM_GETTEXT = &HD
> > Public Const WM_GETTEXTLENGTH = &HE
> >
> > dim length[/color]
>
> '... As Int32'.
>[color=green]
> > , NotepadResult as String
> >
> > length = SendMessage(handle2, WM_GETTEXTLENGTH, Nothing, 0)[/color]
>
> \\\
> NotepadResult = Strings.StrDup(length, " "c)
> ///
>
>[color=green]
> > SendMessage(handle2, WM_GETTEXT, length, NotepadResult)[/color]
>
> \\\
> MsgBox(NotepadResult)
> ///
>
> --
> Herfried K. Wagner [MVP]
> <URL:http://dotnet.mvps.org/>[/color] | 
November 20th, 2005, 10:40 PM
| | | Re: no result with WM_GETTEXT
Correction:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Int32, ByVal
lParam As String) As Integer
"Seb Schöps" <nospam@internet.com> schrieb im Newsbeitrag
news:ccs1uc$5r1$1@online.de...[color=blue]
> Thanks Herfried,
>
> that solved my problem.
>
> But I had to declare lParam as String:
> Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
> (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Object,[/color]
ByVal[color=blue]
> lParam As String) As Integer
>
> Thanks again!
>
> Regards
> Sebastian
>
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schrieb im[/color]
Newsbeitrag[color=blue]
> news:OAAxL$2ZEHA.2812@TK2MSFTNGP11.phx.gbl...[color=green]
> > * Seb Schöps <nospam@internet.com> scripsit:[color=darkred]
> > > I try to read the content of an open Notepad window, but I don't get[/color][/color]
> WM_GETTEXT to work with Visual Basic[color=green][color=darkred]
> > > .NET. I have the correct handle for the Notepad window and get the[/color][/color]
> number of signs with wm_gettextlength, but no[color=green][color=darkred]
> > > results for wm_gettext.
> > >
> > > Here is how I try it:
> > >
> > > Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"[/color][/color]
> (ByVal hWnd As IntPtr, ByVal wMsg As[color=green][color=darkred]
> > > Integer, ByVal wParam As Object, ByVal lParam As Object) As Integer[/color]
> >
> > Declare 'wParam' and 'lParam' as 'Int32' and pass a 0.
> >[color=darkred]
> > > Public Const WM_GETTEXT = &HD
> > > Public Const WM_GETTEXTLENGTH = &HE
> > >
> > > dim length[/color]
> >
> > '... As Int32'.
> >[color=darkred]
> > > , NotepadResult as String
> > >
> > > length = SendMessage(handle2, WM_GETTEXTLENGTH, Nothing, 0)[/color]
> >
> > \\\
> > NotepadResult = Strings.StrDup(length, " "c)
> > ///
> >
> >[color=darkred]
> > > SendMessage(handle2, WM_GETTEXT, length, NotepadResult)[/color]
> >
> > \\\
> > MsgBox(NotepadResult)
> > ///
> >
> > --
> > Herfried K. Wagner [MVP]
> > <URL:http://dotnet.mvps.org/>[/color]
>
>[/color] | 
November 20th, 2005, 10:40 PM
| | | Re: no result with WM_GETTEXT
* "Seb Schöps" <nospam@internet.com> scripsit:[color=blue]
> But I had to declare lParam as String:
> Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
> (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Object, ByVal
> lParam As String) As Integer[/color]
That's true for 'WM_GETTEXT'. You can overload 'SendMessage'.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/> | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 205,248 network members.
|