¥»©«³Ì«á¥Ñ white5168 ©ó 2012-6-23 20:19 ½s¿è
½Ð°Ý¦U¦ì¤j¤j,n¦p¦ó¦bVBAªºÀô¹Ò¤¤¨Ï¥ÎSendMessage©ÎPostMessage¨Ó¹ï"ÀɮפU¸ü"¹ï¸Ü²°¶i¦æ¾Þ§@?
¦pºô§} http://www.twse.com.tw/ch/trading/fund/BFI82U/BFI82U_print.php?begin_date=20120611&end_date=&report_type=day&language=ch&save=csv
¥H¤U¬O§Ú¨Ï¥Î¹Lªº¤èªk,¦ý¨ÌµLªk¦¨¥\- 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 PostMessage& Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
- Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) 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 Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
- Private Const WM_LBUTTONDOWN = &H201
- Private Const WM_LBUTTONUP = &H202
- Private Const BM_CLICK = &HF5
- Private Const MOUSEEVENTF_LEFTDOWN = &H2
- Private Const MOUSEEVENTF_LEFTUP = &H4
- Sub test()
- Dim IE As Object
- Dim hpwnd As Long, hcwnd As Long
- Dim iRet As Long
-
- Set IE = CreateObject("InternetExplorer.Application") '³]©wInternetExplorerª«¥ó
-
- strLink = "http://www.twse.com.tw/ch/trading/fund/BFI82U/BFI82U_print.php?begin_date=20120611&end_date=&report_type=day&language=ch&save=csv" 'ÀɮפU¸üºô§}
-
-
- With IE
- .Visible = True '¶}±ÒIE
- .Navigate strLink '³sµ²ºô§}
- End With
-
-
- Do
- hpwnd = FindWindow("#32770", "ÀɮפU¸ü") '§ì¨ú¹ï¸Ü²°ªºhandle
- DoEvents
- Loop While hpwnd = 0
-
- Do
- hcwnd = FindWindowEx(hpwnd, 0, "Button", "Àx¦s(&S)") '§ì¨ú¹ï¸Ü²°«ö¶sªºhandle
- DoEvents
- Loop While hcwnd = 0
- iRet = SetForegroundWindow(hcwnd) '³]©wµJÂI
- '¦b¥H¤U¤ºØ¤èªk¸g¬Ò¥Ñwindowsµo°e°T®§¼Ò¥é·Æ¹««öÁä,,¨ÌµMµLªk½Ð°Ý¦U¦ì¬O§_¦³¨ä¥L¤èªk¥i¥H°µ¨ìwindowsµo°e°T®§¼Ò¥é·Æ¹««öÁä
- '¤èªk¤@
- iRet = SendMessage(hcwnd, BM_CLICK, 0, 0) '³z¹Lwindowsµo°e°T®§¼Ò¥é·Æ¹««öÁä
- '¤èªk¤G
- 'iRet = SendMessage(hcwnd, WM_LBUTTONDOWN, 0, 0) '·Æ¹«¥ªÁä«ö¤U
- 'iRet = SendMessage(hcwnd, WM_LBUTTONUP, 0, 0) '·Æ¹«¥ªÁäÄÀ©ñ
- '¤èªk¤T
- 'PostMessage hcwnd, WM_LBUTTONDOWN, 0&, CLng(&H90009) '·Æ¹«¥ªÁä«ö¤U
- 'PostMessage hcwnd, WM_LBUTTONUP, 0&, CLng(&H90009) '·Æ¹«¥ªÁäÄÀ©ñ
- 'PostMessage hcwnd, WM_LBUTTONDOWN, 0&, CLng(&H90009) '·Æ¹«¥ªÁä«ö¤U
- 'PostMessage hcwnd, WM_LBUTTONUP, 0&, CLng(&H90009) '·Æ¹«¥ªÁäÄÀ©ñ
- '¤èªk¥|
- 'mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 '³z¹L·Æ¹«¨Æ¥ó, ·Æ¹«¥ªÁä«ö¤U
- 'mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 '³z¹L·Æ¹«¨Æ¥ó, ·Æ¹«¥ªÁäÄÀ©ñ
-
- '¤èªk¤
- 'SendKeys "%s", True '³z¹L«ö¤UAlt + s Àx¦sÀÉ®×
- Set IE = Nothing 'ÄÀ©ñ¸ê·½
- End Sub
½Æ»s¥N½X |