|
-
Nov 13th, 2000, 11:35 AM
#1
Thread Starter
PowerPoster
I was wondering how to use SendKeys to send text to AOL Instant Messager. I have the text I want to send in a text box, but when I try to send the message, nothing happens. I think it is because there are two textboxes in instant messager, and the first one is read-only. Would this question fit better in the API section of the forums?
Joey (MidgetsBro)
-
Nov 13th, 2000, 02:21 PM
#2
Hyperactive Member
Maybe you need the Hwnd to that paticular textbox ? Just a thought .
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Nov 13th, 2000, 02:50 PM
#3
Frenzied Member
hehe good thinking 
I don't have AOL messenger so I can't test it, but you need to find the handle of the textbox with an API spy, then use
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
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_SETTEXT = &HC
Private Sub AOL()
Dim a&, t&, t2&
a = FindWindow("CLASSNAME", "CAPTION")
t = FindWindowEx(a, Byval 0&, "CLASSOFTEXTBOX", "")
'if there's another textbox with the same class and the first one doesn't work use:
't2 = FindWindowEx(a, t, "CLASSOFTEXTBOX", "")
'then set the text using
SendMessage t, WM_SETTEXT, ByVal CLng(0), ByVal "MYNEWTEXT"
'or if you use the second textbox
SendMessage t2, WM_SETTEXT, ByVal CLng(0), ByVal "MYNEWTEXT"
End Sub
have fun!
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Nov 13th, 2000, 03:43 PM
#4
Thread Starter
PowerPoster
Can I use Spy++ to get the textbox class name? I have the window class name, but I can't find the textbox one. If anyone has made a program that sends text to an Instant Message window, please respond. BTW thanks Jop, that code should work once I get the textbox name.
-
Nov 13th, 2000, 05:27 PM
#5
Frenzied Member
Yup, just move your mouse over the textbox and it should work.
Anyway, if that doesn't work download Kedaman's Class Explorer from his homepage (www.kedaman.com)
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Nov 13th, 2000, 10:39 PM
#6
Hyperactive Member
aim 4p1
i tried helping someone send text to a chat window in aim and i'm guessing this should be about the same if ur still planning to use the sendkeys
the way you have to do it is by find the title of the IM
appactivate "the screenname - instant message"
once you activate it you have to find out where the focus is given to the IM ...
to send a message to the chat i had to send the TAB key seven times so the cursor would position in the textbox
so see how many times you have to press tab
finally the code would look like:
appactivate "the screenname - instant message"
for x = 1 to 4
sendkeys {vbtab}
next x
sendkeys thetextboxname.text
hopefully that works
-
Nov 14th, 2000, 11:23 AM
#7
Thread Starter
PowerPoster
Thanks man! That worked really well. I was researching Jop's code and trying to find all that info about the IM box, and I got the e-mail about your code. I tried it and it works. The only thing is that the Instant Message window has to be open. Oh well that's a small price to pay for somthing this good. Thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|