Since my other post seems to have gone off-topic, here we go:
I have used this code to find the IM window on trillian:
VB Code:
Option Explicit
'declare API:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Private Const My_Message As Long = 10001
Private Sub Form_Load()
'Class Name of the window:
Dim strClassName As String, lhWnd As Long, strclassname2 As String, lhWnd2 As Long
i added SendMessage lhWnd, "Yo", 0&, 0&, <--to send the that window defined as lhwnd, that gives me an error as i assumed, but i need to find the textbox of the window im sending too with spy++, and i dont know what to look for, it gave me a page full of children..
My question is, how can i send a message to a textbox inside of an app, by its classname? the class name im looking for is: icoPMsgMSN <(which i do find)>
For starters I dont have MSN but you can not get a child window handle with just FindWindow alone.
You need FindWindowEx to get any child window handle. Then once you have the correct handle you can do like this...
SendMessage lhWnd, WM_SETTEXT, 2&, ByVal "Yo".
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
well, first ive never seen that thread, but i did visit another one of your threads that got me this far..
edit**my stupidity, i see my own post on there, although i dont remember it..
added this to a module:
VB Code:
Option Explicit
'Functions, constants and types for the hook
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" ( _
ByVal idHook As Long, _
ByVal lpfn As Long, _
ByVal hmod As Long, _
ByVal dwThreadId As Long _
) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" ( _
ByVal hHook As Long _
) As Long
Private Declare Function CallNextHookEx Lib "user32" ( _
ByVal hHook As Long, _
ByVal ncode As Long, _
ByVal wParam As Long, _
lParam As Any _
) As Long
Public Const WH_MOUSE_LL = 14
Public Type POINTAPI
x As Long
y As Long
End Type
Public Type MSLLHOOKSTRUCT
pt As POINTAPI
mouseData As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type
Private hHook As Long
Public IsHooked As Boolean
'functions for getting windows properties
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" ( _
ByVal hwnd As Long, _
ByVal lpString As String, _
ByVal cch As Long _
) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" ( _
ByVal hwnd As Long, _
ByVal lpClassName As String, _
ByVal nMaxCount As Long _
) As Long
Private Declare Function WindowFromPoint Lib "user32" ( _
I have a joke:
Q: How many I.T. administrators does it take to changes a light bulb?
A: It works for me...
OK, I won't give the typical IT response
Let's check:
Are you using VB 6?
Did you put the module code in a module and the form code in a form?
Did you compile the code to check for errors?
Option Explicit everywhere?
did you press the cmdStart button?
If the answers to all these is yes, yes, yes, yes, yes
check to see if your mouse hook is working...
put a debug.print statement in there
Let me know
edit2**
figured it out, after my computer crashed i forgot to rename command1 to cmdstart.shoot. sorry for your time.
in txthandle it says: 1049E
ib txtcaption & txtclassname it says "trillian display"
btw, the txthandle changes for each msg, so if i open up 2 im windows, the textboxes will have different handles..how can i do this, if they handles change?<the only thing that stays the same is icoPMsgAIM, or icoPMsgMSN, <--thats the main one, its the parent is it called? is this still doable still?
Last edited by |2eM!x; Feb 23rd, 2005 at 07:34 PM.
Aaaahh...! I need an icon for pulling out my hair.
OK, now that that is cleared up. Now that you have the values for classname and caption you can get the handle to the window you want to send the message to.
Define these functions:
VB Code:
Option Explicit
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any _
) As Long
Public 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
Assuming the program you want to send the message to is running. You can get the handle to the text box you want
here are the variables: set them to the values you know
OK, I'll try one more time.
Forget about the code you got from another thread.
Use the code I gave you in my last thread.
You said that you already know the values for captions and class names so just plug those values in and
SEND YOUR MESSAGE
I'm not angry, just frustrated.
1. You don't clearly describe the problem you are trying to solve
2. You bring in code from other posts that don't have anything to do with your problem, claim it dosn't work, then claim it does work
3. You don't read other posts which have solved the same problem
4. You don't pay attention to posts I and others have made to try to help you
im frusterated too
1.)Im trying to sendmessage...ive never used it before, its not like it is that easy..
2.)I used code from the link you sent me. I just didnt understand it.
3.)I definately have.Except mine is different. I dont post unless i dont find it first..
4.)ok..[edit]discovered that both the text i was typing, and the text i was recieving had the same classname and same caption but not the same handle.That is my problem, i dont know how to send messages to a handle
thanks.ill just end this topic right here.
Last edited by |2eM!x; Feb 24th, 2005 at 07:50 PM.
Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
Posts
1,152
Re: Sendmessage help?
I didn't really read through any posts past the first few.
Just some advice that i always give in this forum:
www.patorjk.com For SIMPLE api stuff, just use the API Spy....instead of spending 20 minutes looking through spy++ for messages being sent and handles.
Also other neat api programs at their site.
ONLY time i have to use spy++ is when im dealing more so with treeview/listview and menu ids. Of course theres other circumstances...but 70% of the time ill just use api spy and be done in 5 minutes.
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
-------------------------------- "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe "Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++