Champak Posted September 5, 2009 Share Posted September 5, 2009 Original credit for this comes from Here, I just wanted a lot more and expanded it. My problem is the ticker. When there are a lot of stocks they are wrapped to another line instead of all being on the same line and scrolling through. I have to expand/widen the app/ticker to get everything to scroll through properly....but that will only work to a certain extent, because if there are enough stocks, no matter how far you widen the ticker they will wrap to another line. So, can someone fix this please...the ticker and how it is set up.And yes the coding is not clean/properly named variables and such...just through it together.Thanks.expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #Include <Array.au3> #include <IE.au3> #Include <string.au3> #include <GuiListView.au3> #include <WinAPI.au3> Opt("WinTitleMatchMode", 2) Global $StockImage = @TempDir & '\stockimage.png' Global $TickerEntries, $TickerTimer, $TickerText;, $StockSPLIT = 1 Global $GUI_DOCKHORZ=$GUI_DOCKLEFT+$GUI_DOCKRIGHT Global $GUI_DOCKMARQUEE=$GUI_DOCKHORZ+$GUI_DOCKHEIGHT Global $GUI_InitSize Global $REGLOCATION = "HKEY_CURRENT_USER\SOFTWARE\MyStocks" Global $Width = 400 Global $OIE Global $GUI_DetailedInfo, $mmmm, $TickerText Global $GUI_StockChart, $hGraphic, $hImage, $Button6, $Button7, $Button8, $Button9, $Button10, $Button11, $Button12 Global $CurrentStockSymbal, $CurrentStockName RegRead ( $REGLOCATION, "MyStocks" ) If @error Then RegWrite($REGLOCATION, "MyStocks", "REG_MULTI_SZ", "") Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Stock Ticker", $Width, 164, -1,-1,$WS_CAPTION + $WS_SIZEBOX + $WS_SYSMENU, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUISetOnEvent($GUI_EVENT_CLOSE,'GUI_Close') $Label1 = GUICtrlCreateLabel(" Loading Ticker... Please wait.", 0, 0, $Width-20, 21, -1, $WS_EX_STATICEDGE) GUICtrlSetResizing(-1,$GUI_DOCKMARQUEE+$GUI_DOCKTOP) GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetBkColor(-1, 0x000000) $RollButton=GUICtrlCreateButton('+',$Width-20,0,20,21) GUICtrlSetResizing(-1,$GUI_DOCKSIZE+$GUI_DOCKTOP+$GUI_DOCKRIGHT) GUICtrlSetOnEvent(-1,'GUI_QuickToggle') $CheckBox = GUICtrlCreateCheckbox("Real Name", 1, 21, 110, 22) GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) ;GUICtrlSetOnEvent(-1,'GUI_RealName') $Input1 = GUICtrlCreateInput("", 1, 41, 110, 21) GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) $Input2 = GUICtrlCreateInput("", 1, 62, 110, 21) GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) $Button1 = GUICtrlCreateButton("Quick Quote", 112, 40, 77, 22, 0) GUICtrlSetOnEvent(-1,'GUI_ReadStockSymbol') GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) $Button2 = GUICtrlCreateButton("Set Ticker", 112, 62, 77, 22, 0) GUICtrlSetOnEvent(-1,'GUI_SetTicker') GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) $Button3 = GUICtrlCreateButton("Get Info", 192, 40, 77, 22, 0) GUICtrlSetOnEvent(-1,'GUI_GetInfo') GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) $Button4 = GUICtrlCreateButton("Delete Ticker", 192, 62, 77, 22, 0) GUICtrlSetOnEvent(-1,'GUI_DeleteTicker') GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) $Button5 = GUICtrlCreateButton("Get Chart", 271, 62, 77, 22, 0) GUICtrlSetOnEvent(-1,'GUI_GetChart') GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) $List = GUICtrlCreateListView("Company Stock|Symbol", 1, 85, $Width, 80, -1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_TRACKSELECT, $LVS_EX_DOUBLEBUFFER)) GUICtrlSetFont(-1, 10, 9) _GUICtrlListView_SetColumnWidth($List, 0, $Width-126) _GUICtrlListView_SetColumnWidth($List, 1, $Width-300) GUICtrlSetResizing($List,$GUI_DOCKLEFT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM) GUISetState(@SW_HIDE) $GUI_InitSize=WinGetPos($Form1) #EndRegion ### END Koda GUI section ### ;GUIRegisterMsg($WM_GETMINMAXINFO, "MY_WM_GETMINMAXINFO"); Ripped from Zedna - <a href='[url="http://www.autoitscript.com/forum/index.php?showtopic=63272&view=findpost&p=472003"]http://www.autoitscript.com/forum/index.php?showtopic=63272&view=findpost&p=472003[/url]' class='bbc_url' title='External link' rel='external'>[url="http://www.autoitscript.com/forum/index....p?showtopic=63272&view=findpost&p=472003"]http://www.autoitscript.com/forum/index....p?showtopic=63272&view=findpost&p=472003[/url]</a> Global $TickerEntries,$TickerTimer, $TickerText GUI_QuickToggle() GUI_SetTicker() ;#cs ;_ArrayDisplay($aData1) ;Global $TickerEntries[UBound($aData1)] ;For $i = 1 To UBound($aData1) - 1 ; $TickerEntries[$i] = $aData1[$i][1] ;Next ;#ce ;$TickerEntries = _ArrayToString($aData2, ",") ;_ArrayDisplay($TickerEntries) ;MsgBox(0,0,$TickerEntries) _IEErrorHandlerRegister("_MyErrFunc") _IEErrorHandlerDeRegister() _IEErrorHandlerRegister() _GDIPlus_Startup() Global $hCtrl=ControlGetHandle($Form1,'',$Label1) Global $gro Global $grb Global $gr Global $hFamily = _GDIPlus_FontFamilyCreate ("Arial") Global $hFont = _GDIPlus_FontCreate ($hFamily, 10, 2) Global $tLayout Global $hFormat = _GDIPlus_StringFormatCreate () Global $hBrush=_GDIPlus_BrushCreateSolid(0xFF00FF00) Global $iMove=0 Global $gr_dim[4]=[0,0,0,0] ;WinMove($Form1,'',100,100,500) GUISetState(@SW_SHOW) GUI_TickerSize() GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_PAINT, "WM_PAINT") $DeleteInfo = False $SetList = True Global $NAStock[1][2] While 1 If IsArray($TickerEntries) Then If TimerDiff($TickerTimer)>60000 Then $TickerText='' If $SetList = True Then ;GUISetState(@SW_LOCK, $Form1) _GUICtrlListView_BeginUpdate($List) _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($List)) EndIf For $i=1 To UBound($TickerEntries)-1 If StringLen($TickerEntries[$i])<1 Then ContinueLoop Local $StockInfo=_Stock_GetInfo($TickerEntries[$i]) If IsArray($StockInfo) Then; And Not StringIsASCII($TickerText) Then If $StockInfo[3] = "N/A" Then $DeleteInfo = True _ArrayAdd2D($StockInfo[1], $i) ContinueLoop;So the info isn't added to the ticker EndIf $TickerText&=$StockInfo[1]&' '&' &$StockInfo[2]& ' '&$StockInfo[3]&' ('&$StockInfo[4]&') // ' EndIf Next ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; If $DeleteInfo = True Then $DeleteInfo = False $StockREAD = RegRead($REGLOCATION, "MyStocks") $StockSPLIT = StringSplit($StockREAD, @LF) _ArrayDelete($StockSPLIT, 0) _ArrayDelete($NAStock, UBound($NAStock)) For $i = 0 To UBound($NAStock) - 1 $55 = _ArraySearch($StockSPLIT, $NAStock[$i][0]) If @error Then ConsoleWrite("+ ERROR = " & $55 & " --- " & $NAStock[$i][0] & @LF) _ArrayDelete($StockSPLIT, Number($55)) If @error Then ConsoleWrite("! ERROR") $a = _GUICtrlListView_FindText($List, $NAStock[$i][0]) _GUICtrlListView_DeleteItem($List, Number($a)) Next RegWrite($REGLOCATION, "MyStocks","REG_MULTI_SZ",_ArrayToString($StockSPLIT, @LF)) If $SetList = True Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($List)) EndIf $TickerText='' $NAStock = "" Global $NAStock[1][2];Reset this array so the stocks to be deleted and their position in the TickerEntries can be stored $j = 1 For $i=1 To UBound($TickerEntries)-1 If StringLen($TickerEntries[$i])<1 Then ContinueLoop Local $StockInfo=_Stock_GetInfo($TickerEntries[$i]) If IsArray($StockInfo) Then ;_ArrayDisplay($StockInfo) If $StockInfo[3] = "N/A" Then _ArrayAdd2D($StockInfo[1], $i);Adding the stocks to be deleted in the $NAStock array inside this function ; ConsoleWrite("! " & $i & @LF) $mmmm &= " " & $j & "/ " & $StockInfo[1] & @LF $j += 1 ContinueLoop;So the info isn't added to the ticker EndIf $TickerText&=$StockInfo[1]&' '&' &$StockInfo[2]& ' '&$StockInfo[3]&' ('&$StockInfo[4]&') // ' EndIf Next MsgBox(262144 + 48,"Unretrievable Stock", "The following stocks do not exist and will be deleted:" & @CRLF & @CRLF & $mmmm) ;Get rid of the stocks that don't exist from the listview For $i = 0 To UBound($NAStock) - 1 $a = _GUICtrlListView_FindInText($List, $NAStock[$i][0]) _GUICtrlListView_DeleteItem(GUICtrlGetHandle($List), Number($a)) Next ;Get rid of the stocks that don't exist from the TickerEntries array _ArrayDelete($NAStock, Number(UBound($NAStock))) For $i = UBound($NAStock) - 1 To 0 Step -1 _ArrayDelete($TickerEntries, Number($NAStock[$i][1])) Next $NAStock = "" Global $NAStock[1][2];Reset this array for the next time $DeleteInfo = False #cs If $StockInfo[3] = "N/A" Then ;_ArrayDisplay($StockInfo) $StockREAD = RegRead($REGLOCATION, "MyStocks") $TickerEntries = StringSplit($StockREAD, @LF) _ArrayDelete($TickerEntries, 0) $tt = _ArraySearch($TickerEntries, StringReplace($StockInfo[1],'"',"")) ConsoleWrite("+ " & $tt & " -- " & $StockInfo[1] &@CRLF) _ArrayDelete($TickerEntries, Number($tt)) ;_ArrayDisplay($TickerEntries) RegWrite($REGLOCATION, "MyStocks","REG_MULTI_SZ",_ArrayToString($TickerEntries, @LF)) Return EndIf _GUICtrlListView_AddItem($List, $StockInfo[5]) $rr = Number(_GUICtrlListView_GetItemCount($List)) _GUICtrlListView_AddSubItem($List, $rr-1, $TickerEntries[$rr], 1) #ce EndIf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;If $SetList = True Then GUISetState(@SW_UNLOCK, $Form1) If $SetList = True Then _GUICtrlListView_EndUpdate($List) $SetList = False ; If $DeleteInfo = False Then $TickerTimer=TimerInit() ; EndIf Else GUI_DrawTicker($TickerText) Sleep(25) $iMove+=1 EndIf Else Sleep(100) EndIf WEnd Func GUI_ReadStockSymbol() GUICtrlSetState($Button1,$GUI_DISABLE) GUICtrlSetState($Button2,128) If GUICtrlRead($CheckBox) = $GUI_CHECKED Then _IELoadWaitTimeout(120000) $OIE = _IECreate("", 0, 0) If @error Then MsgBox(262144, "Error", "Problem retrieving stock info.") Return EndIf _IENavigate($OIE, "[url="http://finance.yahoo.com/q?s="]http://finance.yahoo.com/q?s=[/url]" & GUICtrlRead($Input1)) $OELEMENTSs = _IEGetObjById($OIE, "yfi_investing_head") $OELEMENTSss = _IETagNameGetCollection($OELEMENTSs, "h1", 0) $rrrr = _StringBetween($OELEMENTSss.innertext, "(", ")") _IEQuit($OIE) If Not IsArray($rrrr) Then MsgBox(262144, "Unknown Company", "Unable to find stock symbols for " & GUICtrlRead($Input1) & "." & @CRLF & _ "Either it is not publically traded or the name associated" & @CRLF & _ "with the stock is different.") GUICtrlSetState($Button1,$GUI_ENABLE) GUICtrlSetState($Button2,64) Return EndIf Local $StockInfo=_Stock_GetInfo($rrrr[0]) Else Local $StockInfo=_Stock_GetInfo(GUICtrlRead($Input1)) EndIf If IsArray($StockInfo) Then Local $t=$StockInfo[5]&' ' $t&='Close: '&$StockInfo[2]&' ' $t&='Change: '&$StockInfo[3]&' ('&$StockInfo[4]&')' Local $timer=TimerInit() $iMove=0 While TimerDiff($timer)<8000 GUI_DrawTicker($t) Sleep(25) $iMove+=1 WEnd EndIf GUICtrlSetState($Button1,$GUI_ENABLE) GUICtrlSetState($Button2,64) EndFunc #cs Func GUI_RealName() If GUICtrlRead($CheckBox) = $GUI_CHECKED Then ConsoleWrite("++") EndIf EndFunc #ce Func GUI_SetTicker() GUICtrlSetState($Button1,128) GUICtrlSetState($Button2,128) $TickerTimer=0 $TickerEntries='' $TickerText='' ;$TickerEntries=StringSplit(GUICtrlRead($Input2)&',',',') $InputREAD = StringSplit(GUICtrlRead($Input2), ",") _ArrayDelete($InputREAD, 0) If GUICtrlRead($CheckBox) = $GUI_CHECKED Then _IELoadWaitTimeout(120000) $OIE = _IECreate("", 0, 0) If @error Then MsgBox(262144, "Error", "Problem retrieving stock info.") Return EndIf For $i = UBound($InputREAD) - 1 To 0 Step -1 _IENavigate($OIE, "[url="http://finance.yahoo.com/q?s="]http://finance.yahoo.com/q?s=[/url]" & $InputREAD[$i]) $OELEMENTSs = _IEGetObjById($OIE, "yfi_investing_head") $OELEMENTSss = _IETagNameGetCollection($OELEMENTSs, "h1", 0) $rrrr = _StringBetween($OELEMENTSss.innertext, "(", ")") If IsArray($rrrr) Then $InputREAD[$i] = $rrrr[0] Else $TickerText &= " " & $InputREAD[$i] & @CRLF _ArrayDelete($InputREAD, $i) EndIf Next _IEQuit($OIE) EndIf $StockREAD = RegRead($REGLOCATION, "MyStocks") $StockSPLIT = StringSplit($StockREAD, @LF) If $StockSPLIT[1] = "" Then _ArrayDelete($StockSPLIT, 1) If GUICtrlRead($Input2) <> "" Then _ArrayConcatenate($StockSPLIT, $InputREAD) GUICtrlSetData($Input2, "") EndIf Global $TickerEntries[UBound($StockSPLIT)] For $i = 0 To UBound($StockSPLIT) - 1 $TickerEntries[$i] = $StockSPLIT[$i];[1] Next _ArrayDelete($StockSPLIT, 0) RegWrite($REGLOCATION, "MyStocks","REG_MULTI_SZ",_ArrayToString($StockSPLIT, @LF)) If StringIsASCII($TickerText) Then MsgBox(262144, "Unknown Companies", "Unable to find stock symbols for the following companies." & @CRLF & _ "They either are not publically traded or the name associated" & @CRLF & _ "with the stock is different." & @CRLF & @CRLF & _ $TickerText) EndIf GUICtrlSetState($Button1,64) GUICtrlSetState($Button2,64) $SetList = True EndFunc Func GUI_DeleteTicker() ;Grab info from registry delete the stock and then resave it, it is then reread back into the ticker GUICtrlSetState($Button1,$GUI_DISABLE) GUICtrlSetState($Button2,128) $TickerTimer=0 $TickerEntries='' $TickerText='' $a = _GUICtrlListView_GetSelectedIndices($List) $b = _GUICtrlListView_GetItemText($List, Number($a), 1) $StockREAD = RegRead($REGLOCATION, "MyStocks") $StockSPLIT = StringSplit($StockREAD, @LF) $55 = _ArraySearch($StockSPLIT, $b) _ArrayDelete($StockSPLIT, $55) Global $TickerEntries[UBound($StockSPLIT)] For $i = 0 To UBound($StockSPLIT) - 1 $TickerEntries[$i] = $StockSPLIT[$i];[1] Next _ArrayDelete($StockSPLIT, 0) RegWrite($REGLOCATION, "MyStocks","REG_MULTI_SZ",_ArrayToString($StockSPLIT, @LF)) GUICtrlSetState($Button1,$GUI_ENABLE) GUICtrlSetState($Button2,64) $SetList = True EndFunc Func GUI_QuickToggle() Local $wgp=WinGetPos($Form1) If $wgp[3]>70 Then ; not the right height because of Visual Styles differences X( ; but it can't go less than the forced min. WinMove($Form1,'',$wgp[0],$wgp[1],$wgp[2],45) Else WinMove($Form1,'',$wgp[0],$wgp[1],$wgp[2],150); not right again. :P - hopefully hits the max Height. EndIf EndFunc Func GUI_GetInfo() _IELoadWaitTimeout(120000) $OIE = _IECreate("", 0, 0) If @error Then MsgBox(262144, "Error", "Problem retrieving stock info.") Return EndIf $a = _GUICtrlListView_GetSelectedIndices($List) $b = _GUICtrlListView_GetItemText($List, Number($a), 0) $c = _GUICtrlListView_GetItemText($List, Number($a), 1) _IENavigate($OIE, "[url="http://finance.yahoo.com/q?s="]http://finance.yahoo.com/q?s=[/url]" & $c) $GUI_DetailedInfo = GUICreate("Current Detailed Info: " & $b, 400, 280, 200, 270, -1, $WS_EX_TOPMOST) GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_CloseSecondary") $OELEMENTS = _IETagNameGetCollection($OIE, "div") For $rr In $OELEMENTS ;ConsoleWrite($rr.id & @LF) If String($rr.id) = "yfi_market_summary" Then $OELEMENTSs = _IETagNameGetCollection($rr, "span", 0) GUICtrlCreateLabel($OELEMENTSs.innertext & ":", 10, 10, 40, 25) _FONTSTYLING(-1, 12, 800, 0x000000) $OELEMENTSs = _IETagNameGetCollection($rr, "span", 1) GUICtrlCreateLabel($OELEMENTSs.innertext, 50, 10, 70, 25) _FONTSTYLING(-1, 12, 800, 0x000000) $OELEMENTSs = _IETagNameGetCollection($rr, "span", 2) GUICtrlCreateLabel($OELEMENTSs.innertext & ":", 160, 10, 70, 25) _FONTSTYLING(-1, 12, 800, 0x000000) $OELEMENTSs = _IETagNameGetCollection($rr, "span", 3) GUICtrlCreateLabel($OELEMENTSs.innertext, 225, 10, 70, 25) _FONTSTYLING(-1, 12, 800, 0x000000) ExitLoop EndIf Next $OELEMENTSs = _IETagNameGetCollection($OIE, "table", 0) _IEGetObjById ($OIE, "table1") If Not @error Then ;This is a stock GetInfo($OELEMENTSs, "table1", "th", 10) GetInfo($OELEMENTSs, "table1", "td", 90) GetInfo($OELEMENTSs, "table2", "th", 230) GetInfo($OELEMENTSs, "table2", "td", 310) Else ;This is a fund GetInfo($OELEMENTSs, "table", "th", 120) GetInfo($OELEMENTSs, "table", "td", 230) EndIf ;GUICtrlCreateButton("Close", 160, 270, 77, 22) ;GUICtrlSetOnEvent(-1,'GUI_CloseInfo') GUISetState() EndFunc Func GUI_GetChart() ; Local $qf=@TempDir&'\yahoo_stockinfo.csv' _IELoadWaitTimeout(120000) $OIE = _IECreate("", 0, 0) If @error Then MsgBox(262144, "Error", "Problem retrieving stock chart.") Return EndIf $a = _GUICtrlListView_GetSelectedIndices($List) $CurrentStockName = _GUICtrlListView_GetItemText($List, Number($a), 0) $CurrentStockSymbal = _GUICtrlListView_GetItemText($List, Number($a), 1) $Range = "1d" $RangeTitle = "1 Day" _RetrieveStockImage($Range) $GUI_StockChart = GUICreate($RangeTitle & " Stock Chart Info: " & $CurrentStockName, 512, 325, 200, 270, -1, $WS_EX_TOPMOST) GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_CloseSecondary") $hImage = _GDIPlus_ImageLoadFromFile($StockImage) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($GUI_StockChart) $Button6 = GUICtrlCreateButton("1 Day", 10, 295, 67, 22) GUICtrlSetOnEvent(-1,'GUI_StockRange') GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) $Button7 = GUICtrlCreateButton("5 Day", 80, 295, 67, 22) GUICtrlSetOnEvent(-1,'GUI_StockRange') GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) $Button8 = GUICtrlCreateButton("3 Month", 150, 295, 67, 22) GUICtrlSetOnEvent(-1,'GUI_StockRange') GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) $Button9 = GUICtrlCreateButton("6 Month", 220, 295, 67, 22) GUICtrlSetOnEvent(-1,'GUI_StockRange') GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) $Button10 = GUICtrlCreateButton("1 Year", 290, 295, 67, 22) GUICtrlSetOnEvent(-1,'GUI_StockRange') GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) $Button11 = GUICtrlCreateButton("2 Year", 360, 295, 67, 22) GUICtrlSetOnEvent(-1,'GUI_StockRange') GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) $Button12 = GUICtrlCreateButton("Max", 430, 295, 67, 22) GUICtrlSetOnEvent(-1,'GUI_StockRange') GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) GUISetState() _IEQuit($OIE) #cs $oIMGs = _IEImgGetCollection ($ImageTable2) ; Loop through all IMG tags and save file to local directory using INetGet For $oIMG in $oIMGs $sImgUrl = $oIMG.src ConsoleWrite($sImgUrl & @LF) $sImgFileName = $oIMG.nameProp INetGet($sImgUrl, $sImgDir & $sImgFileName) Next #ce EndFunc Func GUI_StockRange() _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphic) If @GUI_CtrlId = $Button6 Then $Range = "1d" $RangeTitle = "1 Day" ElseIf @GUI_CtrlId = $Button7 Then $Range = "5d" $RangeTitle = "5 Day" ElseIf @GUI_CtrlId = $Button8 Then $Range = "3m" $RangeTitle = "3 Month" ElseIf @GUI_CtrlId = $Button9 Then $Range = "6m" $RangeTitle = "6 Month" ElseIf @GUI_CtrlId = $Button10 Then $Range = "1y" $RangeTitle = "1 Year" ElseIf @GUI_CtrlId = $Button11 Then $Range = "2y" $RangeTitle = "2 Year" ElseIf @GUI_CtrlId = $Button12 Then $Range = "my" $RangeTitle = "Max History" EndIf _IELoadWaitTimeout(120000) $OIE = _IECreate("", 0, 0) If @error Then MsgBox(262144, "Error", "Problem retrieving stock chart.") Return EndIf _RetrieveStockImage($Range) _IEQuit($OIE) $hImage = _GDIPlus_ImageLoadFromFile($StockImage) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($GUI_StockChart) WinSetTitle(" Stock Chart Info: " & $CurrentStockName, "", $RangeTitle & " Stock Chart Info: " & $CurrentStockName) EndFunc Func _RetrieveStockImage($RangeImage) ;_IENavigate($OIE, "[url="http://finance.yahoo.com/q/bc?t=6m&s="]http://finance.yahoo.com/q/bc?t=6m&s=[/url]" & $CurrentStockSymbal & "&l=off&z=m&q=l&c=") _IENavigate($OIE, "[url="http://finance.yahoo.com/q/bc?s="]http://finance.yahoo.com/q/bc?s=[/url]" & $CurrentStockSymbal & "&t=" & $RangeImage) ;$sImgDir = "C:\Documents and Settings\Mobile Business\Desktop\stockimage\"; Please make certain this folder already exists (silent failure if not) $ImageTable = _IETableGetCollection($oIE) For $oIMG in $ImageTable If String($oIMG.classname) = "yfnc_datamodoutline1" Then $ImageTable2 = _IETagNameGetCollection ($oIMG, "tr", 6) $ImageTable3 = _IETagNameGetCollection ($ImageTable2, "img", 0) ExitLoop EndIf Next $sImgUrl = $ImageTable3.src INetGet($sImgUrl, $StockImage) EndFunc Func GUI_Close() If @InetGetActive Then InetGet('abort') $TickerTimer=0 $TickerEntries='' $TickerText='' $tLayout=0 If $hFamily Then _GDIPlus_FontFamilyDispose($hFamily) If $hFont Then _GDIPlus_FontDispose($hFont) If $hFormat Then _GDIPlus_StringFormatDispose($hFormat) If $hBrush Then _GDIPlus_BrushDispose($hBrush) If $gr Then _GDIPlus_GraphicsDispose($gr) If $grb Then _GDIPlus_BitmapDispose($grb) If $gro Then _GDIPlus_GraphicsDispose($gro) If $hImage Then _GDIPlus_ImageDispose($hImage) If $hGraphic Then _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUISetState(@SW_HIDE) GUIDelete($Form1) Exit EndFunc Func GUI_CloseSecondary() If WinActive($GUI_StockChart) Then GUIDelete($GUI_StockChart) ElseIf WinActive($GUI_DetailedInfo) Then GUIDelete($GUI_DetailedInfo) EndIf EndFunc Func GUI_TickerSize() Global $gro, $grb, $gr_dim $gr_dim=ControlGetPos($Form1,'',$Label1) ; ConsoleWrite('TickerResize '&$gr_dim[2]&@CRLF) Local $cgp=$gr_dim If $gro Then _GDIPlus_GraphicsDispose($gro) $gro=_GDIPlus_GraphicsCreateFromHWND($hCtrl) If $gr Then _GDIPlus_GraphicsDispose($gr) If $grb Then _GDIPlus_BitmapDispose($grb) $grb=_GDIPlus_BitmapCreateFromGraphics($cgp[2],$cgp[3],$gro); I'd only make one - but the darn thing has to resize! $gr=_GDIPlus_ImageGetGraphicsContext($grb) EndFunc Func GUI_DrawTicker($str) Global $gr_dim,$iMove Local $cgp=$gr_dim If $iMove>$cgp[2] Then ; ConsoleWrite('TickerBack '&$iMove&'>'&$cgp[2]&@CRLF) $iMove=0 EndIf _GDIPlus_GraphicsClear($gr,0xFF000000) $tLayout = 0 $tLayout = _GDIPlus_RectFCreate ($iMove,0, $cgp[2], $cgp[3]) _GDIPlus_GraphicsDrawStringEx ($gr, $str, $hFont, $tLayout, $hFormat, $hBrush) $tLayout = 0 $tLayout = _GDIPlus_RectFCreate ($iMove-$cgp[2],0, $cgp[2], $cgp[3]) _GDIPlus_GraphicsDrawStringEx ($gr, $str, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_GraphicsDrawImageRect($gro, $grb, 0, 0, $cgp[2], $cgp[3]);copy to bitmap EndFunc #cs Func GUI_CloseInfo() GUIDelete($GUI_DetailedInfo) EndFunc #ce Func GetInfo($Collection, $TableString, $TableID, $PLeft) $i = 60 $OELEMENTSsst = _IETagNameGetCollection($Collection, $TableID) For $rrs In $OELEMENTSsst GUICtrlCreateLabel($rrs.innertext,$PLeft,$i,100,20) $i += 25 Next EndFunc Func _FONTSTYLING($FONTCONTROL, $FONTSTYLINGSIZE = "", $FONTSTYLINGWEIGHT = "", $FONTSTYLINGCOLOR = "", $FONTATTRIBUTE = "") GUICtrlSetColor($FONTCONTROL, $FONTSTYLINGCOLOR) GUICtrlSetFont($FONTCONTROL, $FONTSTYLINGSIZE, $FONTSTYLINGWEIGHT, $FONTATTRIBUTE) EndFunc ;==>_FONTSTYLING Func _Stock_GetInfo($Symbol) ;[url="http://download.finance.yahoo.com/d/quotes.csv?s=GOOG&f=sl1c1p2n&e=.csv"]http://download.finance.yahoo.com/d/quotes.csv?s=GOOG&f=sl1c1p2n&e=.csv[/url] ;StrSymbol,FloatLastValue,FloatLastChange,StrPercentChange,StrCompany Local $qf=@TempDir&'\yahoo_stockinfo.csv' InetGet('[url="http://download.finance.yahoo.com/d/quotes.csv?s="]http://download.finance.yahoo.com/d/quotes.csv?s=[/url]'&StringUpper($Symbol)&'&f=sl1c1p2n&e=.csv',$qf,1,1) $iMove=0 While @InetGetActive GUI_DrawTicker('Loading '&$Symbol&'... Please Wait.') Sleep(25) $iMove+=1 WEnd Local $StockInfo=StringSplit(StringReplace(StringStripCR(FileRead($qf)),@LF,'')&',',',') ;_ArrayDisplay($StockInfo) ;_ArrayDisplay($TickerEntries) ;ConsoleWrite("! " & $StockInfo[5] & @CRLF) If $SetList = True Then #cs If $StockInfo[3] = "N/A" Then ;_ArrayDisplay($StockInfo) $StockREAD = RegRead($REGLOCATION, "MyStocks") $TickerEntries = StringSplit($StockREAD, @LF) _ArrayDelete($TickerEntries, 0) $tt = _ArraySearch($TickerEntries, StringReplace($StockInfo[1],'"',"")) ConsoleWrite("+ " & $tt & " -- " & $StockInfo[1] &@CRLF) _ArrayDelete($TickerEntries, Number($tt)) ;_ArrayDisplay($TickerEntries) RegWrite($REGLOCATION, "MyStocks","REG_MULTI_SZ",_ArrayToString($TickerEntries, @LF)) Return EndIf #ce _GUICtrlListView_AddItem($List, $StockInfo[5]) $rr = Number(_GUICtrlListView_GetItemCount($List)) _GUICtrlListView_AddSubItem($List, $rr-1, $TickerEntries[$rr], 1) EndIf Local $StockInfo_Max=UBound($StockInfo)-1 For $i=1 To $StockInfo_Max If StringMid($StockInfo[$i],1,1)=='"' And StringMid($StockInfo[$i],StringLen($StockInfo[$i]),1)=='"' Then $StockInfo[$i]=StringTrimRight(StringTrimLeft($StockInfo[$i],1),1) EndIf Next ;If $StockInfo[3] <> "N/A" Then Return $StockInfo Return $StockInfo EndFunc Func _ArrayAdd2D($d1, $d2) ReDim $NAStock[UBound($NAStock) + 1][UBound($NAStock, 2)] $NAStock[UBound($NAStock) - 2][0] = $d1 $NAStock[UBound($NAStock) - 2][1] = $d2 EndFunc ;==>_MyAddrayAdd Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) GUI_TickerSize() Return $GUI_RUNDEFMSG EndFunc Func MY_WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam); ty Zedna;) $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int",$lParam) DllStructSetData($minmaxinfo,7,$GUI_InitSize[2]); min X DllStructSetData($minmaxinfo,8,$GUI_InitSize[3]-43); min Y - this should leave just 21px for the stock ticker (visual styles may break this x_x ) ;DllStructSetData($minmaxinfo,9,500); max X DllStructSetData($minmaxinfo,10,$GUI_InitSize[3]); max Y Return 0 EndFunc ; Draw PNG image Func WM_PAINT($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($GUI_StockChart, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) ; _GDIPlus_GraphicsDrawImage($hGraphic, $hImage2, 100, 100) _WinAPI_RedrawWindow($GUI_StockChart, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc Func _MYERRFUNC() $HEXNUMBER = Hex($OIEERRORHANDLER.number, 8) MsgBox(0, "COM Error", "INM intercepted a COM Error !" & @CRLF & @CRLF & "err.description is: " & @TAB & $OIEERRORHANDLER.description & @CRLF & "err.windescription:" & @TAB & $OIEERRORHANDLER.windescription & @CRLF & "err.number is: " & @TAB & $HEXNUMBER & @CRLF & "err.lastdllerror is: " & @TAB & $OIEERRORHANDLER.lastdllerror & @CRLF & "err.linecode is: " & @TAB & $OIEERRORHANDLER.scriptline) SetError(1) EndFunc ;==>_MYERRFUNC Link to comment Share on other sites More sharing options...
Champak Posted September 7, 2009 Author Share Posted September 7, 2009 bump Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 7, 2009 Share Posted September 7, 2009 (edited) TL-DNR Can't you reduce that to just a short reproducer that shows your issue? Edited September 7, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Champak Posted September 7, 2009 Author Share Posted September 7, 2009 OK, this is the bare minimum I believe. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> Global $GUI_DOCKHORZ=$GUI_DOCKLEFT+$GUI_DOCKRIGHT Global $GUI_DOCKMARQUEE=$GUI_DOCKHORZ+$GUI_DOCKHEIGHT Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Stock Ticker", 200, 100, -1,-1,$WS_CAPTION + $WS_SIZEBOX + $WS_SYSMENU) GUISetOnEvent($GUI_EVENT_CLOSE,'GUI_Close') $Label1 = GUICtrlCreateLabel(" Loading Ticker... Please wait.", 0, 0, 180, 21, -1, $WS_EX_STATICEDGE) GUICtrlSetResizing(-1,$GUI_DOCKMARQUEE+$GUI_DOCKTOP) GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetBkColor(-1, 0x000000) $Input2 = GUICtrlCreateInput("GOOG,MSFT,ibm,x,f,siri,cvc,g,r", 1, 42, 110, 21) GUICtrlSetResizing(-1,$GUI_DOCKLEFT+$GUI_DOCKSIZE+$GUI_DOCKTOP) Global $TickerEntries,$TickerTimer, $TickerText GUI_SetTicker() _GDIPlus_Startup() Global $hCtrl=ControlGetHandle($Form1,'',$Label1) Global $gro Global $grb Global $gr Global $hFamily = _GDIPlus_FontFamilyCreate ("Arial") Global $hFont = _GDIPlus_FontCreate ($hFamily, 10, 2) Global $tLayout Global $hFormat = _GDIPlus_StringFormatCreate () Global $hBrush=_GDIPlus_BrushCreateSolid(0xFF00FF00) Global $iMove=0 Global $gr_dim[4]=[0,0,0,0] GUISetState(@SW_SHOW) GUI_TickerSize() GUIRegisterMsg($WM_SIZE, "WM_SIZE") While 1 If IsArray($TickerEntries) Then If TimerDiff($TickerTimer)>60000 Then $TickerText='' For $i=1 To UBound($TickerEntries)-1 If StringLen($TickerEntries[$i])<1 Then ContinueLoop Local $StockInfo=_Stock_GetInfo($TickerEntries[$i]) If IsArray($StockInfo) Then $TickerText&=$StockInfo[1]&' '&$StockInfo[3]&' ('&$StockInfo[4]&') - ' EndIf Next $TickerTimer=TimerInit() Else GUI_DrawTicker($TickerText) Sleep(25) $iMove+=1 EndIf Else Sleep(300) EndIf WEnd Func GUI_SetTicker() Global $TickerEntries, $TickerTimer, $TickerText $TickerTimer=0 $TickerEntries='' $TickerText='' $TickerEntries=StringSplit(GUICtrlRead($Input2)&',',',') EndFunc Func GUI_Close() If @InetGetActive Then InetGet('abort') $TickerTimer=0 $TickerEntries='' $TickerText='' $tLayout=0 If $hFamily Then _GDIPlus_FontFamilyDispose($hFamily) If $hFont Then _GDIPlus_FontDispose($hFont) If $hFormat Then _GDIPlus_StringFormatDispose($hFormat) If $hBrush Then _GDIPlus_BrushDispose($hBrush) If $gr Then _GDIPlus_GraphicsDispose($gr) If $grb Then _GDIPlus_BitmapDispose($grb) If $gro Then _GDIPlus_GraphicsDispose($gro) GUISetState(@SW_HIDE) GUIDelete($Form1) Exit EndFunc Func GUI_TickerSize() Global $gro, $grb, $gr_dim $gr_dim=ControlGetPos($Form1,'',$Label1) ConsoleWrite('TickerResize '&$gr_dim[2]&@CRLF) Local $cgp=$gr_dim If $gro Then _GDIPlus_GraphicsDispose($gro) $gro=_GDIPlus_GraphicsCreateFromHWND($hCtrl) If $gr Then _GDIPlus_GraphicsDispose($gr) If $grb Then _GDIPlus_BitmapDispose($grb) $grb=_GDIPlus_BitmapCreateFromGraphics($cgp[2],$cgp[3],$gro); I'd only make one - but the darn thing has to resize! $gr=_GDIPlus_ImageGetGraphicsContext($grb) EndFunc Func GUI_DrawTicker($str) Global $gr_dim,$iMove Local $cgp=$gr_dim If $iMove>$cgp[2] Then ConsoleWrite('TickerBack '&$iMove&'>'&$cgp[2]&@CRLF) $iMove=0 EndIf _GDIPlus_GraphicsClear($gr,0xFF000000) $tLayout = 0 $tLayout = _GDIPlus_RectFCreate ($iMove,0, $cgp[2], $cgp[3]) _GDIPlus_GraphicsDrawStringEx ($gr, $str, $hFont, $tLayout, $hFormat, $hBrush) $tLayout = 0 $tLayout = _GDIPlus_RectFCreate ($iMove-$cgp[2],0, $cgp[2], $cgp[3]) _GDIPlus_GraphicsDrawStringEx ($gr, $str, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_GraphicsDrawImageRect($gro, $grb, 0, 0, $cgp[2], $cgp[3]);copy to bitmap EndFunc Func _Stock_GetInfo($Symbol) Local $qf=@TempDir&'\yahoo_stockinfo.csv' InetGet('http://download.finance.yahoo.com/d/quotes.csv?s='&StringUpper($Symbol)&'&f=sl1c1p2n&e=.csv',$qf,1,1) $iMove=0 While @InetGetActive GUI_DrawTicker('Loading '&$Symbol&'... Please Wait.') Sleep(25) $iMove+=1 WEnd Local $StockInfo=StringSplit(StringReplace(StringStripCR(FileRead($qf)),@LF,'')&',',',') Local $StockInfo_Max=UBound($StockInfo)-1 For $i=1 To $StockInfo_Max If StringMid($StockInfo[$i],1,1)=='"' And StringMid($StockInfo[$i],StringLen($StockInfo[$i]),1)=='"' Then $StockInfo[$i]=StringTrimRight(StringTrimLeft($StockInfo[$i],1),1) EndIf Next Return $StockInfo EndFunc Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) GUI_TickerSize() Return $GUI_RUNDEFMSG EndFunc Link to comment Share on other sites More sharing options...
Champak Posted October 26, 2009 Author Share Posted October 26, 2009 Bump Link to comment Share on other sites More sharing options...
martin Posted October 26, 2009 Share Posted October 26, 2009 BumpDon't you just needGlobal $hFormat = _GDIPlus_StringFormatCreate (0x1000)instead of Global $hFormat = _GDIPlus_StringFormatCreate ()? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Champak Posted October 30, 2009 Author Share Posted October 30, 2009 I actually tried that before, the problem is, say you have 50 different stocks (how many ever), but you have the ticker stretched just wide enough to fit two stocks side by side, only those two stocks will continue to scroll by. Yes you eliminate the wrapping, but you also eliminate all of the other stocks --- that may not have been caught in the wrapping --- from scrolling by. As you stretch the ticker to fit three stocks, those stocks will start scrolling as well, and so on. So basically you have to have the ticker stretched wide enough to fit ALL the stocks on it side by side for all the stocks to continuously scroll across the ticker. I would like it so that if you only have the ticker wide enough to fit two or three (how many ever), it will still scroll the entire list of stocks that may be listed. Link to comment Share on other sites More sharing options...
martin Posted October 31, 2009 Share Posted October 31, 2009 I actually tried that before, the problem is, say you have 50 different stocks (how many ever), but you have the ticker stretched just wide enough to fit two stocks side by side, only those two stocks will continue to scroll by. Yes you eliminate the wrapping, but you also eliminate all of the other stocks --- that may not have been caught in the wrapping --- from scrolling by. As you stretch the ticker to fit three stocks, those stocks will start scrolling as well, and so on. So basically you have to have the ticker stretched wide enough to fit ALL the stocks on it side by side for all the stocks to continuously scroll across the ticker. I would like it so that if you only have the ticker wide enough to fit two or three (how many ever), it will still scroll the entire list of stocks that may be listed.Maybe you could do it this way.Have an array of all the items you want to have displayed, and the information in the same array say of the length of each string. ( _WInAPI_GetTextExtent32 ?)I'll cal the items A,B,C etcDraw B, A and scroll right. At first only A is seen then B comes into view and eventually A is out of view. We know when that will happen because we have the length of the text for A. So now start the scroll again but now draw C,B positioned so that B appears not to have jumped and so on. So the text willl continually scroll but there is only ever 2 items drawn. Do you think that would work? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Champak Posted November 9, 2009 Author Share Posted November 9, 2009 I'm going to have to sit down with that for a minute because I can't conceptualize/visualize it right now on how to do it. Link to comment Share on other sites More sharing options...
dickep Posted October 4, 2010 Share Posted October 4, 2010 I know this is an old thread, but did anyone ever figure out the reason that the ticker would not let you display as many items as you want? I seem to have the limit at 4, but that is not always exact. I have been playing with GDI+ and ran across this and thought to ask. E Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now