Страница: 1 |
|
Вопрос: Программное заполнение формы и нажатие кнопки...
|
Добавлено: 02.02.10 22:05
|
|
Автор вопроса: @lex
|
Подскажите пожалуйста как можно программно заполнить форму и\или нажать на кнопку на сайте?)
Пример http://www.google.ru/
Заполнить строку поиска и нажать кнопку "Поиск в Google" ("http://www.google.ru/search?hl=ru&q=" & "текст запроса" не предлогать, Google я выбрал просто для примера)
Используя средства VB (если такие есть) или с использованием сторонних контролы типа MSHTL и WebBrowser - неважно)
з.ы. VB6
Ответить
|
Номер ответа: 1 Автор ответа: @lex
Вопросов: 14 Ответов: 262
|
Профиль | | #1
|
Добавлено: 02.02.10 22:08
|
Offtop: приделайте к сайту редактирование постов Х_х
контролов* MSHTML*
Ответить
|
Номер ответа: 4 Автор ответа: Just
Вопросов: 4 Ответов: 330
|
Профиль | | #4
|
Добавлено: 09.02.10 22:09
|
в голову тока приходит 2 варианта:
1.
-
- AppActivate "iE"
- SendKeys "{TAB}"
- SendKeys "{ENTER}"
2.
Этот способ я использую для автоматического входа (вводит пароль) в скайп
пример перечислет все что имеет хэндл на форме и в нужный введет текст
-
- Option Explicit
-
- Private Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
-
- 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 Long) As Long
- Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
- Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
-
- Private Const WM_KEYDOWN = &H100
- Private Const WM_GETTEXT = &HD
- Private Const WM_SETTEXT = &HC
- Private Const WM_SETFOCUS = &H7
- Private Const WM_GETTEXTLENGTH = &HE
-
- Dim M() As String
- Dim lCount As Long
-
-
- Private Sub Form_Load()
- On Error Resume Next
- If App.PrevInstance = True Then End
- App.TaskVisible = False
- Me.Visible = False
-
- If Dir(App.Path & "\Skype\shared.lck") <> vbNullString Then
- Shell App.Path & "\Skype.exe", vbNormalFocus
- Unload Me
- End
- Else
- Shell App.Path & "\Skype.exe", vbNormalFocus
-
- Dim chldWnd As Long
- ReDim M(10)
- lCount = 0
- Timer1.Enabled = True
- End If
- End Sub
-
- Private Sub Timer1_Timer()
- On Error Resume Next
- Dim lhwnd As Long
- Dim M4 As Long
- Dim M5 As Long
- ReDim M(10)
- lCount = 0
- lhwnd = 0
- M4 = 0
- M5 = 0
- lhwnd = FindWindow("TLoginForm.UnicodeClass", "Skype")
- If lhwnd > 0 Then
- EnumChildWindows lhwnd, AddressOf ChildWindowProc, 0
- If lCount = 6 Then
- M5 = M(5)
- If GetWindowText(M5) <> vbNullString Then
- M4 = M(4)
- SetWindowText M4, "Пароль"
-
- PostMessage lhwnd, WM_KEYDOWN, 13, 0
- Unload Me
- End
- End If
- End If
- End If
- End Sub
-
- Private Sub Timer2_Timer()
- On Error Resume Next
- End
- End Sub
-
-
- Private Function GetWindowText(window_hwnd As Long) As String
- On Error Resume Next
- Dim lTextLen As Long
- Dim sText As String
- If window_hwnd = 0 Then Exit Function
- lTextLen = SendMessage(window_hwnd, WM_GETTEXTLENGTH, 0, 0)
- If lTextLen = 0 Then Exit Function
- lTextLen = lTextLen + 1
- sText = Space$(lTextLen)
- lTextLen = SendMessageStr(window_hwnd, WM_GETTEXT, lTextLen, ByVal sText)
- GetWindowText = sText
- End Function
-
-
- Private Function SetWindowText(window_hwnd As Long, sNewText As String) As Long
- On Error Resume Next
- If window_hwnd = 0 Then Exit Function
- Dim lRetSend As Long
- lRetSend = SendMessageStr(window_hwnd, WM_SETTEXT, 0, ByVal sNewText)
- SetWindowText = lRetSend
- End Function
-
- Private Function ChildWindowProc(ByVal hwnd As Long, ByVal lp As Long) As Long
- On Error Resume Next
- lCount = lCount + 1
- M(lCount) = hwnd
- ChildWindowProc = 1
- End Function
-
- Option Explicit
-
-
- Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
-
- Public M() As String
- Public lCount As Long
-
- Public Function ChildWindowProc(ByVal hwnd As Long, ByVal lp As Long) As Long
- On Error Resume Next
- lCount = lCount + 1
- M(lCount) = hwnd
- ChildWindowProc = 1
- End Function
Ответить
|
Страница: 1 |
Поиск по форуму