Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Problem getting a script to repeat itself

$
0
0

Hey Guys,

 

Haven't posted for awhile, but I ran into a new problem today while I was trying to make this script.

 

So I have a networked temperature monitor in my server room and I'm trying to download the graph that it creates and have it show up in a small GUI window. Now I've gotten it to download and display just fine, the issue happens when I try to get it to re-download the image, update the GUI and then do it again.

 

Here's what I have so far:

AutoIt         
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> ;Pre-Defined Variables $hWGoose = "http://xx.xx.xx.xxx/graph?width=500&height=200&time=900&refresh=0&dev=011BBCAB14000019&sen=1&sen=2&dev=2D0000008DFBC812&sen=1&sen=3" ;-------------------------------------------------------------------------------------------- Local $hDownload = InetGet($hWGoose, @TempDir & "\test.png", 1, 1) Do     Sleep(100) Until InetGetInfo($hDownload, 2) ;Check if the download is complete InetClose($hDownload) ;Close the handle to release resources ;-------------------------------------------------------------------------------------------- Global $hGUI, $hImage, $hGraphic ;Create GUI $hGUI = GUICreate("DFW WeatherGoose", 400, 200) GUISetState() ;Load PNG image _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\test.png") ;Draw PNG image $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) ;Loop until user exits Do    Local $hDownload = InetGet($hWGoose, @TempDir & "\test.png", 1, 1)    Do     Sleep(100)    Until ((InetGetInfo($hDownload, 2)) Or (GUIGetMsg() = $GUI_EVENT_CLOSE)) ;Check if download is complete or exit GUI    Local $nBytes = InetGetInfo($hDownload, 0)    InetClose($hDownload) ;Close the handle to release resources        _GDIPlus_Startup()    $hImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\test.png")    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) Until GUIGetMsg() = $GUI_EVENT_CLOSE ;Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown()

The problem seems to be under the Do, I've got this section and when I comment it out it works fine, just no looping like I want:

;Loop until user exits Do   ; Local $hDownload = InetGet($hWGoose, @TempDir & "\test.png", 1, 1)    ;Do     ;Sleep(100)    ;Until ((InetGetInfo($hDownload, 2)) Or (GUIGetMsg() = $GUI_EVENT_CLOSE)) ;Check if download is complete or exit GUI    ;Local $nBytes = InetGetInfo($hDownload, 0)    ;InetClose($hDownload) ;Close the handle to release resources        _GDIPlus_Startup()    $hImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\test.png")    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) Until GUIGetMsg() = $GUI_EVENT_CLOSE

Ideally I want it to re-download the image and refresh the PNG every 60 seconds, but this is the only way I could think of looping the script. =\

 

Any hints?


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>