-
May 26th, 2007, 09:55 AM
#16
Re: webbrowser
thanks everyone, but now I have a new problem.. this program I'm making runs in the background (with me.hide), so sendkeys wouldn't work..
I searched the forum and found some code but can't get it to work
Code:
Private Sub Timer1_Timer()
opendialog = FindWindow(vbNullString, "Choose file")
If opendialog > 0 Then
hEdit = FindWindowEx(opendialog, 0&, "Edit", vbNullString)
Call SendMessage(hEdit, WM_SETTEXT, 0&, "C:\test.txt")
Timer1.Enabled = False
End If
End Sub
I also downloaded winspy++ to check if the name of the editbox was "Edit" and I'm pretty sure it is
-
May 26th, 2007, 10:00 AM
#17
Re: webbrowser
But you wouldn't send the messages to the Edit window. You would send them to the Choose file window.
Code:
Private Sub Timer1_Timer()
opendialog = FindWindow(vbNullString, "Choose file")
If opendialog > 0 Then
SendMessage opendialog, WM_SETTEXT, 0&, "C:\test.txt"
Timer1.Enabled = False
End If
End Sub
Edit: Also, have you declared WM_SETTEXT?
Last edited by PeejAvery; May 26th, 2007 at 10:03 AM.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
May 28th, 2007, 03:24 PM
#18
Re: webbrowser
I don't think that's right.. you can't just send WM_SETTEXT to the choose file window
what if it had multiple editboxes? it woudn't know which one to type in
I tried your code and it didn't work
And yes, at the top I have
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
-
May 28th, 2007, 08:28 PM
#19
Re: webbrowser
Originally Posted by adsfdg
I tried your code and it didn't work
Well, I am on holiday today (Monday) and will have check some code back at the office on Tuesday. Or maybe someone will cover it before me.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
May 29th, 2007, 08:44 AM
#20
Re: webbrowser
It's a lot more complicated. FindWindowEx can only find children directly under the window you're looking in. The Edit control isn't a first child. The actual hierarchy (from Windows XP and IE7's open dialog) goes:
#32770 "Choose file:"
ComboBoxEx32 ""
ComboBox ""
Edit ""
So you have to look in that order:
Code:
Private Sub Timer1_Timer()
Dim opendialog As Long
Dim hEdit As Long
Dim hCombo As Long
opendialog = FindWindow(vbNullString, "Choose file")
If opendialog > 0 Then
Do
hCombo = FindWindowEx(opendialog, 0&, "ComboBoxEx32", vbNullString)
If hCombo > 0 Then hCombo = FindWindowEx(hCombo, 0&, "ComboBox", vbNullString)
If hCombo > 0 Then hEdit = FindWindowEx(hCombo, 0&, "Edit", vbNullString)
Loop While hEdit = 0
Call SendMessage(hEdit, WM_SETTEXT, 0&, ByVal "C:\test.txt")
Timer1.Enabled = False
End If
End Sub
You also have to pass the string ByVal or else it gets chewed up when it actually goes in to the text field.
This code could be improved upon, as there are a few potential pitfalls. And the open dialogs could be different depending on the application (not as likely) and the version of Windows (much more likely).
-
May 29th, 2007, 01:40 PM
#21
Re: webbrowser
thanks, that worked. but now I can't figure out how to press enter!
Code:
Call SendMessage(hEdit, WM_SETTEXT, 0&, ByVal "C:\test.txt")
Call SendMessage(hEdit, WM_LBUTTONDOWN, VK_RETURN, 0)
Call SendMessage(hEdit, WM_LBUTTONUP, VK_RETURN, 0)
it looks pretty simple.. but I can't figure out why it won't work
I even tried postmessage
-
May 29th, 2007, 03:16 PM
#22
Re: webbrowser
WM_LBUTTONDOWN
The WM_LBUTTONDOWN message is posted when the user presses the left mouse button while the cursor is in the client area of a window.
Can't exactly replicate pressing Enter with a mouse click on an edit box.
I tried WM_KEYDOWN and WM_KEYUP in it's place, but the dialog wouldn't dismiss. You may just have to find the Open button and send the WM_LBUTTONDOWN and WM_LBUTTONUP to simulate a click on it.
-
May 30th, 2007, 06:57 PM
#23
Re: webbrowser
I got it to close using the Open button.. but now I'm trying to figure out how to know when it's finished uploading
I don't think the page reloads or anything, they just use javascript to change part of the page and show you your download url (I think..)
I thought about using a timer to check when the length of downloadurl > 0, but I can't seem to access WebBrowser1 from my timer, or anything outside WebBrowser1_DocumentComplete
I used WebBrowser1.Document.getElementById("downloadurl").Value
-
May 31st, 2007, 10:50 AM
#24
Re: webbrowser
At this point, you'll just have to see how it acts when you do an upload and see if the page redirects or just updates something on the page.
If it does redirect, you can use DocumentComplete (at this point, you'd have to have it check the URL to know whether it should do an upload or read the results), if it doesn't, you'll have to watch some object on the page for what you're waiting for.
-
June 4th, 2007, 06:48 PM
#25
Re: webbrowser
does anyone have any ideas? I need it to close when it's done uploading
the page doesn't redirect to anything..
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
|