Hello, I'm not much good in this, but I made some little script for checking Online Gold Price, and reading value number from image. But, I want hide image and get just number, without showing image. How? Thank you. ![:)]()
script example:
EDIT: Or just what function can I use for getting color from custom pixel of some loaded image?
![:)](http://aut1.autoit-cdn.com/forum/public/style_emoticons/default/smile.png)
script example:
;----- example 3 PNG work araund by Zedna #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <StaticConstants.au3> Opt("PixelCoordMode", 2) Global $link = "http://goldprice.org/NewCharts/gold/images/gold_1d_k_EUR.png" Global $saveto = @TempDir & "\goldprice.png" Global $hGUI, $hImage, $hGraphic Global $ImageX = 20, $ImageY = 53 #NoTrayIcon ; Create GUI $hGUI = GUICreate("Gold Price Live!", 220, 263) GUICtrlCreateLabel("Gold Price Live!", 0, 0, 220, 30, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFFFFFF) $Pic1 = GUICtrlCreatePic("", 0, 30, 253, 2, -1, $WS_EX_STATICEDGE) GUICtrlCreateGroup("", 8, 36, 204, 189) $Pic1 = GUICtrlCreatePic("", 19, 52, 182, 116, BitOR($GUI_SS_DEFAULT_PIC,$WS_BORDER)) $label = GUICtrlCreateLabel("Gold Price: " &@CRLF& "Change: ", 20, 174, 180, 48) $button = GUICtrlCreateButton("Update", 58, 233, 75, 23) $button1 = GUICtrlCreateButton("Izlaz", 139, 233, 75, 23) ; Load PNG image _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($saveto) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") GUISetState() GUICtrlSetData($label, "Gold Price: " & _CitanjeBrojeva($ImageX+50, $ImageY+4) &@CRLF& "Change: " & _CitanjeBrojeva($ImageX+130, $ImageY+4)) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $button1 Exit Case $button _UpdateGoldPrice() EndSwitch WEnd ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() ; Draw PNG image Func MY_WM_PAINT($hWnd, $msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam, $lParam _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, $ImageX, $ImageY) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_PAINT Func _CitanjeBrojeva($x, $y, $x1 = 80) Local $text, $broj, $proba, $1 For $a = 0 To $x1 $broj = _GetRow($x+$a, $y) $proba = _GetRow($x+$a+4, $y) $proba1 = _GetRow($x+$a-1, $y) If $proba1 = "00000000" Then Switch $broj Case "01111110";0 If $proba = "01111110" Then $text &= 0 Case "01000001";1 If $proba = "00000001" Then $text &= 1 Case "01000011";2 If $proba = "01100001" Then $text &= 2 Case "01000010";3 If $proba = "01101110" Then $text &= 3 Case "00001100";4 If $proba = "11111111" Then $text &= 4 Case "11110010";5 If $proba = "10001110" Then $text &= 5 Case "00111110";6 If $proba = "00001110" Then $text &= 6 Case "10000000";7 If $proba = "11000000" Then $text &= 7 Case "01101110";8 If $proba = "01101110" Then $text &= 8 Case "01110000";9 If $proba = "01111100" Then $text &= 9 Case "00000011";dot If _GetRow($x+$a+1, $y) = "00000000" Then $text &= "." Case "00000010";UP If $proba = "00111110" Then GUICtrlSetColor($label, 0x008000) Case "00100000";DOWN If $proba = "00111110" Then GUICtrlSetColor($label, 0xFF0000) EndSwitch EndIf $broj = "" Next Return $text EndFunc Func _GetRow($x, $y = 0) Local $1, $2 For $a = 0 To 7 $2 = PixelGetColor($x, $y+$a, $hGUI) $color1 = Hex($2, 6) If $color1 = "FFFFFF" Then $1 &= "0" Else $1 &= "1" EndIf Next Return $1 EndFunc Func _UpdateGoldPrice() Local $hDownload, $nBytes GUICtrlSetState($button, $GUI_DISABLE) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) $hDownload = InetGet($link, $saveto, 1, 1) Do Sleep(250) Until InetGetInfo($hDownload, 2) ; Check if the download is complete. $nBytes = InetGetInfo($hDownload, 0) InetClose($hDownload) ; Close the handle to release resources. If $nBytes <> 0 Then $hImage = _GDIPlus_ImageLoadFromFile($saveto) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, $ImageX, $ImageY) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) GUICtrlSetData($label, "Gold Price: " & _CitanjeBrojeva($ImageX+50, $ImageY+4) &@CRLF& "Change: " & _CitanjeBrojeva($ImageX+130, $ImageY+4) &@CRLF& "Updated: " & @HOUR &":"& @MIN) Else MsgBox(0,$nBytes, "Error") EndIf GUICtrlSetState($button, $GUI_ENABLE) EndFunc
EDIT: Or just what function can I use for getting color from custom pixel of some loaded image?