Jump to content

Array Ithem to GUI Label


sach
 Share

Recommended Posts

Tell me please how i make output Array Ithem into GUI Label

this part my script, where create array

Local $aGroup

$dom_gr = _ADSamAccountNametoFQDN("VPN Access Group")

_ADGetGroupMembers($aGroup, $dom_gr)

_ArrayDisplay($aGroup, "Members of group: ", $dom_gr)

;Конвертим fqdn в displayname и сравниваем

$iCount = 1

Local $iCount2 =1, $iCount3 =1, $aDisplay[20]

Dim $num = 0

For $iCount = 1 To UBound($aFile)-1

$fqdn_name = _ADSamAccountNametoFQDN($aFile[$iCount])

$iIndex = _ArraySearch($aGroup, $fqdn_name, 0, 0, 0, 1)

If Not @error Then

$fqdn_name1 = _ADDNToSamAccountName($fqdn_name)

_ArrayInsert($aDisplay, $iCount3, $fqdn_name1)

$num += 1

EndIf

$iCount3 += 1

Next

_ArrayInsert($aDisplay, 0, $num)

_ArrayDisplay($aDisplay)

i want array $aDisplay output in GUI form, how ?

Link to comment
Share on other sites

If you mean you want the data displayed in your own gui then have a look at the source for _ArrayDisplay which uses a listview. Or you could create a grid of labels or format the data in an edit. It depends how you want the information displayed.

EDIT: Welcome to the AutoIt forums sach :D

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

If you mean you want the data displayed in your own gui then have a look at the source for _ArrayDisplay which uses a listview. Or you could create a grid of labels or format the data in an edit. It depends how you want the information displayed.

EDIT: Welcome to the AutoIt forums sach :D

No not ListView. Data not edit.

How create grid of labels and out to data from array ?

Link to comment
Share on other sites

No not ListView. Data not edit.

How create grid of labels and out to data from array ?

Dim $Labels[Ubound($aDisplay)]

;create labels with data
for $n = 0 to Ubound($aDisplay) - 1
;some code here to give $x and $y based on $n
 $Labels[$n] = GuiCtrlCreateLabel($aDisplay[$n],$x, $y,120,25)
next

;to change data in labels
for $n = 0 to Ubound($aDisplay) - 1
 GuiCtrlSetData( $Labels[$n],$aDisplay[$n])

next

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <file.au3>
#include <adfunctions.au3>
#include <array.au3>
#include <Guiconstants.au3>

Local $aFile
Local $iCount = 1
    _FileReadToArray("D:\files\autoit\maa01.txt", $aFile)
    If @error Then 
        ;Return SetError(@error, 0, 0)
        MsgBox(4096,"Error", " Error open file:" & @error)
    EndIf
    While 1
           $iCount += 1
        If $iCount > UBound($aFile) - 1 Then ExitLoop
    WEnd
    _ArrayDisplay($aFile)
    FileClose("D:\files\autoit\maa01.txt")
    $iCount = 0
    
;Считываем из домена   

Local $aGroup
    $dom_gr = _ADSamAccountNametoFQDN("VPN Access Group")
    _ADGetGroupMembers($aGroup, $dom_gr)
    _ArrayDisplay($aGroup, "Members of group: ", $dom_gr)

;Конвертим fqdn в displayname и сравниваем

$iCount = 1
Local $iCount2 =1, $iCount3 =1, $aDisplay[UBound($aFile)]
Dim $num = 0
    
    For $iCount = 1 To UBound($aFile)-1
        $fqdn_name = _ADSamAccountNametoFQDN($aFile[$iCount])
        $iIndex = _ArraySearch($aGroup, $fqdn_name, 0, 0, 0, 1)
            If Not @error Then 
                    $fqdn_name1 = _ADDNToSamAccountName($fqdn_name)
                    _ArrayInsert($aDisplay, $iCount3, $fqdn_name1)
                    $num += 1
            EndIf
        $iCount3 += 1
    Next
_ArrayInsert($aDisplay, 0, $num)    
_ArrayDisplay($aDisplay)

;Считаем пол-ей и, строим ГУИ и делаем выход.

    Local $YesID, $NoID, $msg, $achars[UBound($aDisplay)], $iCount4=0
    
    For $iCount3 = 1 To UBound($aDisplay)-1
            
        If $aDisplay[$iCount3] <> "" Then
                    _ArrayInsert($achars, $iCount4, $aDisplay[$iCount3])
                    $iCount4 += 1
        EndIf
    Next
    _ArrayDisplay($achars)

    Local $YesID, $NoID, $msg
    
    GUICreate("Превышен лимит", 200, 500)
    Local $Labels[Ubound($achars)]
    ;create labels with data
        For $n = 0 to Ubound($achars) - 1
            $x = 50
            $y = 50
            ;some code here to give $x and $y based on $n
            $Labels[$n] = GuiCtrlCreateLabel($achars[$n],$x, $y,120,25)
            $x +=20
            $y +=20
            ;MsgBox(0,"1",$Labels[0])
        Next

    ;to change data in labels
        For $n = 0 to Ubound($achars) - 1
            GuiCtrlSetData( $Labels[$n],$achars[$n])
        Next
    GUISetState()
    
    $YesID = GUICtrlCreateButton("Выход", 50, 210, 70, 25)
    ;$NoID = GUICtrlCreateButton("Выход", 100, 210, 70, 25)
    
    Do
        $msg = GUIGetMsg()

        Select
            Case $msg = $YesID
                MsgBox(0, "Завершение сеанса", "Повторите попытку позже")
                ;shutdown (0)
                GUIDelete()
                Exit
            ;Case $msg = $NoID
            ;   Shutdown (0)
            MsgBox(0, "Exit", $ismember)
            Case $msg = $GUI_EVENT_CLOSE
                MsgBox(0, "Завершение сеанса", "Повторите попытку позже")
                GUIDelete()
                ;shutdown (0)
    EndSelect
            
    Until $msg = $GUI_EVENT_CLOSE

This script. In result create empty GUI form. Whats wrong ? Help please

Link to comment
Share on other sites

It's better to post a script which other people can run. I cannot run your script so I'm not going to spend any time on it.

Instead here is an example which I hope will help.

Dim $Labels[26]
$text = FileRead(@ScriptFullPath)

$Gui = GUICreate("label array", 600, 400)
$btn = GUICtrlCreateButton("change", 80, 10)

$x = 20
$y = 70
For $n = 0 To 25
    $Labels[$n] = GUICtrlCreateLabel(LabText($text, 1 + $n * 3, 6), $x, $y, 120, 25)
    $x += 150
    If $x + 120 > 600 Then
        $y += 40
        $x = 20
    EndIf
Next
    
GUISetState()

While 1
    
    
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
    
    If $msg = $btn Then
        ;to change data in labels
        For $n = 0 To UBound($Labels) - 1
            $r = Random(1, StringLen($text) - 10, 1)
            GUICtrlSetData($Labels[$n], LabText($text, $r, 9))
        Next
    EndIf
    
WEnd


Func labText($s,$a,$b)
    Local $s2 = StringMid($s,$a,$b)
    Return StringRegExpReplace($s2,"\W",".")
EndFunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...