WinSetState geht nicht ?

  • Weiß jemand, warum das

    Script
    [autoit]

    Global $hWnd_Window
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $GUI = GUICreate("WinList", 489, 481, 192, 124)
    GUICtrlCreateGroup("Titel", 8, 8, 233, 433)
    $Titel = GUICtrlCreateList("", 16, 32, 217, 396)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateGroup("Handle", 248, 8, 233, 433)
    $Handle = GUICtrlCreateList("", 256, 32, 217, 396)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Set = GUICtrlCreateButton("Auswählen", 8, 440, 473, 33, $WS_GROUP)
    $List = WinList()
    For $i = 1 To $List[0][0]
    If $List[$i][0] <> "" And IsVisible($List[$i][1]) Then
    GUICtrlSetData($Titel, $List[$i][0] & "|")
    GUICtrlSetData($Handle, $List[$i][1] & "|")
    EndIf
    Next
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Set
    ExitLoop
    EndSwitch
    WEnd
    $hWnd_Window = GUICtrlRead($Handle)
    GUIDelete($GUI)
    Opt("TrayMenuMode", 3)
    Opt("WinTitleMatchMode",4)
    $SH = TrayCreateItem("Hide")
    $SH_S = "1"
    $Exit = TrayCreateItem("Exit")
    While 1
    $tMsg = TrayGetMsg()
    Switch $tMsg
    Case $SH
    If $SH_S = "1" Then
    WinSetState($hWnd_Window,"",@SW_HIDE)
    $SH_S = "0"
    TrayItemSetText($SH,"Show")
    ElseIf $SH_S = "0" Then
    WinSetState($hWnd_Window,"",@SW_SHOW)
    $SH_S = "1"
    TrayItemSetText($SH,"Hide")
    EndIf
    Case $Exit
    WinSetState($hWnd_Window,"",@SW_SHOW)
    Exit
    EndSwitch
    WEnd
    Func IsVisible($Handle)
    If BitAND(WinGetState($Handle), 2) Then
    Return 1
    Else
    Return 0
    EndIf
    EndFunc ;==>IsVisible

    [/autoit]

    nicht geht ?

    [autoit]

    If ProcessExists("Sig.exe") Then
    ConsoleWrite("@@ mfg")
    Else
    ConsoleWrite("!! -no sig-")
    EndIf

    [/autoit]
  • Warum liest du denn die Liste aus und speicherst
    das unter der Variable, bei der du den Status ändern
    willst.
    WinSetState ist nur für GUIS oder andere Programme.
    Benutze, wenn du das gesamte GUI ausblenden willst:

    [autoit]

    WinSetState($GUI,"",@SW_HIDE)

    [/autoit]

    Oder wenn du das Control ausblenden willst:

    [autoit]

    GuiCtrlSetState($Handle,@SW_HIDE)

    [/autoit]


    MfG
    qixx

  • was geht denn bei dir nicht?

    bzw ab wann geht es bei dir nicht weiter? ?(

    bei mir funkt der skript

  • Wenn ich im Tray auf "Hide" klicke, wird das ausgewählte Fenster nicht versteckt :o


    Edit (Doppelpost):

    Warum liest du denn die Liste aus und speicherst
    das unter der Variable, bei der du den Status ändern
    willst.
    WinSetState ist nur für GUIS oder andere Programme.
    Benutze, wenn du das gesamte GUI ausblenden willst:

    [autoit]

    WinSetState($GUI,"",@SW_HIDE)

    [/autoit]

    Oder wenn du das Control ausblenden willst:

    [autoit]

    GuiCtrlSetState($Handle,@SW_HIDE)

    [/autoit]

    GUICtrlRead liest nicht die Liste, sondern den markierten Eintrag aus ;)

    [autoit]

    If ProcessExists("Sig.exe") Then
    ConsoleWrite("@@ mfg")
    Else
    ConsoleWrite("!! -no sig-")
    EndIf

    [/autoit]

    2 Mal editiert, zuletzt von RechterWinkel (26. Februar 2010 um 21:59)

  • GUICtrlRead liest nicht die Liste, sondern den markierten Eintrag aus ;)

    Aber das kannst du ja nicht mit

    [autoit]

    WinSetState

    [/autoit]


    ausblenden. ;)

    Was genau hast du denn vor?

    WinSetState arbeitet mit dem Fenstertitel ;)

    Du kannst aber auch eine Variable einer zuvor erstellten
    GUI benutzen. ;)


    MfG
    qixx""

  • Laut Hilfe kann man statt des Titels auch das Handle eintragen, nur leider klappt das nicht


    Edit (Doppelpost):

    Zitat von qixx

    Was genau hast du denn vor?


    Das Programm soll ein auszuwählendes Fenster bei klick auf Hide ausblenden und umgekehrt auch bei Show einblenden.
    Da sich der Titel aber oft ändert, wollte ich mit dem Handle arbeiten

    [autoit]

    If ProcessExists("Sig.exe") Then
    ConsoleWrite("@@ mfg")
    Else
    ConsoleWrite("!! -no sig-")
    EndIf

    [/autoit]
    • Offizieller Beitrag

    Dein Script hat gleich mehrere Fehler, die Listboxen werden unabhängig voneinander alphanumerisch sortiert.

    [autoit]

    $Titel = GUICtrlCreateList("", 16, 32, 217, 396)

    [/autoit]


    Du benutzt damit die Defaultwerte der Listbox, diese beinhaltet auch $LBS_SORT. Richtig wäre:

    [autoit]

    $Titel = GUICtrlCreateList("", 16, 32, 217, 396,BitOR($WS_BORDER, $WS_VSCROLL))

    [/autoit]


    2.Fehler:

    [autoit]

    $Handle = GUICtrlCreateList("", 256, 32, 217, 396)

    [/autoit]


    muß wie folgt aussehen:

    [autoit]

    $Handle = GUICtrlCreateList("", 256, 32, 217, 396,BitOR($WS_BORDER, $WS_VSCROLL))

    [/autoit]

    Ausserdem gibt

    [autoit]

    $hWnd_Window = GUICtrlRead($Handle)

    [/autoit]

    nicht den Winhandle zurück, sondern einen String. So funktioniert es:

    [autoit]

    $hWnd_Window = HWnd(GUICtrlRead($Handle))

    [/autoit]


    Kompletter Code:

    [autoit]

    Global $hWnd_Window
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #region ### START Koda GUI section ### Form=
    $GUI = GUICreate("WinList", 489, 481, 192, 124)
    GUICtrlCreateGroup("Titel", 8, 8, 233, 433)
    $Titel = GUICtrlCreateList("", 16, 32, 217, 396, BitOR($WS_BORDER, $WS_VSCROLL))
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlCreateGroup("Handle", 248, 8, 233, 433)
    $Handle = GUICtrlCreateList("", 256, 32, 217, 396, BitOR($WS_BORDER, $WS_VSCROLL))
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Set = GUICtrlCreateButton("Auswählen", 8, 440, 473, 33, $WS_GROUP)
    $List = WinList()
    For $i = 1 To $List[0][0]
    If $List[$i][0] <> "" And IsVisible($List[$i][1]) Then
    GUICtrlSetData($Titel, $List[$i][0] & "|")
    GUICtrlSetData($Handle, $List[$i][1] & "|")
    EndIf
    Next
    #endregion ### END Koda GUI section ###

    [/autoit][autoit][/autoit][autoit]

    GUISetState()
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Set
    ExitLoop
    EndSwitch
    WEnd
    $hWnd_Window = HWnd(GUICtrlRead($Handle))
    GUIDelete($GUI)
    Opt("TrayMenuMode", 3)
    Opt("WinTitleMatchMode", 4)
    $SH = TrayCreateItem("Hide")
    $SH_S = "1"
    $Exit = TrayCreateItem("Exit")
    While 1
    $tMsg = TrayGetMsg()
    Switch $tMsg
    Case $SH
    If $SH_S = "1" Then
    WinSetState($hWnd_Window, "", @SW_HIDE)
    $SH_S = "0"
    TrayItemSetText($SH, "Show")
    ElseIf $SH_S = "0" Then
    WinSetState($hWnd_Window, "", @SW_SHOW)
    $SH_S = "1"
    TrayItemSetText($SH, "Hide")
    EndIf
    Case $Exit
    WinSetState($hWnd_Window, "", @SW_SHOW)
    Exit
    EndSwitch
    WEnd
    Func IsVisible($Handle)
    If BitAND(WinGetState($Handle), 2) Then
    Return 1
    Else
    Return 0
    EndIf
    EndFunc ;==>IsVisible

    [/autoit]