Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 11th, 2005, 4:42 PM   #1
GoO
Newbie
 
Join Date: Nov 2004
Posts: 17
Rep Power: 0 GoO is on a distinguished road
accessing notepad's textfield

i need to access notepad's textfield. without saving. does vb have any function or api for this?

example: i have notepad open. there are some texts there but still not saved. (ie "Untitled"). i need my vb program to read those texts.

thanks!
GoO is offline   Reply With Quote
Old Feb 11th, 2005, 4:48 PM   #2
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,667
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
i dont know if that is even possible. but i dont know
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old Feb 12th, 2005, 9:20 AM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Try the SendKeys API. It's not extremely reliable, unfortunately, but it should get the job done.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 13th, 2005, 4:07 AM   #4
GoO
Newbie
 
Join Date: Nov 2004
Posts: 17
Rep Power: 0 GoO is on a distinguished road
can u tell me what those are? i dont know anything about that.

anyway i think WM_GETTEXT should get the job done. how do i use this? syntax/declarations? thanks.
GoO is offline   Reply With Quote
Old Feb 13th, 2005, 8:51 AM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Ah... sorry, thought you wanted to send text to Notepad. All you really need, then, is the handle to the text box.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 13th, 2005, 6:27 PM   #6
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Put this in a blank form, open up notepad, type something in, then run!
Also works for password textboxes!
Private Declare Function SendMessage Lib "user32" Alias _
   "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As _
   Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private m_Buffer As String
Private m_length As Long
Private notepad_hwnd As Long
Private edit_hwnd As Long
Private Sub Form_Load()
notepad_hwnd = FindWindow("notepad", vbNullString)
edit_hwnd = FindWindowEx(notepad_hwnd, 0, "Edit", vbNullString)
'Get the handle to the edit box
'---- Structure found using Spy++ - wonderful program! ----
m_length = SendMessage(edit_hwnd, WM_GETTEXTLENGTH, 0, 0) + 1
'Get the text length
m_Buffer = Space$(m_length) 'Dimension our string to the text length
If SendMessage(edit_hwnd, WM_GETTEXT, _
            Len(m_Buffer), ByVal m_Buffer) Then
'Actually get the text
MsgBox TrimNull(m_Buffer) 'The text we retrieved
End If
End Sub
Private Function TrimNull(ByVal StrIn As String) As String
   Dim nul As Long
   'Trims null strings
   nul = InStr(StrIn, vbNullChar)
   Select Case nul
      Case Is > 1
         TrimNull = Left$(StrIn, nul - 1)
      Case 1
         TrimNull = ""
      Case 0
         TrimNull = Trim$(StrIn)
   End Select
End Function
Rory is offline   Reply With Quote
Old Feb 14th, 2005, 6:20 AM   #7
GoO
Newbie
 
Join Date: Nov 2004
Posts: 17
Rep Power: 0 GoO is on a distinguished road
thanks.. ill try it
GoO is offline   Reply With Quote
Old Feb 16th, 2005, 7:11 PM   #8
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
Or you coudl just do this.

Private sub Cmdsend_click()
Dim Text As String
Text = Text1.Text
AppActivate "Notepad.exe"
SendKeys Text
End Sub

Eithier way works just fine
__________________
And there was much rejoicing... Yay....
Cipher is offline   Reply With Quote
Old Feb 16th, 2005, 9:21 PM   #9
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
I said that. He needs to get stuff from the text field, not send stuff.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 17th, 2005, 5:40 PM   #10
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
Oh I see...I am not quite sure how to do that. Maybe a read API?
__________________
And there was much rejoicing... Yay....
Cipher is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:56 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC