Jump to content

First GUI app - Few questions


Recommended Posts

Hi everyone!

This my first GUI app using au3 so any help is appreciated! I just have 3 questions...

1. If you execute a button which contains an endless loop, is there a way to break the cycle so you can pause or exit?

2. How can you add text to a listbox so each new entry goes on a new line and if it exceeds the width of the listbox then it goes to a new line?

3. How do I go about enabling a vertical scroll bar?

Below is sum sample code of my endless loop problem, I want to be able to break the cycle when another button is clicked(if this is possible).

Regards

- Alex

#include <GUIConstants.au3>
#include <Array.au3>
GUICreate("+1", 400, 300)
GUISetState(@SW_SHOW)
$btn_Run = GUICtrlCreateButton("Run", 10, 10, 100, 25)
$btn_Pause = GUICtrlCreateButton("Pause", 10, 45, 100, 25)
$btn_Exit = GUICtrlCreateButton("Exit", 10, 80, 100, 25)
$lst_Status = GUICtrlCreateList("", 125, 10, 200, 250)
Global $Pause

While 1
    $msg = GUIGetMsg()
    Select      
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $btn_Exit
            Exit            
        Case $msg = $btn_Pause
            $Paused = NOT $Paused
            While $Paused
                sleep(100)
                ToolTip('Script is "Paused"',0,0)
            WEnd
            ToolTip("")
        Case $msg = $btn_Run
            While 1; endless loop
            ; do some code
            WEnd
    EndSelect
WEnd
Link to comment
Share on other sites

Q1- Yes it is possible to break a loop externally. 1 method would be to have a varible, and set it to true/false depending on what you want done in the loop. If you add if $var = true then ExitLoop into your loop, it will exit the loop if $var is true. Also, if you don't already use AdLib in your GUI, you can just use an adlib loop, which would be easy.

Q2- Well a simple function could do that.

Q3- Look in the helpfile for scroll. Should be under UDF's (Latest version from memory)

Give me a bit to get AutoIt back on this stupid loan machine, and I'll get one working for you :)

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...