Sign in to follow this  
Followers 0
GodlessSinner

Why it's so?

3 posts in this topic

I can't understand why script repeat Cases($w[$n] ) and shows MsgBoxes while $h[$n] = "\".

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $w[10], $h[10],$i = 0, $ownhandle
For $i = 1 To 9 Step 1
    $w[$i] = "\"
    $h[$i] = "\"
Next
$Form1 = GUICreate("Form1", 428, 101, 268, 474)
$Button1 = GUICtrlCreateButton("Hide/Show", 24, 32, 113, 25, 0)
$Button1context = GUICtrlCreateContextMenu($Button1)
$MenuItem1 = GUICtrlCreateMenu("Show", $Button1context)

$ownhandle = WinGetHandle($Form1, "")

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Sleep(2000)
            $handle = WinGetHandle("", "")
            If $handle <> $ownhandle Then
                $added = 0
                For $n = 1 To 9 Step 1
                    If $w[$n] = "\" And $h[$n] = "\" And $added = 0 Then
                        If MsgBox(4, "Hide this window?", WinGetTitle($handle)) = 6 Then
                            $w[$n] = GUICtrlCreateMenuItem(WinGetTitle($handle), $MenuItem1)
                            $h[$n] = $handle
                            $added = 1
                            WinSetState($h[$n],"", @SW_HIDE)
                        EndIf
                    EndIf
                Next
            EndIf
        Case $w[1]
            MsgBox(0,"test","")
            GUICtrlDelete($w[1])
            WinSetState($h[1],"", @SW_SHOW)
            $w[1] = "\"
            $h[1] = "\"
        Case  $w[2]
            ;MsgBox(0,"test2","")
            GUICtrlDelete($w[2])
            WinSetState($h[2],"", @SW_SHOW)
            $w[2] = "\"
            $h[2] = "\"
        Case $w[3]
            ;MsgBox(0,"test3","")
            GUICtrlDelete($w[3])
            WinSetState($h[3],"", @SW_SHOW)
            $w[3] = "\"
            $h[3] = "\"
        Case $w[4]
            GUICtrlDelete($w[4])
            WinSetState($h[4],"", @SW_SHOW)
            $w[4] = "\"
            $h[4] = "\"
        Case $w[5]
            GUICtrlDelete($w[5])
            WinSetState($h[5],"", @SW_SHOW)
            $w[5] = "\"
            $h[5] = "\"
        Case $w[6]
            GUICtrlDelete($w[6])
            WinSetState($h[6],"", @SW_SHOW)
            $w[6] = "\"
            $h[6] = "\"
        Case $w[7]
            GUICtrlDelete($w[7])
            WinSetState($h[1],"", @SW_SHOW)
            $w[7] = "\"
            $h[7] = "\"
        Case $w[8]
            GUICtrlDelete($w[8])
            WinSetState($h[8],"", @SW_SHOW)
            $w[8] = "\"
            $h[8] = "\"
        Case $w[9]
            GUICtrlDelete($w[9])
            WinSetState($h[9],"", @SW_SHOW)
            $w[9] = "\"
            $h[9] = "\"
    EndSwitch
WEnd

_____________________________________________________________________________

Share this post


Link to post
Share on other sites



Try giving the array members something more meaningful to avoid zero-evaluation expression to occur, it's well possible that '\' and $nMsg both evaluated to 0. Try -1 instead.

Share this post


Link to post
Share on other sites

Thanks a lot!


_____________________________________________________________________________

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  
Followers 0