|
-
Sep 23rd, 2007, 06:07 PM
#41
Thread Starter
Hyperactive Member
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Fazi that works great.
Can you help me make a function for this program? its a lot easier. I can already submit the button "Check email"
Here is a screenshot:
http://img370.imageshack.us/img370/4572/lastph2.jpg
you have to access the group container that it is in.
This is the code im using to press the "check email" button:
Private Declare
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 Integer, ByVal lParam As Any) As Long
Private Const BM_CLICK As Long = &HF5&
Private Const WM_SETTEXT = &HC
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
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 SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
The function
Code:
Private Sub SendSubmit()
On Error Resume Next
Dim WinWnd As Long
Dim Ret As Long
Dim ErrNum As Integer
'Find window Handle
WinWnd = FindWindow(vbNullString, "email poster")
If WinWnd <> 0 Then
'Show the form
'AppActivate "email poster"
'Find button handle by going through every child control in the form
EnumChildWindows WinWnd, AddressOf EnumChildProc, ByVal 0&
If BtnHwnd <> 0 Then
'Send the Message
Ret = SendMessage(BtnHwnd, BM_CLICK, 0, 0&)
Else
ErrNum = 2 'Button was not found
End If
Else
ErrNum = 1 'Window was not found
End If
'Errors
Select Case ErrNum
Case 1
Me.Caption = "Window handle could not be found"
Case 2
Me.Caption = "Button was not found on form"
End Select
End Sub
and the module:
Code:
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public BtnHwnd As Long
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sSave As String
'Get the windowtext length
sSave = Space$(GetWindowTextLength(hwnd) + 1)
'get the window text
GetWindowText hwnd, sSave, Len(sSave)
'remove the last Chr$(0)
sSave = Left$(sSave, Len(sSave) - 1)
If sSave = "Check email" Then
BtnHwnd = hwnd
Exit Function
End If
'continue enumeration
EnumChildProc = 1
End Function
Right now it just hits the "check email" button. can you make it send the email/popserver/password text that is located on another form/program?
-
Sep 23rd, 2007, 06:22 PM
#42
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
you want to grab the email/pop../pass etc located in an external program and past in to this programs relevant box's?
-
Sep 23rd, 2007, 06:42 PM
#43
Thread Starter
Hyperactive Member
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
 Originally Posted by Fazi
you want to grab the email/pop../pass etc located in an external program and past in to this programs relevant box's?
Correct!
-
Sep 23rd, 2007, 06:51 PM
#44
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
you need to use the WM_GETTEXT AND WM_SETTEXT Messages with SendMessage(). give a try
-
Sep 23rd, 2007, 07:23 PM
#45
Thread Starter
Hyperactive Member
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
 Originally Posted by Fazi
you need to use the WM_GETTEXT AND WM_SETTEXT Messages with SendMessage(). give a try 
I have tried, believe me. LOL
For over a week!
Last edited by penagate; Sep 24th, 2007 at 04:12 AM.
Reason: removed offer of payment
-
Sep 23rd, 2007, 07:41 PM
#46
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
thud,
ill post you the codes. but i need little time as i am busy out here.
ok
-
Sep 23rd, 2007, 11:32 PM
#47
Thread Starter
Hyperactive Member
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
 Originally Posted by Fazi
thud,
ill post you the codes. but i need little time as i am busy out here.
ok
No problem, I don't mean to sound like I'm rushing you.
I very much appreciate your help.
-
Sep 25th, 2007, 12:46 AM
#48
Thread Starter
Hyperactive Member
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Just let me know
-
Sep 25th, 2007, 01:33 AM
#49
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
Thud, making a complete project is imposible dear,
this is the code you requir to Get the text from a control and then Set it to another control. you no how to ritriv the handle of the window that contain the text.
Code:
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 Const WM_GETTEXT = &HD
Private Sub Command1_Click()
'this code will retrive the text from a text box in to the StrBuff variable
Dim StrBuff As String * 255
SendMessage hwnd, WM_GETTEXT, 255, StrBuff
'strbuffer is the buffer where the text ritrived will be copied
'255 is the number of charactors to copy in to the strbuffer.
'This code will set the text in to a text box
SendMessage hwnd, WM_SETTEXT, 0, ByVal StrBuff
End Sub
-
Sep 26th, 2007, 12:38 PM
#50
Thread Starter
Hyperactive Member
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
 Originally Posted by Fazi
Thud, making a complete project is imposible dear,
this is the code you requir to Get the text from a control and then Set it to another control. you no how to ritriv the handle of the window that contain the text.
Code:
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 Const WM_GETTEXT = &HD
Private Sub Command1_Click()
'this code will retrive the text from a text box in to the StrBuff variable
Dim StrBuff As String * 255
SendMessage hwnd, WM_GETTEXT, 255, StrBuff
'strbuffer is the buffer where the text ritrived will be copied
'255 is the number of charactors to copy in to the strbuffer.
'This code will set the text in to a text box
SendMessage hwnd, WM_SETTEXT, 0, ByVal StrBuff
End Sub
Fazi, can I send you the program.
-
Sep 26th, 2007, 12:43 PM
#51
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
thud,
what is the trouble now?
-
Sep 28th, 2007, 06:59 PM
#52
Thread Starter
Hyperactive Member
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
 Originally Posted by Fazi
thud,
what is the trouble now?
The trouble is that I don't know what I'm doing.
LOL
-
Sep 28th, 2007, 07:11 PM
#53
Re: DESPERATE - SendMessage - How can I click this toolbar item "Connect"
I thinkg you really solved that connection issue which is the topic of this thread. is it? if it so, i recommend you to make this thread Resolved and create a new fresh thread and clearly explain your next problem.
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
|