Jump to content

Included script hanging after called from GUI

Recommended Posts


I have created a basic GUI(master.au3) which contains a button that calls a specific function from a Include file(slave.au3).

The problem is that the execution of the command netstat -a >> netstat-a.log hangs, apparently doesn't run properly and also does not return control to the GUI.

I made a test where I call the same function from the included script using one main script and it works perfectly. I think I'm missing something regarding the GUI piece.

Can somebody help me?


Below are the two codes that I'm using.

Opt("GUIOnEventMode", 1) 
#include <slave.au3>
#include <GUIConstants.au3>
$mainwindow = GUICreate("Livelab Tool", 300, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseClicked") 
$button = GUICtrlCreateButton("Run", 20, 70, 80)
While 1
  Sleep(1000) ; Idle around
GUICtrlSetOnEvent($button, "_MainSlave")
Func _CloseClicked()

;scriptname: slave.au3
#include <Constants.au3>; Required for $STDERR_CHILD use
Func _RunCommand($command,$tool)
    ConsoleWrite(" [i] Starting " & $tool & @CRLF)
    $ourproc = Run(@ComSpec & " /c " & $command, "", @SW_HIDE,$STDERR_CHILD)    

    While 1
        $line = StderrRead($ourproc)
        If @error Then ExitLoop
        ConsoleWrite(" [X] WARNING: " & $line)

Func _MainSlave()
    Consolewrite("This is the _MainSlave function")
;Running NETSTAT
    $command = "netstat -a >> netstat-a.log"
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...