Jump to content

Recommended Posts

Posted

Hello guys!

I have a little problem in one of my function/functions. Here is my code:

Func IsVisible($handle)

    If BitAND(WinGetState($handle), 4) Then
        ;If Not BitAND(WinGetState($handle), 16) Then
        If BitAND(WinGetState($handle), 2) Then
            Return 1
        Else
            Return 0
        EndIf
    EndIf

EndFunc   ;==>IsVisible

Func _GetWindows()
; Global $i = 12

    ;Local $anumber = 0 / or use &i?
    Dim $VisibleWindows[1][2] = [["0", ""]]
    $AllWindows = WinList()
    For $i = 1 To $AllWindows[0][0]
        If IsVisible($AllWindows[$i][1]) Then
            If $AllWindows[$i][0] <> "" And $AllWindows[$i][0] <> "Program Manager" Then
                ReDim $VisibleWindows[UBound($VisibleWindows) + 1][2]
                $VisibleWindows[0][0] = $VisibleWindows[0][0] + 1
                $VisibleWindows[($VisibleWindows[0][0])][0] = $AllWindows[$i][0]
                $VisibleWindows[($VisibleWindows[0][0])][1] = $AllWindows[$i][1]
            EndIf
         Else
        EndIf
    Next
    _ArrayDisplay($VisibleWindows, "Visible Windows")

    ;If WinClose("Visible Windows", "") = 1 Then Idle()

EndFunc   ;==>_GetWindows

This should display all windows and their respective handels that WinList function can find, and display it in a "Visible Windows" titled arraydisplay. All good there, script runs as expected. I copied the code for the _GetWindows() from here, and implemented it with minimal changes as I recall (sorry I found it more then a month ago).

My problem is that If I try to close the "Visible Windows" Window, the script just reopens anotherone, basicly the only thing I can do is terminate the script somehow after I started to display this. I'm pretty sure that there is something small that I miss, but since I can't really bend my mind around the _GetWindows array creation, I can't really pinpoint why it opens it again when I close it.

(I try to used WinClose but thats just stupid since there is noproblem with closing, the problem is the reopening, realized that while I was writing it)

Thank you for your help!

  • Solution
Posted (edited)

Sorry, typical Murphy, the problem wasn't originated from the above code.

I made my program that after activating said function it runs it every 200 millisec... Fixed that, works like dream, I only had to post it here first to find the error almost immedietly after it...

Edited by SorryButImaNewbie
Posted

It's often the case that writing the problem down or trying to explain it to others triggers a different thought process and the solution becomes obvious. Done it many times myself. 

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

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
×
×
  • Create New...