Jump to content

Splash Screen with text from ConsoleRead


wehr
 Share

Recommended Posts

Hello,

I'm trying to get a "splash screen" while loading a programm via a batch file. This "Splash screen" consists of a background image and and should contain the text, the .bat file echos. But my Splash closes after every message from consoleread and re-opens for the next one.

Here's what my Start.bat looks like:

/Xodu/xodu.exe start first | SplashScreen.exe
/Xodu/xodu.exe start second | SplashScreen.exe

When running these commands in the console, the console echoes: "starting binaries..." and "starting xodu..."

my SplashScreen.exe (the compiled .au3) looks like this:

#NoTrayIcon
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include<ButtonConstants.au3>
#include<EditConstants.au3>
#include<GUIConstantsEx.au3>
#include<StaticConstants.au3>
#include<WindowsConstants.au3>

Local $data
While True
    $data &= ConsoleRead ( )
    If @error Then ExitLoop
    Sleep (1000)
WEnd
$tempo=4000
$tamanhox=@DesktopWidth*0.46875
$tamanhoy=$tamanhox/2
$posicaox=(@DesktopWidth/2)-($tamanhox/2)
$posicaoy=(@DesktopHeight/2)-($tamanhoy)
splashImageOn("","splash.gif",$tamanhox,$tamanhoy,$posicaox,$posicaoy,1)
$GUI = GUICreate ("Teste", $tamanhox, $tamanhoy, $posicaox, $posicaoy,$WS_POPUP, BitOR ($WS_EX_TRANSPARENT, $WS_EX_LAYERED, $WS_EX_TOPMOST))
$label = GUICtrlCreateLabel($data, 20, $posicaoy, 250, $tamanhoy/4)
GUICtrlSetFont(-1,10,$tamanhox/1000)
WinSetTrans ($GUI, "", 100)
GUISetBkColor(0x4169e1, $GUI)
GUISetState(@SW_SHOW,$GUI)
Sleep($tempo)

So when i click my start.bat i see the splash screen with "starting binaries..." after about 2 secs it disapears and then after another second it reapears with the text "starting xodu...". Now how could i make it stay all the time?

Link to comment
Share on other sites

Each command line is not complete until the process receiving the piped data closes. So the first SplashScreen.exe has to close (closing your GUI in the process) before the batch file moves on to the next line. The solution would be for SplashScreen.exe to pass the data on to another process that will be started if required, or use the existing instance if already available. The other process can be the same script with command line options:

#include<GUIConstantsEx.au3>

If $CmdLine[0] Then
    ; There was a commandline parameter passed - create gui and wait
    $hGUI = GUICreate("Test Output Console", 400, 500)
    $idEdit = GUICtrlCreateEdit("Started monitor..." & @CRLF, 10, 10, 380, 480)
    GUISetState()
    Do
        Sleep(100)
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    Exit
Else
    ; No commandline passed - check for gui and post data
    $hGUI = WinGetHandle("Test Output Console", "")
    If Not IsHWnd($hGUI) Then
        Run(@ScriptFullPath & " -x", @ScriptDir, @SW_MINIMIZE)
        WinWait("Test Output Console", "", 10) ; Wait max 10sec for GUI to appear
        $hGUI = WinGetHandle("Test Output Console", "")
        If Not IsHWnd($hGUI) Then
            MsgBox(16, "Error", "Failed to create output monitor GUI.")
            Exit
        EndIf
    EndIf

    $sConsoleData = ""
    While 1
        $sConsoleData &= ConsoleRead()
        If @error Then ExitLoop
    WEnd
    $sEditData = ControlGetText("Test Output Console", "", "Edit1")
    ControlSetText("Test Output Console", "", "Edit1", $sEditData & $sConsoleData)
EndIf

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...