Jump to content

Update GUI while Func is running


 Share

Recommended Posts

I have a GUI that will have status indicators (like red/yellow/green LEDs) that I would like to be flashing while something is occurring in the background after the user clicks a button.

Using the GUICtrlSetOnEvent() function, when a user clicks the "GO" button, I would like the program to have the indicator flash while the program is pinging, or resolving, or doing the 'behind the scenes' actions, and upon finishing it will change it to the SUCCESS/FAIL colors appropriately, but I would like something informing them that something IS working and how it's going.

I can have the indicator change after the func has returned, but can't figure out a way to set it up during the func is running. (I always get stuck in doube-loops), I've even tried Adlib functions, but not effective. What is the best way to do it?

Thanks for your time and help.

Van

Link to comment
Share on other sites

Without seeing any code, I'd just have to suggest that the function you call needs a while loop with code in it to continually update your indicators. If you already have a while loop, then just put that bit of code into the while loop.

Maybe even have a seperate function specifically created for updating your indicators.

Link to comment
Share on other sites

...or stick an animated GIF on your window. That will move without your code having to do anything.

<{POST_SNAPBACK}>

Really?

I didn't think the animated GIFs were supported.

I'll try this, thanks.

Thank you to everyone that provided input.

I tried the while loops in the past, but it kept geting stuck (having 2 or more in different functions -and Au3 isn't a multi-threaded program, so it kept crashing the program.

The separate EXE, however, is not an option as it is intended to all be self-contained to share variables, handles for controls, etc....

Van

Link to comment
Share on other sites

...or stick an animated GIF on your window. That will move without your code having to do anything.

<{POST_SNAPBACK}>

I tried the animated GIF but it does not animate at all.

transparency works great ( too well, as any color in the window having that the same color and the GIFs transparent code, is transparent).

Download the accompanying animated GIF and place in the same folder, then run the script.

; Download the accompanying animated GIF and place in the same folder.
#include <GUIConstants.au3>
GUICreate("My GUI picture",350,300,-1,-1,$WS_SIZEBOX+$WS_SYSMENU, $WS_EX_LAYERED )
$n=GUICtrlCreatePic( "Light_Green_Blink.gif",25,25, 25,25  )
GUISetState ()

While 1     ;   Run the GUI until the dialog is closed
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Wend

Van

Link to comment
Share on other sites

Can you explain how the Adlib functions were of no use to you ??

Cheers

<{POST_SNAPBACK}>

Well, I want the indicator/picture to blink, right?

using the adlib, causing the script to run every X milliseconds.

I think that's unneeded overhead, not to mention if I have multiple things happening in the background, enabling adlib #2, overrides the adlib #1. enabling adlib #3 overrides #1 and #2.

(It'll work -but limited functionality and cumbersome)

Van

Link to comment
Share on other sites

I have never tried using an animated GIF before, so I apologize for the bad info. Have you tried using GUICtrlCreateAvi() instead? I am sure that should at least animate. You could even convert your animated GIF into an AVI with the proper converter.

Just trying to make this simple...

Edit: I tried to upload an AVI converted from your animated GIF but this forum does not allow AVI extension to be uploaded.

Edited by SerialKiller
Link to comment
Share on other sites

Dont forget to load 1.bmp and 2.bmp!

#include <GUIConstants.au3>
GUICreate("My GUI picture",350,300,-1,-1,$WS_SIZEBOX+$WS_SYSMENU, $WS_EX_LAYERED )
$n=GUICtrlCreatePic( "1.bmp",25,25, 25,25  )
$Go = GuiCtrlCreateButton("Go", 140, 25, 50, 25)
GUISetState ()

While 1    ;    Run the GUI until the dialog is closed
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
If $msg = $Go then
AdlibEnable ( "Blink" ,200 )
sleep(5000)
;Do things
AdlibDisable ( )
GUICtrlSetImage ( $n, "1.bmp" )
EndIf
    Wend
    
Func Blink ()
GUICtrlSetImage ( $n, "2.bmp" )
sleep(100)
GUICtrlSetImage ( $n, "1.bmp" )
sleep(100)
EndFunc

1.bmp

2.bmp

Edited by Westi
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...