Jump to content
Sign in to follow this  
florisch

GUI not active

Recommended Posts

florisch

I want to start another app, lets say "B", which gives back data via I/O stream. Therefore the starting script "A" should go on an process the data, but should not allow user interaction while B is running. I used GUISetState(@SW_DISABLE) and GUISetState(@SW_ENABLE).

The Problem is: when B stops, A is still disabled and another Window gets focused. Getting the focus back with winactivate causes an unaesthetic flicker.

But I cannot enable A before B closes.

An idea somebody? Or do I just have to live with it?

Here is some code for testing:

#include <GUIConstants.au3>

$Form1 = GUICreate("A")
$BtnA = GUICtrlCreateButton("Normal", 10,10)
$BtnB = GUICtrlCreateButton("A disabled", 150,10)
GUISetState(@SW_SHOW, $Form1)

While 1 ; Main loop, GUI-manager
    $aGUIMsg = GUIGetMsg(1)
    select 
        Case  $aGUIMsg[0] = $GUI_EVENT_CLOSE
            Exit
        Case $aGUIMsg[0] = $BtnA
            a()
        Case $aGUIMsg[0] = $BtnB
            b()
    EndSelect
WEnd

Func a()
    $pid = Run("notepad.exe", @ScriptDir)
    If @error Then exit
    While ProcessExists($pid)
        Sleep(100)
    WEnd
EndFunc   

Func b()
    GUISetState(@SW_DISABLE, $Form1)
    a()
    GUISetState(@SW_ENABLE, $Form1)
    WinActivate($Form1)
EndFunc

Share this post


Link to post
Share on other sites
BrettF

I want to start another app, lets say "B", which gives back data via I/O stream. Therefore the starting script "A" should go on an process the data, but should not allow user interaction while B is running. I used GUISetState(@SW_DISABLE) and GUISetState(@SW_ENABLE).

The Problem is: when B stops, A is still disabled and another Window gets focused. Getting the focus back with winactivate causes an unaesthetic flicker.

But I cannot enable A before B closes.

An idea somebody? Or do I just have to live with it?

Here is some code for testing:

#include <GUIConstants.au3>

$Form1 = GUICreate("A")
$BtnA = GUICtrlCreateButton("Normal", 10,10)
$BtnB = GUICtrlCreateButton("A disabled", 150,10)
GUISetState(@SW_SHOW, $Form1)

While 1 ; Main loop, GUI-manager
    $aGUIMsg = GUIGetMsg(1)
    select 
        Case  $aGUIMsg[0] = $GUI_EVENT_CLOSE
            Exit
        Case $aGUIMsg[0] = $BtnA
            a()
        Case $aGUIMsg[0] = $BtnB
            b()
    EndSelect
WEnd

Func a()
    $pid = Run("notepad.exe", @ScriptDir)
    If @error Then exit
    While ProcessExists($pid)
        Sleep(100)
    WEnd
EndFunc   

Func b()
    GUISetState(@SW_DISABLE, $Form1)
    a()
    GUISetState(@SW_ENABLE, $Form1)
    WinActivate($Form1)
EndFunc oÝ÷ Ûú®¢×uÛ(ëax%GºÚ"µÍYÝØÙÜÑ^Ý
    ][ÝÔØÙÜÓ[YSÙØÜ][ÝÊH[ÕRTÙ]Ý]H
Õ×Ñ[XJB[Y

into the while loop of process A :)

Share this post


Link to post
Share on other sites
florisch

Add something like:

If Not ProcessExist ("ProcessNameOfScriptB") Then
GUISetState (@SW_Enable)
Endif

into the while loop of process A :)

Thats just another place for the GUISetState (@SW_Enable) and of course will be processed _after_ B closes. At this time A is already gone. (Nevertheless, I tried this, and no, it does not change anything.)

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  

×