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

請問每次登入奇摩知識都要輸入密碼(目前網頁只會記憶自己的帳號)
很麻煩
能不能用vb6來寫個程式作登入呢?
謝謝

2005-12-31 15:53:35 · 1 個解答 · 發問者 Anonymous in 電腦與網際網路 程式設計

謝謝你的解答
想請教一下
把它作成exe檔後
放到桌面上
竟然就無法執行
若是在檔案總管內執行exe檔就ok
不知那裡可以解決此問題呢?
謝謝

2006-01-01 10:48:31 · update #1

現在又可以了
可能我的電腦不穩定
謝謝

2006-01-01 16:38:32 · update #2

1 個解答

95/1/1補充
怎麼會呢?我的不會啊!!要不然我在每個按鍵執行碼後面加Sleep讓程式不要跑太快,你重新執行看看
----------------------------
因一直抓不到帳號及密碼之hwnd,故只好用模擬按鍵的方式,程式要有作用必須游標是停在帳號的TextBox上(基本上剛開啟登入網頁時游標是停在帳號的上面低),然後模擬按下Ctrl+A(全選)>帳號>Tab>Ctrl+A(全選)>密碼>Enter,以帳號為AbCdE密碼Ab123為例:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const KEYEVENTF_KEYUP = &H2
Const VK_CONTROL = &H11
Const VK_SHIFT = &H10
Const Win_Cls = "IEFrame"
Const Win_Str = "Yahoo!奇摩知識+ 登入 - Microsoft Internet Explorer"
Private Sub Command1_Click()
Dim Hw As Long, I As Integer, S As String
Hw = FindWindow(Win_Cls, Win_Str)
If Hw <> 0 Then
SetForegroundWindow Hw
DoEvents
'按Ctrl+A
keybd_event VK_CONTROL, 0, 0, 0: Sleep 50
keybd_event Asc("A"), 0, 0, 0: Sleep 50
keybd_event Asc("A"), 0, KEYEVENTF_KEYUP, 0: Sleep 50
keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0: Sleep 50

S = "AbCdE" '你的帳號
For I = 1 To Len(S)
KeyDn Mid(S, I, 1)
Next
'按Tab鍵
SendKeys "{Tab}", True: Sleep 50
'按Ctrl+A
keybd_event VK_CONTROL, 0, 0, 0: Sleep 50
keybd_event Asc("A"), 0, 0, 0: Sleep 50
keybd_event Asc("A"), 0, KEYEVENTF_KEYUP, 0: Sleep 50
keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0: Sleep 50
S = "A12345" '你的密碼
For I = 1 To Len(S)
KeyDn Mid(S, I, 1)
Next
'按Enter鍵
SendKeys "{Enter}", True

Else
MsgBox "找不到Yahoo!奇摩知識+ 登入視窗"
End If
End Sub

Sub KeyDn(ByVal K As String)
If Asc(K) > 64 And Asc(K) < 91 Then
keybd_event VK_SHIFT, 0, 0, 0: Sleep 50
keybd_event Asc(K), 0, 0, 0: Sleep 50
keybd_event Asc(K), 0, KEYEVENTF_KEYUP, 0: Sleep 50
keybd_event VK_SHIFT, 0, KEYEVENTF_KEYUP, 0: Sleep 50
Else
SendKeys K, True: Sleep 50
End If
DoEvents
End Sub

2005-12-31 21:29:45 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers