Sign in to follow this  
Followers 0
JohnBailey

WinList to array

4 posts in this topic

Does anyone know why this won't work? I'm just wanting to send the window list array to a file.

Opt("TrayIconDebug", 1)
TrayTip("AutoIt Script", @ScriptName, 10, 1)
#include <Array.au3>
#include <File.au3>

$array = WinList()

$file = FileOpen("currentWindowList.txt", 1)
_ArrayDelete($array, 0)
$write = _FileWriteFromArray("currentWindowList.txt", $array, 0)
FileClose($file)

A decision is a powerful thing

Share this post


Link to post
Share on other sites



This has the same effect. Nonetheless, it would be nice to know how to list all of them at one time instead of incrementing it like I have done.

Opt("TrayIconDebug", 1)
TrayTip("AutoIt Script", @ScriptName, 10, 1)
#include <Array.au3>
#include <File.au3>

$var = WinList()
$file = FileOpen("currentWindowList.txt", 1)

For $i = 1 to $var[0][0]
  ; Only display visble windows that have a title
  If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
    $write = FileWriteLine("currentWindowList.txt", $var[$i][0])
    ;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
  EndIf
Next

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf

EndFunc
FileClose("currentWindowList.txt")

A decision is a powerful thing

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Does anyone know why this won't work? I'm just wanting to send the window list array to a file.

Opt("TrayIconDebug", 1)
TrayTip("AutoIt Script", @ScriptName, 10, 1)
#include <Array.au3>
#include <File.au3>

$array = WinList()

$file = FileOpen("currentWindowList.txt", 1)
_ArrayDelete($array, 0)
$write = _FileWriteFromArray("currentWindowList.txt", $array, 0)
FileClose($file)oÝ÷ Ûú®¢×zÅ¢¸¬¶·­º¹ìkgbéìÚªëk-4jw@®¶²
é^µïÅW®+^º&ºÚÊåʧvWµv)Ȩ©Dv+H~+wöÈî²Ü"Ú0³*.j·­¯(§Ú0®+^¶§¥«,¶W§jgÙhq«b¢{h¶¬~éܶ*'jëh×6Func _FileWriteWinList($hFile)
    If Not FileExists($hFile) Then FileClose(FileOpen($hFile, 2))
    Local $aWL = WinList(), $sHold = ''
    For $iCC = 1 To UBound($aWL) -1
        If $aWL[$iCC][0] And BitAND(WinGetState($aWL[$iCC][1]), 2) Then
            $sHold &= $aWL[$iCC][0] & @CRLF
        EndIf
    Next
    If $sHold Then Return FileWrite($hFile, StringTrimRight($sHold, 2))
    Return SetError(1, 0, '')
EndFunc
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thanks that works so much better!


A decision is a powerful thing

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