Jump to content

GUI not responding


t0ddie
 Share

Recommended Posts

Well... rewriting my old script in the new version of autoit has been challenging to say the least.

as i test the script more and more i keep finding other problems!

This time, i have made example code.

what the code is supposed to do, is open a child gui. (works)

then you press the ping button, and it pings the ip address that was entered (works)

but after it finished pinging, its supposed to put the last entered ip back into the field. then give it focus (highlight it)

and instead it stays blank. and if you try to close the child gui after that nothing happens. (frozen)

if i just open the child gui and close it without hitting the ping button it does close.

this code worked before with an older version of autoit. hopefully someone can show me how to fix this?

#include <GUIConstants.au3>
#include <Constants.au3>

$GUI = GUICreate("test",300,300,100,100)
$button6 = GUICtrlCreateButton("test",10,10,40,25)
GUISetState()
while 1
    $msg = GUIGetMsg()
    Select
        
    Case $msg = $GUI_EVENT_CLOSE
        Exit
        
Case $msg = $button6
        GUISetState(@SW_DISABLE, $GUI)
        $fade = 255
        $vol = 0
        Do
            WinSetTrans($GUI, "", $fade)
            $fade = $fade - 1.5
        Until $fade < 0
        GUISetState(@SW_HIDE, $GUI)
        $pinger = GUICreate("Pinger!", 350, 280)
        $hEdit = GUICtrlCreateEdit("", 5, 5, 300,)
        GUICtrlCreateLabel("Enter a COMPUTER or IP ADDRESS to ping!", 5, 190)
        $hInput = GUICtrlCreateInput("", 5, 220)
        GUICtrlSetData($hInput, @ComputerName)
        $buttonz = GUICtrlCreateButton("Ping!", 107, 250, 50, 20)
        GUICtrlSetState($hInput, $GUI_FOCUS)
        GUISetState()
        $PID = 0
        While 1
            $data = StdoutRead ($PID, 0, 1)
            If $data Then
                While 1
                    $line = StdoutRead ($PID)
                    If @error = -1 Then ExitLoop
                    GUICtrlSetData($hEdit, $line, 1)
                WEnd
                GUICtrlSetData($hInput, $box)
                GUICtrlSetState($hInput, $GUI_FOCUS)
            EndIf
            $nMsg = GUIGetMsg()
            Select
                Case $nMsg = $GUI_EVENT_CLOSE
                    $fade = 0
                    ProcessClose($PID)
                    GUIDelete($pinger)
                    GUISetState(@SW_SHOW, $GUI)
                    GUISetState(@SW_ENABLE, $GUI)
                    Do
                        WinSetTrans("test", "", $fade)
                        $fade = $fade + 1.5
                    Until $fade > 255
                    ExitLoop

                Case $nMsg = $buttonz


                    $box = GUICtrlRead($hInput)
                    GUICtrlSetData($hInput, "")
                    $PID = Run(@ComSpec & " /c ping " & $box, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                    GUICtrlSetState($hInput, $GUI_FOCUS)
            EndSelect
        WEnd
        
EndSelect
WEnd

thanks for looking :)

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

  • Developers

Couple of observations:

- What have you done to figure out where it is Hanging ?

- There is an au3check error when running the script

The problem is simple to solve but in stead of telling you I am going to tell you how you can figure it out yourself . The hint is TrayDebug ...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

Didn't feel like debugging it? You see anything wrong with how your trying to exit that loop?

If $data Then
                While 1
                    $line = StdoutRead ($PID)
                    $ATERROR = @error
                    If $ATERROR = -1 Then ExitLoop
                    ToolTip('@error = ' & $ATERROR, 0, 0)
                    GUICtrlSetData($hEdit, $line, 1)
                WEnd
                MsgBox(0,'', '')
                GUICtrlSetData($hInput, $box)
                GUICtrlSetState($hInput, $GUI_FOCUS)
            EndIf

Edit:

Opps... Sorry Jdeb (but I didn't give him the complete answer to mine :) )

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Couple of observations:

- What have you done to figure out where it is Hanging ?

- There is an au3check error when running the script

The problem is simple to solve but in stead of telling you I am going to tell you how you can figure it out yourself . The hint is TrayDebug ...

1. in the actual script i have added msgbox(0,"test","test") in places to see where it was getting stuck

2. i didnt use au3check on this script.. but i do remember using it with the old version and there was no error.

i dont see how there can be a problem if it works with the old version of autoit. but...

thanks for the tips. i changed -1 to -2 and everything is back to how it should be

EDIT: theres one other thing. i want to play a sound when you "ping" and if i add a sound after the button it wont play until about the middle of the pinging operation.

i remember having edited the code previously to play it right as soon as you hit the button. but i cant remember what i did.

anyways, if you were to just add a soundplay command after the case statement, the sound would be delayed in playing until about the middle of the ping operation. why is this?

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

  • Moderators

I would imagine the sound wouldn't play until the end of the ping. You may want to look at /AutoIt3ExecuteLine

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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