English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

有一個程式
執行後會產生一個inputbox的對話方塊
要求你輸入姓名如:Peter
如下面網址圖片中所示
http://myhome.apbb.com.tw/pinget8/input1.GIF

請問:
如何另外寫一個程式
自動幫我輸入peter到上面圖片中的inputbox中並按\"確定\"呢?
謝謝

2006-02-14 16:44:14 · 3 個解答 · 發問者 strike 5 in 電腦與網際網路 程式設計

3 個解答

'利用API可做的到
Private Const WM_SETTEXT = &HC

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 Sub Command1_Click()
Dim H As Long
'先找InputBox的hWnd
H = FindWindow("#32770", "請輸入姓名")
If H <> 0 Then
 '再找裡面TextBox的hWnd
 H = FindWindowEx(H, ByVal 0&, "Edit", vbNullString)
 '找到後輸入Peter
 If H <> 0 Then SendMessage H, WM_SETTEXT, 0&, ByVal "Peter"
End If
End Sub

2006-02-15 18:03:31 補充:
抱歉沒看到還要按確定,請加上此APIPrivate Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long

2006-02-15 18:06:56 補充:
'將程式改成Dim H As LongH = FindWindow("#32770", "請輸入姓名")If H <> 0 Then '讓InputBox取得駐點 SetForegroundWindow H H = FindWindowEx(H, ByVal 0&, "Edit", vbNullString) If H <> 0 Then  SendMessage H, WM_SETTEXT, 0&, ByVal "Peter"  SendKeys "{Enter}", True'按確定 End IfEnd If

2006-02-14 20:54:12 · answer #1 · answered by W.J.S. 7 · 0 0

不是
只想省點麻煩

2006-02-15 01:41:40 · answer #2 · answered by strike 5 · 0 0

你想當駭客嗎 ?

2006-02-14 22:14:46 · answer #3 · answered by 青楓 2 · 0 0

fedest.com, questions and answers