myspacee Posted January 31, 2012 Share Posted January 31, 2012 Hello to all,i've an IP cam with bad bad html interface.But found that is possibile to take actual image on its http internal web server(eg: http://10.119.1.246/enu/camera320x240.jpg)So i think to build a GUI that, download image (InetGet) every n seconds and refresh image.but i don't know where to start, anyone can give me some hint?thank you,m. Link to comment Share on other sites More sharing options...
JohnQSmith Posted January 31, 2012 Share Posted January 31, 2012 (edited) The help file is your friend. $n = 30 While 1 InetGet("http://10.119.1.246/enu/camera320x240.jpg", "C:images" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & ".JPG", 1) Sleep($n * 1000) ; every n = 30 seconds Wend Edit: Forgot that it's '$n', not just 'n' inside the sleep. Edited January 31, 2012 by JohnQSmith Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Link to comment Share on other sites More sharing options...
myspacee Posted January 31, 2012 Author Share Posted January 31, 2012 JohnQ, maybe request is malformed, but i need a GUI that, after download .jpg, show updated image. m. Link to comment Share on other sites More sharing options...
JohnQSmith Posted January 31, 2012 Share Posted January 31, 2012 No, I understood your question, I was just replying to the part of your message that said...So i think to build a GUI that, download image (InetGet) every n seconds and refresh image.but i don't know where to start, anyone can give me some hint?So I was giving you a place to start. Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Link to comment Share on other sites More sharing options...
myspacee Posted January 31, 2012 Author Share Posted January 31, 2012 (edited) so you can correct this for me? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $gui, $background, $pic, $basti_stay, $msg Local $sFile = @ScriptDir & "" & "camera320x240.jpg" $gui = GUICreate("Background", 320, 240) ; background picture $background = GUICtrlCreatePic(@ScriptDir & "" & "camera320x240.jpg", 0, 0, 320, 240) GUISetState(@SW_SHOW) ; transparent MDI child window $pic = GUICreate("", 320, 240, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui) ; transparent pic $basti_stay = GUICtrlCreatePic($sFile, 0, 0, 320, 240) GUISetState(@SW_SHOW) Do $msg = GUIGetMsg() sleep(1000) InetGet("http://10.119.1.246/enu/camera320x240.jpg",$sFile) Until $msg = $GUI_EVENT_CLOSEI can't unload current loaded image and show newer....maybe i can use GUICtrlSetImage ?m. Edited January 31, 2012 by myspacee Link to comment Share on other sites More sharing options...
JohnQSmith Posted January 31, 2012 Share Posted January 31, 2012 Outstanding attempt! I told you the help files were your friend. I just glanced over your code and you're headed in the right direction. Here's what I threw together using examples in the documentation from GUICreate, GUICtrlCreatePic, and GUICtrlSetImage. See if you can massage it into what you want. #include <GUIConstantsEx.au3> Example() Func Example() Local $msg, $pic, $timer $delay = 30 InetGet("http://10.119.1.246/enu/camera320x240.jpg", "c:tempimage.jpg", 1) GUICreate("My GUI", 320, 240) ; will create a dialog box that when displayed is centered $pic = GUICtrlCreatePic("c:tempimage.jpg", 0, 0, 0, 0) ; Run the GUI until the dialog is closed $timer = TimerInit() While 1 $msg = GUIGetMsg() GUICtrlSetImage($pic, "c:tempimage.jpg") GUISetState() Sleep(100) If TimerDiff($timer) > ($delay * 1000) Then InetGet("http://10.119.1.246/enu/camera320x240.jpg", "c:tempimage.jpg", 1) $timer = TimerInit() EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>Example Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Link to comment Share on other sites More sharing options...
myspacee Posted February 1, 2012 Author Share Posted February 1, 2012 hello again, modify http link to allow test, modify JohnQ example that hang, and post this: #include <GUIConstantsEx.au3> Example() Func Example() Local $msg, $pic InetGet("http://193.109.35.195/jpg/Aosta.jpg", "image.jpg", 1) GUICreate("My GUI", 640, 480) ; will create a dialog box that when displayed is centered $pic = GUICtrlCreatePic("image.jpg", 0, 0, 0, 0) GUICtrlSetImage($pic, "image.jpg") GUISetState() ; Run the GUI until the dialog is closed ;$timer = TimerInit() While 1 $msg = GUIGetMsg() GUICtrlSetImage($pic, "image.jpg") GUISetState() InetGet("http://193.109.35.195/jpg/Aosta.jpg", "image.jpg", 1) Sleep(2000) If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>Example now it works but GUI is very heavy, anyway to solve this issue ? (JohnQ thank you, finish now to drink a thing with help file, nice guy) Link to comment Share on other sites More sharing options...
Mikeman27294 Posted February 1, 2012 Share Posted February 1, 2012 (edited) Here's another idea for you, as far as updating it each second by placing the code in a while loop, try this: ;createGUI blah blah blah AdlibRegister('_UpdateImage', 1000) ;While loop here Func _UpdateImage() InetGet("http://193.109.35.195/jpg/Aosta.jpg", "image.jpg", 1) GUICtrlSetImage($pic, "image.jpg") EndFunc The function AdlibRegister sets the program to run the function set in the first parameter, every amount of milliseconds set in the second parameter (in this case, 1000 milliseconds = 1 second). So, I have just optimized the script a little, here it is: #include <GUIConstantsEx.au3> Local $msg, $pic GUICreate("My GUI", 640, 480) ; will create a dialog box that when displayed is centered $pic = GUICtrlCreatePic(@TempDir&"image.jpg", 0, 0, 640, 480) GUISetState() AdlibRegister('_UpdateImage', 1000) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Sleep(10) WEnd Func _UpdateImage() InetGet("http://193.109.35.195/jpg/Aosta.jpg", @TempDir&"image.jpg", 0) GUICtrlSetImage($pic, @TempDir&"image.jpg") Return EndFunc Edited February 1, 2012 by Mikeman27294 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