johnmcloud Posted February 17, 2012 Posted February 17, 2012 (edited) Hi guys, i have a little problem with a $var of this script, i don't know how to make it:expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <String.au3> #include <File.au3> Global $image $GUI = GUICreate("Test GUI", 466, 360, -1, -1) $InfoButton = GUICtrlCreateButton("Info", 14, 312, 123, 25) $WebPic = GUICtrlCreatePic(_GetURLImage('"' & $image & '"'), 16, 216, 120, 90) If @error = 1 Then $GroupPic = GUICtrlCreateGroup("", 15, 210, 120, 100) EndIf GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $InfoButton Read_Info() EndSwitch WEnd Func Read_Info() Dim $logfile = @WorkingDir & "\test.txt" If FileGetSize($logfile) <> 0 Then Global $image = FileReadLine($logfile, 2) MsgBox(0,0, FileReadLine($logfile, 2)) EndIf EndFunc ;==>Read_Info Func _GetURLImage($sURL, $sDirectory = @TempDir) Local $hDownload, $sFile $sFile = StringRegExpReplace($sURL, "^.*/", "") If @error Then Return SetError(1, 0, $sFile) EndIf If StringRight($sDirectory, 1) <> "\" Then $sDirectory = $sDirectory & "\" EndIf $sDirectory = $sDirectory & $sFile If FileExists($sDirectory) Then Return $sDirectory EndIf $hDownload = InetGet($sURL, $sDirectory, 17, 1) While InetGetInfo($hDownload, 2) = 0 If InetGetInfo($hDownload, 4) <> 0 Then InetClose($hDownload) Return SetError(1, 0, $sDirectory) EndIf Sleep(105) WEnd InetClose($hDownload) Return $sDirectory EndFunc ;==>_GetURLImageThe Test.txtblabla dizziness-and-balance.com/images/eye-chart.jpg blablaI have removed the http://www. on the forum, but on the file the link is fullOn MsgBox or ConsoleWrite i see the full link ( the link posted change everytime, so i can't make a direct link to the image on PC ) but the image is not loaded on GUI.What is the problem?Thanks for support Edited February 17, 2012 by johnmcloud
AlmarM Posted February 17, 2012 Posted February 17, 2012 I think it's because you are trying to load an image from the web.Try download it first using the INet functions and save it somewhere local. Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
johnmcloud Posted February 17, 2012 Author Posted February 17, 2012 (edited) Thanks AlmarM, but i don't think is the problem, because _GetUrlImage() download the image on PC and give me the directory position, in @Tempdir & "nameofthefile.jpeg" Edited February 17, 2012 by johnmcloud
AlmarM Posted February 17, 2012 Posted February 17, 2012 Thanks AlmarM, but i don't think is the problem, because _GetUrlImage() download the image on PC and give me the directory position, in @Tempdir & "\nameofthefile.jpeg" Ah, I oversaw that. Whats the reason you are adding a " twice in the _GetURLImage? $WebPic = GUICtrlCreatePic(_GetURLImage('"' & $image & '"'), 16, 216, 120, 90) Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
johnmcloud Posted February 17, 2012 Author Posted February 17, 2012 Because i can't make it without GetImageUrl("http://qwerty") - work GetImageUrl(http://qwerty) - not work My problem is set the $var, with link work, with the variable not, but the consolewrite give me the right url. Try it.
AlmarM Posted February 17, 2012 Posted February 17, 2012 Because i can't make it without GetImageUrl("http://qwerty") - work GetImageUrl(http://qwerty) - not work My problem is set the $var, with link work, with the variable not, but the consolewrite give me the right url. Try it. First of all, remove those 2 ". It's no use since you are using a variable. Second, the link inside the text.txt is correct, but the link provided by the _GetURLImage returns only @TempDir. Therefore the image will not show because the _GetURLImage doesn't return the filename + extension. MsgBox(0, "", _GetURLImage($image)) Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
UEZ Posted February 17, 2012 Posted February 17, 2012 Try this: Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
johnmcloud Posted February 17, 2012 Author Posted February 17, 2012 (edited) Guys, maybe i'm not so clear, my problem is not with the script, the script work file, take a look: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <String.au3> #include <File.au3> $GUI = GUICreate("Test GUI", 466, 360, -1, -1) $InfoButton = GUICtrlCreateButton("Info", 14, 312, 123, 25) $WebPic = GUICtrlCreatePic(_GetURLImage("http://www.autoitscript.com/forum/uploads/profile/photo-thumb-29844.jpg"), 16, 216, 120, 90) If @error = 1 Then $GroupPic = GUICtrlCreateGroup("", 15, 210, 120, 100) EndIf GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _GetURLImage($sURL, $sDirectory = @TempDir) Local $hDownload, $sFile $sFile = StringRegExpReplace($sURL, "^.*/", "") If @error Then Return SetError(1, 0, $sFile) EndIf If StringRight($sDirectory, 1) <> "" Then $sDirectory = $sDirectory & "" EndIf $sDirectory = $sDirectory & $sFile If FileExists($sDirectory) Then Return $sDirectory EndIf $hDownload = InetGet($sURL, $sDirectory, 17, 1) While InetGetInfo($hDownload, 2) = 0 If InetGetInfo($hDownload, 4) <> 0 Then InetClose($hDownload) Return SetError(1, 0, $sDirectory) EndIf Sleep(105) WEnd InetClose($hDownload) Return $sDirectory EndFunc ;==>_GetURLImage Oh, @AlmarM, The func _GetURLImage give me the full directory + extension: ConsoleWrite(_GetURLImage("http://www.autoitscript.com/forum/uploads/profile/photo-thumb-29844.jpg") Result is: C:DOCUME~1WINDOW~1IMPOST~1Tempphoto-thumb-29844.jpg For the "" you have right, it's useless but the result is the same. I'll remove them Resume, i want to do this: 1) Open the script, no image ( i have did it with if @error = 1 ) 2) Click on info button --> _GetURLImage --> load image into GUI So my problem is i don't know how to do the 2), i need help for this. Thanks to all Edited February 17, 2012 by johnmcloud
johnmcloud Posted February 17, 2012 Author Posted February 17, 2012 (edited) Maybe i have resolved by myself with this: $var = _GetURLImage("http://www.autoitscript.com/forum/uploads/profile/photo-thumb-29844.jpg") GUICtrlSetImage($WebPic, $var) I'll test it and post the result later EDIT: Yes, work Thanks anyway to UEZ and AlmarM Edited February 17, 2012 by johnmcloud
passimage Posted July 23, 2013 Posted July 23, 2013 here are some codes on how to load image from url vb.net. Imports System.IOImports System.Drawing.PrintingImports RasterEdge.ImagingImports RasterEdge.Imaging.ProcessingDim Image As New RasterEdgeImaging() Image.GetImageFromURL("http://www.rasteredge.com/1.jpg")If _Image IsNot Nothing Then pictureBox1.Image = _Image Image.Save("C:1.jpg")End If
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