Sign in to follow this  
Followers 0
vaibhavs

Need help with this script

5 posts in this topic

Hi,

I need help with this code. My first real script!!

This script will execute some Shell commands.

While executing the shell command, I need the progress bar.

Problem 1 : The close button is not working in the child window.

Problem 2 : If I close the Child Window using GUI_EVENT_CLOSE, the main window also closes.

Please help.

Also if any code optimization is possible, please advice.

#include <GuiConstants.au3>

; GUI
$ParentWin = GuiCreate("Internet Connection Manager", 400, 400)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)


; LABEL
$title = GuiCtrlCreateLabel("My Title here My Title Here", 35, 20, 350, 50)
GUICtrlSetFont(-1, 15, 800, -1, "Verdana")
GuiCtrlSetColor(-1, 0x0000FF)


; BUTTON
$Btn_Get1 = GuiCtrlCreateButton("Command 1", 130, 130, 150, 40)
$Btn_Get2 = GuiCtrlCreateButton("Command 2", 130, 190, 150, 40)
$Btn_Get3 = GuiCtrlCreateButton("Command 3", 130, 250, 150, 40)
GUICtrlSetStyle(-1, $SS_CENTER)

$Btn_Ext0 = GuiCtrlCreateButton("Close", 160, 330, 90, 20)
GuiSetState()



While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $Btn_Ext0
            ExitLoop
        Case $msg = $Btn_Get1
            func4cmd1()
        Case $msg = $Btn_Get2
            func4cmd2()
        Case $msg = $Btn_Get3
            func4cmd3()         
    EndSelect
    if $msg = $GUI_EVENT_CLOSE Then ExitLoop;GUIDelete();ExitLoop; for closing the application window. The [X] icon
WEnd
Exit

;GUIDelete()








Func func4cmd1()
        ;PROGRESS BAR
            $ChildWin = GUICreate('Screen 2...', 300, 140)
            $progressbartext = GuiCtrlCreateLabel("Progress Bar...", 45, 10, 350, 50)
            GUICtrlSetFont(-1, 10, 800, -1, "Verdana")
            GuiCtrlSetColor(-1, 0x0000FF)
            $pro = GUICtrlCreateProgress(35, 40, 230, 20)
            GUISetState()
                For $i = 0 To 100 Step 1
                    GUICtrlSetData($pro, $i)
                    Sleep(10)
                Next

                        $cmd1   = 'some command here'
                ;   $foo1 = RunWait($cmd1, @SystemDir, @SW_HIDE)

                $progressbartextend = GuiCtrlCreateLabel("Screen 2!", 50, 70, 350, 50)
                GUICtrlSetFont(-1, 10, 800, -1, "Verdana")
                GuiCtrlSetColor(-1, 0x000000)
                GUICtrlCreateButton("Done", 105, 100, 90, 20)
                While 1
                    $msg = GuiGetMsg()
;                   Select
;                       Case $msg = $progressbartextendClose
;                           ExitLoop
;                   EndSelect
                    if $msg = $GUI_EVENT_CLOSE Then ExitLoop; for closing the application window the [X]
                WEnd
EndFunc

Thank you.

Vai

Share this post


Link to post
Share on other sites



#include <GuiConstants.au3>

; GUI
$ParentWin = GUICreate("Internet Connection Manager", 400, 400)
GUISetIcon(@SystemDir & "\mspaint.exe", 0)

; LABEL
$title = GUICtrlCreateLabel("My Title here My Title Here", 35, 20, 350, 50)
GUICtrlSetFont(-1, 15, 800, -1, "Verdana")
GUICtrlSetColor(-1, 0x0000FF)

; BUTTON
$Btn_Get1 = GUICtrlCreateButton("Command 1", 130, 130, 150, 40)
$Btn_Get2 = GUICtrlCreateButton("Command 2", 130, 190, 150, 40)
$Btn_Get3 = GUICtrlCreateButton("Command 3", 130, 250, 150, 40)
GUICtrlSetStyle(-1, $SS_CENTER)

$Btn_Ext0 = GUICtrlCreateButton("Close", 160, 330, 90, 20)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            ExitLoop
        Case $msg = $Btn_Ext0
            ExitLoop
        Case $msg = $Btn_Get1
            func4cmd1()
        Case $msg = $Btn_Get2
            func4cmd2 ()
        Case $msg = $Btn_Get3
            func4cmd3 ()
    EndSelect
WEnd
Exit

;GUIDelete()

Func func4cmd1()
    ;PROGRESS BAR
    $ChildWin = GUICreate('Screen 2...', 300, 140)
    $progressbartext = GUICtrlCreateLabel("Progress Bar...", 45, 10, 350, 50)
    GUICtrlSetFont(-1, 10, 800, -1, "Verdana")
    GUICtrlSetColor(-1, 0x0000FF)
    $pro = GUICtrlCreateProgress(35, 40, 230, 20)
    GUISetState()
    For $i = 0 To 100 Step 1
        GUICtrlSetData($pro, $i)
        Sleep(10)
    Next

    $cmd1 = 'some command here'
    ;    $foo1 = RunWait($cmd1, @SystemDir, @SW_HIDE)

    $progressbartextend = GUICtrlCreateLabel("Screen 2!", 50, 70, 350, 50)
    GUICtrlSetFont(-1, 10, 800, -1, "Verdana")
    GUICtrlSetColor(-1, 0x000000)
    GUICtrlCreateButton("Done", 105, 100, 90, 20)
    While 1
        $msg2 = GUIGetMsg()
        ;                    Select
        ;                        Case $msg = $progressbartextendClose
        ;                            ExitLoop
        ;                    EndSelect
        If $msg2 = $GUI_EVENT_CLOSE Then ExitLoop; for closing the application window the [X]
    WEnd
    GUIDelete($ChildWin)    
EndFunc   ;==>func4cmd1


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thanks "gafrost".

It helped with the child window closing individually.

Can you identify why the "Done" button (in the function) is not active ??

I discovered one mistake. I was missing the following line, but it still does not work.

$progressbartextendClose = GUICtrlCreateButton("Close", 105, 100, 90, 20)

I am sure its something minor

Thank you in advance.

Func func4cmd1()
   ;PROGRESS BAR
    $ChildWin = GUICreate('Screen 2...', 300, 140)
    $progressbartext = GUICtrlCreateLabel("Progress Bar...", 45, 10, 350, 50)
    GUICtrlSetFont(-1, 10, 800, -1, "Verdana")
    GUICtrlSetColor(-1, 0x0000FF)
    $pro = GUICtrlCreateProgress(35, 40, 230, 20)
    GUISetState()
    For $i = 0 To 100 Step 1
        GUICtrlSetData($pro, $i)
        Sleep(10)
    Next

    $cmd1 = 'some command here'
   ;    $foo1 = RunWait($cmd1, @SystemDir, @SW_HIDE)

    $progressbartextend = GUICtrlCreateLabel("Screen 2!", 50, 70, 350, 50)
    GUICtrlSetFont(-1, 10, 800, -1, "Verdana")
    GUICtrlSetColor(-1, 0x000000)
    GUICtrlCreateButton("Done", 105, 100, 90, 20)
    While 1
        $msg2 = GUIGetMsg()
       ;                    Select
       ;                        Case $msg = $progressbartextendClose
       ;                            ExitLoop
       ;                    EndSelect
        If $msg2 = $GUI_EVENT_CLOSE Then ExitLoop; for closing the application window the [X]
    WEnd
    GUIDelete($ChildWin)    
EndFunc  ;==>func4cmd1

Share this post


Link to post
Share on other sites

Thanks "gafrost".

It helped with the child window closing individually.

Can you identify why the "Done" button (in the function) is not active ??

I discovered one mistake. I was missing the following line, but it still does not work.

$progressbartextendClose = GUICtrlCreateButton("Close", 105, 100, 90, 20)

I am sure its something minor

Thank you in advance.

Func func4cmd1()
  ;PROGRESS BAR
    $ChildWin = GUICreate('Screen 2...', 300, 140)
    $progressbartext = GUICtrlCreateLabel("Progress Bar...", 45, 10, 350, 50)
    GUICtrlSetFont(-1, 10, 800, -1, "Verdana")
    GUICtrlSetColor(-1, 0x0000FF)
    $pro = GUICtrlCreateProgress(35, 40, 230, 20)
    GUISetState()
    For $i = 0 To 100 Step 1
        GUICtrlSetData($pro, $i)
        Sleep(10)
    Next

    $cmd1 = 'some command here'
  ; $foo1 = RunWait($cmd1, @SystemDir, @SW_HIDE)

    $progressbartextend = GUICtrlCreateLabel("Screen 2!", 50, 70, 350, 50)
    GUICtrlSetFont(-1, 10, 800, -1, "Verdana")
    GUICtrlSetColor(-1, 0x000000)
    GUICtrlCreateButton("Done", 105, 100, 90, 20)
    While 1
        $msg2 = GUIGetMsg()
      ;                 Select
      ;                     Case $msg = $progressbartextendClose
      ;                         ExitLoop
      ;                 EndSelect
        If $msg2 = $GUI_EVENT_CLOSE Then ExitLoop; for closing the application window the [X]
    WEnd
    GUIDelete($ChildWin)    
EndFunc ;==>func4cmd1
Case $msg2 = $progressbartextendClose

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Case $msg2 = $progressbartextendClose

Oh Yes!!.

Changed, but did not help.

For some reason the button is INACTIVE (I mean when I get the mouse over the button or press it, it does not show the 3rd effect typical of XP).

I get a feeling the button is not active at all.

Any ideas ???

Thx

Share this post


Link to post
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
Sign in to follow this  
Followers 0