Jump to content
Sign in to follow this  
SorryButImaNewbie

_ArrayDisplay function, finding "logic loop which reopens arraydisplay"

Recommended Posts

SorryButImaNewbie

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!

Share this post


Link to post
Share on other sites
SorryButImaNewbie

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

Share this post


Link to post
Share on other sites
Bowmore

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

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  

  • Similar Content

    • TimRude
      By TimRude
      The help text for the _ArrayDisplay function says: "Clicking on a column header sort it."
      I'm wondering why the sorting of hex numbers (specifically window handles like 0x12345678) is so wonky.
      Sample script:
      #include <Array.au3> Local $aList = WinList() _ArrayDisplay($aList) Clicking on the Col1 header to sort by window handle doesn't properly sort the list.
      As a workaround, I'm sorting the array by window handle before displaying it using _ArraySort. But I still wonder what's up with the ListView sorting.
      Workaround:
      #include <Array.au3> Local $aList = WinList() _ArraySort($aList, 0, 1, 0, 1) _ArrayDisplay($aList)  
    • Ostap
      By Ostap
      I have a small script that checks if users from certain security groups exist or are disabled in AD. 
         For $j = Ubound ( $Users, 1 ) -1 To 0 Step -1       Switch _AD_IsObjectDisabled ( $Users[$j] )           Case 1             ClipPut ( $Users[$j] & " - account disabled; " )           Case 0             If @error = 1 Then                ClipPut ( $Users[$j] & " - account not found; " )             Else                ClipPut ( $Users[$j] & " - Ok; " )             EndIf       EndSwitch    $Clip = $Clip & @CRLF & ClipGet ()    Next   $Data[$O][1] = $Clip The code works correctly, at the end I have a 2D array $Data with security group in column 1 and checked user accounts in columns 2. However, _ArrayDisplay ( $Data ) shows users in one row, despite I added @CRLF. When I write $Clip to a text file, user accounts are written as column. Isn't it possible to have multiple-line cell split by @CRLF in _ArrayDisplay? 
    • distancesprinter
      By distancesprinter
      _ArrayDisplay($aArray, "Window Title", "1:", 0, Default, "Column") ; Expected results are rows 1 to the end of the array, all columns. The result is rows 0-1, all columns. The API reference is here:
      https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayDisplay.htm
       
      Am I doing something wrong?
    • Eddi96
      By Eddi96
      Hello World!
      So I have this code
      #include <Array.au3> Run("C:\Windows\System32\query user>>c:\GTScript\query.txt") $aFileArray = FileReadToArray("c:\GTScript\query.txt") -1 ; NOTE: the first line of the file is in element 0, but that only holds column headers so we start from 1! For $lineIndex = 1 to UBound($aFileArray) ; Let's take every group of non-whitespace characters from the current line and put it in an array: $aSplit = StringRegExp($aFileArray[$lineIndex], "(\S+)", $STR_REGEXPARRAYGLOBALMATCH) _ArrayDisplay($aSplit, "All elements on line") ; We know the format of the file, so we know where the values will be in the array: $userName = $aSplit[0] $userId = $aSplit[2] MsgBox(64, "Info", "Username: " & $userName & @CRLF & "ID: " & $userId) Next Do you have an Idea on how to rewrite it so it allways tells me row 2  of a certain user, no matter in which Column of ArrayDisplay he is?
      Post examples please, since I am still a rookie!
       
      With kind regards
      Eddi96
    • TheDcoder
      By TheDcoder
      Hi, Please look at the code below:
      #include <File.au3> #include <Array.au3> ; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ; #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> #include <GuiListView.au3> Global $hGUI = GUICreate("GUIx",283,120,-1,-1,-1,-1) GUISetBkColor(0xFFFFFF,$hGUI) $hListX = GUICtrlCreatelistview("ColumnX|ColumnY|ColumnZ",4,4,269,65,4,544) ; GUICtrlCreatelistview("ListX",7,4,269,65,-1,512) GUICtrlSetData(-1, "ColumnX|ColumnY|ColumnZ") $hButtonY = GUICtrlCreateButton("ButtonY",20,80,100,30,-1,-1) $hButtonZ = GUICtrlCreateButton("ButtonZ",160,80,100,30,-1,-1) GUISetState() While True $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hButtonY AddRows() EndSwitch WEnd Func AddRows() Local $aFiles = _FileListToArray(@ScriptFullPath & '\FolderX', Default, Default, True) _ArrayDisplay($aFiles) Local $aContent[9] For $i = 0 To UBound($aFiles) - 1 MsgBox(0, "", $aFiles) $aContent = FileReadToArray($aFiles[$i]) Next For $i = 0 To UBound($aContent) - 1 Step 3 GUICtrlCreateListViewItem($aContent[$i] & '|' & $aContent[$i + 1] & '|' & $aContent[$i + 2], $hListX) Next EndFunc _ArrayDisplay at line no. 33 is not working, I don't know what is happening...
      Thanks in Advance, TD
      P.S Actually the code was for another question but while debugging the code, I encountered this problem
×