- ©«¤l
- 23
- ¥DÃD
- 0
- ºëµØ
- 0
- ¿n¤À
- 73
- ÂI¦W
- 294
- §@·~¨t²Î
- XP
- ³nÅ骩¥»
- Office 2003
- ¾\ŪÅv
- 20
- µù¥U®É¶¡
- 2012-4-21
- ³Ì«áµn¿ý
- 2024-11-23
|
¦^´_ 14# joey0415
¥t¤@ºØ¤è¦¡,¸Õ¸Õ¬Ý...- Option Explicit
- #If Win64 Then
- Private Declare PtrSafe Function GetWindow Lib "USER32" (ByVal hWnd As LongPtr, ByVal wCmd As LongPtr) As LongPtr
- Private Declare PtrSafe Function SetForegroundWindow Lib "USER32" (ByVal hWnd As Long) As Long
- Private Declare PtrSafe Function FindWindow Lib "USER32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
- Private Declare PtrSafe Function FindWindowEx Lib "USER32" Alias "FindWindowExA" (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPtr
- Private Declare PtrSafe Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hWnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, lParam As Any) As LongPtr
- #Else
- Private Declare Function GetWindow Lib "user32" (ByVal HWND As Long, ByVal wCmd As Long) As Long
- Private Declare Function SetForegroundWindow Lib "user32" (ByVal HWND 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.dll" 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.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
- #End If
- Private Const WM_CLOSE = &H10
- Private Const GW_HWNDNEXT = 2
- Private Const GW_CHILD = 5
- Private Const BM_CLICK = &HF5
- Sub ÂIÀ»()
- Cells.Clear
- Dim hWndChild, hWndPopup, x, Retries As Integer: Retries = 10
-
- With CreateObject("InternetExplorer.Application")
- .Visible = True
- .Navigate "http://www.tdcc.com.tw/smWeb/QryStock.jsp"
-
- Do While .Busy Or .ReadyState <> 4 'µ¥Ôºô¶¤U¸ü§¹²¦
- DoEvents
- Loop
- Set x = .document.all.tags("option") '¬d¤U©Ô¿ï³æ
- x(7).Selected = True '¿ï¨ú¸Ó¤l¶µ¥Ø
-
- .document.getElementsByName("StockNo")(0).Value = "6456"
- .document.getElementsByName("sub")(0).Click
-
- Do While (.Busy Or .ReadyState <> 4) And 0 < Retries
-
- hWndChild = GetWindow(.hWnd, GW_CHILD)
-
- If 0 <> hWndChild Then
- Do While hWndChild
- hWndPopup = FindWindow("#32770", "ºô¶°T®§") '#32770 The class for a dialog box
- If 0 <> hWndPopup Then
- SendMessage FindWindowEx(hWndPopup, 0, "Button", "½T©w"), BM_CLICK, 0, 0
- Else
- Exit Do
- End If
- 'SetForegroundWindow .hWnd 'HWND is the HWND of the myIEWindow
- 'Application.SendKeys "~", True
- hWndChild = GetWindow(hWndChild, GW_HWNDNEXT)
- Loop
-
- End If
- Application.Wait Now + #12:00:01 AM#
- DoEvents
- Retries = Retries - 1
- Loop
- If 0 = Retries Then
- AppActivate Application.Caption
- MsgBox "µLªkÃö³¬°T®§µøµ¡!", vbCritical
- Exit Sub
- End If
- '-------------------¥H¤U¬°¥¢µJ³B¡AµLªkÂIÀ»
- Stop
- .document.getElementsByName("StockNo")(0).Value = "1101"
- .document.getElementsByName("sub")(0).Click
-
- Do While .Busy Or .ReadyState <> 4 'µ¥Ôºô¶¤U¸ü§¹²¦
- DoEvents
- Loop
-
- Stop
- .Quit
- End With
- End Sub
½Æ»s¥N½X |
|