Jump to content

GUI not active


Recommended Posts

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
Link to comment
Share on other sites

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 :)

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