au3查看股票价格(二)

这次用GUI窗口实现股票查询和显示。

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FontConstants.au3>
mainrun()
Func mainrun()
    GUICreate("股票信息", 600, 600)
    Local Const $sFont = "Arial"
    Local $idMyedit = GUICtrlCreateEdit("Info" & @CRLF, 0, 0, 600, 600, 0)
    GUICtrlSetFont($idMyedit, 36, $FW_NORMAL,  $sFont) ;
    GUISetState(@SW_SHOW)
    Send("{END}")
    While 1
        Local $HTML = BinaryToString(InetRead('http://hq.sinajs.cn/list=sh600000'))
        $aArray = StringSplit($HTML, ',')
        If(UBound($aArray) < 2) Then
            ContinueLoop
        EndIf
        $gname = StringSplit($aArray[1], '"')
        $diff = Round($aArray[4] - $aArray[3], 2)
        $diffpercentage = Round($diff / $aArray[3] * 100, 3)
        $show1 = $gname[2] & @CRLF &'现价: ' & $aArray[4] & @CRLF &'涨跌幅: ' & $diff & @CRLF &'涨跌%: ' & $diffpercentage & @CRLF
        $show2 = '最高: ' & $aArray[5] & @CRLF
        $show3 = '最低: ' & $aArray[6] & @CRLF
        $show4 = '今开: ' & $aArray[2] & @CRLF
        $show5 = '昨收: ' & $aArray[3] & @CRLF
        $showtime = $aArray[31] &' '&$aArray[32] & @CRLF
        GUICtrlSetData($idMyedit, $show1)
        GUICtrlSetData($idMyedit, $show2, 1)
        GUICtrlSetData($idMyedit, $show3, 1)
        GUICtrlSetData($idMyedit, $show4, 1)
        GUICtrlSetData($idMyedit, $show5, 1)
        GUICtrlSetData($idMyedit, $showtime, 1)
        Sleep(3000)
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch
    WEnd
    GUIDelete()
EndFunc

 

posted @ 2017-09-08 07:24  greershk  阅读(226)  评论(0编辑  收藏  举报