Jump to content
MesterPerfect

need help to create a treeview linked with array

Recommended Posts

good morning
this is the first post here in the autoit forums
i hope that you can help me in my problem
i have a JSON encoded
it a map of my forums
where i want to make a treeview that have the same type of map
e.g
a system (as category)
windows (as sub category)
software (as an child item in the windows category)
.....
i don't know how to do that
so, i know that i can do that using the json functions
but i need your help about how we can do it as the type that i told you
by the way i need to put the sub info for each item in an array that give me the ability to manage my items
e.g
can post thread
can reply
message cound ...
you just give me a small example and i can continue.
am sorry if this against the rules of the forum.
but i realy searched a lot but i couldn't
i hope some one give me the way.
thank you very much in advance

 

here is the link of json forum
https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn/

and here is my encoded json file

 

{
    "tree_map": {
        "0": [
            1,
            5,
            6,
            7
        ],
        "1": [
            2
        ],
        "2": [
            4
        ],
        "5": [
            3
        ],
        "6": [
            8
        ],
        "8": [
            9,
            10
        ]
    },
    "nodes": [
        {
            "breadcrumbs": [],
            "description": "",
            "display_in_list": true,
            "display_order": 1,
            "node_id": 1,
            "node_name": null,
            "node_type_id": "Category",
            "parent_node_id": 0,
            "title": "Main category",
            "type_data": {}
        },
        {
            "breadcrumbs": [
                {
                    "node_id": 1,
                    "title": "Main category",
                    "node_type_id": "Category"
                }
            ],
            "description": "",
            "display_in_list": true,
            "display_order": 1,
            "node_id": 2,
            "node_name": null,
            "node_type_id": "Forum",
            "parent_node_id": 1,
            "title": "Main forum",
            "type_data": {
                "allow_poll": true,
                "allow_posting": true,
                "can_create_thread": true,
                "can_upload_attachment": true,
                "discussion_count": 0,
                "last_post_date": 0,
                "last_post_id": 0,
                "last_post_username": "",
                "last_thread_id": 0,
                "last_thread_prefix_id": 0,
                "last_thread_title": "",
                "message_count": 0,
                "min_tags": 0,
                "require_prefix": false
            }
        },
        {
            "breadcrumbs": [
                {
                    "node_id": 1,
                    "title": "Main category",
                    "node_type_id": "Category"
                },
                {
                    "node_id": 2,
                    "title": "Main forum",
                    "node_type_id": "Forum"
                }
            ],
            "description": "",
            "display_in_list": true,
            "display_order": 1,
            "node_id": 4,
            "node_name": null,
            "node_type_id": "Forum",
            "parent_node_id": 2,
            "title": "my forums1",
            "type_data": {
                "allow_poll": true,
                "allow_posting": true,
                "can_create_thread": true,
                "can_upload_attachment": true,
                "discussion_count": 0,
                "last_post_date": 0,
                "last_post_id": 0,
                "last_post_username": "",
                "last_thread_id": 0,
                "last_thread_prefix_id": 0,
                "last_thread_title": "",
                "message_count": 0,
                "min_tags": 0,
                "require_prefix": false
            }
        },
        {
            "breadcrumbs": [],
            "description": "",
            "display_in_list": true,
            "display_order": 2,
            "node_id": 5,
            "node_name": null,
            "node_type_id": "Category",
            "parent_node_id": 0,
            "title": "Perfect",
            "type_data": {}
        },
        {
            "breadcrumbs": [
                {
                    "node_id": 5,
                    "title": "Perfect",
                    "node_type_id": "Category"
                }
            ],
            "description": "",
            "display_in_list": true,
            "display_order": 2,
            "node_id": 3,
            "node_name": null,
            "node_type_id": "Forum",
            "parent_node_id": 5,
            "title": "ahmed",
            "type_data": {
                "allow_poll": true,
                "allow_posting": true,
                "can_create_thread": true,
                "can_upload_attachment": true,
                "discussion_count": 0,
                "last_post_date": 0,
                "last_post_id": 0,
                "last_post_username": "",
                "last_thread_id": 0,
                "last_thread_prefix_id": 0,
                "last_thread_title": "",
                "message_count": 0,
                "min_tags": 0,
                "require_prefix": false
            }
        },
        {
            "breadcrumbs": [],
            "description": "",
            "display_in_list": true,
            "display_order": 3,
            "node_id": 6,
            "node_name": null,
            "node_type_id": "Forum",
            "parent_node_id": 0,
            "title": "autoit",
            "type_data": {
                "allow_poll": true,
                "allow_posting": true,
                "can_create_thread": true,
                "can_upload_attachment": true,
                "discussion_count": 0,
                "last_post_date": 0,
                "last_post_id": 0,
                "last_post_username": "",
                "last_thread_id": 0,
                "last_thread_prefix_id": 0,
                "last_thread_title": "",
                "message_count": 0,
                "min_tags": 0,
                "require_prefix": false
            }
        },
        {
            "breadcrumbs": [
                {
                    "node_id": 6,
                    "title": "autoit",
                    "node_type_id": "Forum"
                }
            ],
            "description": "",
            "display_in_list": true,
            "display_order": 3,
            "node_id": 8,
            "node_name": null,
            "node_type_id": "Forum",
            "parent_node_id": 6,
            "title": "examples",
            "type_data": {
                "allow_poll": true,
                "allow_posting": true,
                "can_create_thread": true,
                "can_upload_attachment": true,
                "discussion_count": 0,
                "last_post_date": 0,
                "last_post_id": 0,
                "last_post_username": "",
                "last_thread_id": 0,
                "last_thread_prefix_id": 0,
                "last_thread_title": "",
                "message_count": 0,
                "min_tags": 0,
                "require_prefix": false
            }
        },
        {
            "breadcrumbs": [
                {
                    "node_id": 6,
                    "title": "autoit",
                    "node_type_id": "Forum"
                },
                {
                    "node_id": 8,
                    "title": "examples",
                    "node_type_id": "Forum"
                }
            ],
            "description": "",
            "display_in_list": true,
            "display_order": 3,
            "node_id": 9,
            "node_name": null,
            "node_type_id": "Forum",
            "parent_node_id": 8,
            "title": "GUI",
            "type_data": {
                "allow_poll": true,
                "allow_posting": true,
                "can_create_thread": true,
                "can_upload_attachment": true,
                "discussion_count": 0,
                "last_post_date": 0,
                "last_post_id": 0,
                "last_post_username": "",
                "last_thread_id": 0,
                "last_thread_prefix_id": 0,
                "last_thread_title": "",
                "message_count": 0,
                "min_tags": 0,
                "require_prefix": false
            }
        },
        {
            "breadcrumbs": [
                {
                    "node_id": 6,
                    "title": "autoit",
                    "node_type_id": "Forum"
                },
                {
                    "node_id": 8,
                    "title": "examples",
                    "node_type_id": "Forum"
                }
            ],
            "description": "",
            "display_in_list": true,
            "display_order": 31,
            "node_id": 10,
            "node_name": null,
            "node_type_id": "Forum",
            "parent_node_id": 8,
            "title": "windowEX",
            "type_data": {
                "allow_poll": true,
                "allow_posting": true,
                "can_create_thread": true,
                "can_upload_attachment": true,
                "discussion_count": 0,
                "last_post_date": 0,
                "last_post_id": 0,
                "last_post_username": "",
                "last_thread_id": 0,
                "last_thread_prefix_id": 0,
                "last_thread_title": "",
                "message_count": 0,
                "min_tags": 0,
                "require_prefix": false
            }
        },
        {
            "breadcrumbs": [],
            "description": "",
            "display_in_list": true,
            "display_order": 4,
            "node_id": 7,
            "node_name": null,
            "node_type_id": "Category",
            "parent_node_id": 0,
            "title": "vbs",
            "type_data": {}
        }
    ]
}

 

Share this post


Link to post
Share on other sites

@MesterPerfect

you can visit this thread to know how to use the json in autoit

 

 

 can help you if your forum have at max 2 sec

i mean

main forum / sub

because you can do that using the 2d array

but am sorry i can not do more

i hope any one here can help you

i

Share this post


Link to post
Share on other sites

So far nobody helped so either your question is not clear or you have not shown effort what you tried.

Your question seems to be create a treeview in a json similar layout and details should be shown out of an array.

If thats the question just 

Take example in help file or search forum for treeview.

Show what you tried and you will get more help and suggestions.

Share this post


Link to post
Share on other sites
22 hours ago, junkew said:

Show what you tried and you will get more help and suggestions.

;;; i will try explaying to you what i need in this example
#include <GUIConstants.au3>
Dim $arrayInfos[9][5]
$h_myTreeGUI = GUICreate("treeview", 240, 200)
$h_myTreeCTRL = GUICtrlCreateTreeView(20, 10, 200, 90)
$h_Item1 = GUICtrlCreateTreeViewItem("Windows forums", $h_myTreeCTRL)
$h_Item2 = GUICtrlCreateTreeViewItem("android forums", $h_myTreeCTRL)
$h_Item3 = GUICtrlCreateTreeViewItem("autoit development forums", $h_myTreeCTRL)
$h_SubItem1 = GUICtrlCreateTreeViewItem("softwares", $h_Item1)
$h_SubItem2 = GUICtrlCreateTreeViewItem("corses", $h_Item1)
$h_SubItem1Child1 = GUICtrlCreateTreeViewItem("download and upload", $h_SubItem1)
$h_SubItem1Child2 = GUICtrlCreateTreeViewItem("files recovry", $h_SubItem1)
$h_SubItem1Child3 = GUICtrlCreateTreeViewItem("internet download manager", $h_SubItem1Child1)
$h_SubItem1Child4 = GUICtrlCreateTreeViewItem("free download manager", $h_SubItem1Child1)
$h_SubItem1Child5 = GUICtrlCreateTreeViewItem("Recova", $h_SubItem1Child2)
$h_SubItem2 = GUICtrlCreateTreeViewItem("free apk", $h_Item2)
$h_SubItem3 = GUICtrlCreateTreeViewItem("autoit questions", $h_Item3)
$h_SubItem3Chiled1 = GUICtrlCreateTreeViewItem("GUI questions", $h_SubItem3)
$h_SubItem3Chiled2 = GUICtrlCreateTreeViewItem("consol Questions", $h_SubItem3)
#cs
 now what i need is to stoc this in array or any thing that allow me to get the data
because i have some sub infos
such as any forum must have data
e.g
number of threads
last post
type
etc...
this is just example
because the forums that i have is in json encoded
for that i can not use an variable in evry item
because i not know how much of variables that i have
i hope that you get what i need to
#ce

GUISetState()
While 1
    Switch GUIGetMsg()
        Case $GUI_event_close
            Exit
    EndSwitch
WEnd

 

Edited by Jos
No need to quote whole posts when not required :)

Share this post


Link to post
Share on other sites

Hi,

Here is an example of how you can do it:

 

#include <GUIConstants.au3>
#include <GuiTreeView.au3>


$h_myTreeGUI = GUICreate("treeview", 540, 500)
Global $h_myTreeCTRL = GUICtrlCreateTreeView(20, 10, 500, 290)
$Input1 = GUICtrlCreateInput("", 24, 311, 491, 21)
$Input2 = GUICtrlCreateInput("", 24, 337, 491, 21)
$Input3 = GUICtrlCreateInput("", 24, 364, 491, 21)
$Input4 = GUICtrlCreateInput("", 24, 394, 491, 21)
$Input5 = GUICtrlCreateInput("", 24, 421, 491, 21)
$Input6 = GUICtrlCreateInput("", 26, 450, 491, 21)

Global $a_Cat[100][2]
Global $a_Sub[200][3]
Global $a_Dat[200][7]

$a_Cat[0][0] = 0
$a_Sub[0][0] = 0
$a_Dat[0][0] = 0

AddLV_folder("", "Windows forums", 0)
AddLV_folder("", "android forums", 0)
AddLV_folder("", "autoit development forums", 0)


AddLV_folder("Windows forums", "softwares", 4)
AddLV_folder(4, "download and upload", 5)
AddLV_folder(4, "files recovry", 6)
AddLV_folder("Windows forums", "corses", 7)

AddLV_folder("android forums", "free apk", 8)

AddLV_folder("autoit development forums", "autoit questions", 9)
AddLV_folder(9, "GUI questions", 10)
AddLV_folder(9, "consol Questions", 11)


AddLV_Info(5,"internet download manager","internet_download manager.exe","c:\Progs\IDM\","www.test.com","Downloadmanager by Asd Fghi")
AddLV_Info(5,"free download manager","free download manager.exe","c:\Progs\FDM\","https://www.freedownloadmanager.org/","Best download manager")
AddLV_Info(6,"Recuva","Recuva.exe","c:\Progs\Recuva\","https://www.ccleaner.com/recuva","Recover deleted files")
AddLV_Info(222,"Test","test.exe","c:\test\","https://www.test.com/","Test entry for the top level data info")

Func AddLV_folder($cat_or_id, $name, $idnr)
    ;Call this function to add folder type items
    ;
    ;If $cat_or_id is empty, it will automatically create a top/root level item
    ;If $cat_or_id has a name, then the new item will be added too previously created root level item
    ;If $cat_or_id is a number, then the new item will be added to a previously created subitem
    ;
    ;$idnr - make sure that this is an unique number, it will be used to add to the subfolders
    ;$idnr is not used for the root items, use names for them instead
    ;
    ;$name = display name on the treeview

    Local $x, $found = -1, $foundId = 0, $tmp = 0, $t

    If IsNumber($cat_or_id) Then
        CW("number = " & $cat_or_id)
        For $x = 1 To $a_Sub[0][0]                        ;Search for the subcategory number
            If $cat_or_id = $a_Sub[$x][2] Then
                $found = $x
                $foundId = $a_Sub[$x][1]
                ExitLoop
            EndIf
        Next
    Else                                                 ;Search for the category name

        For $x = 1 To $a_Cat[0][0]
            If $cat_or_id = $a_Cat[$x][0] Then
                $found = $x
                $foundId = $a_Cat[$x][1]
                ExitLoop
            EndIf
        Next
    EndIf

    If $found > 0 Then
        $a_Sub[0][0] = $a_Sub[0][0] + 1        ;Place the Count of the categories into $a_Cat[0][0]
        Local $t = $a_Sub[0][0]
        $a_Sub[$t][0] = $name
        $a_Sub[$t][1] = GUICtrlCreateTreeViewItem($name, $foundId)
        $a_Sub[$t][2] = $idnr
        $t=$a_Sub[$t][1]
    Else
        $a_Cat[0][0] = $a_Cat[0][0] + 1       ;Place the Count of the categories into $a_Cat[0][0]
        Local $t = $a_Cat[0][0]
        $a_Cat[$t][0] = $name
        $a_Cat[$t][1] = GUICtrlCreateTreeViewItem($name, $h_myTreeCTRL)
        $t=$a_Cat[$t][1]
    EndIf

    GUICtrlSetState(-1, $GUI_DEFBUTTON)
    _GUICtrlTreeView_SetIcon($h_myTreeCTRL, $t, "shell32.dll", 4)
EndFunc   ;==>AddLV_folder

Func AddLV_Info($idnr, $name, $i1, $i2 = "", $i3 = "", $i4 = "")
    ;$IdNr - to which subcategory should the info be added
    ;if subcategory is not found, the new item will be created at the root level

    Local $tmp, $found = -1, $foundId
    For $x = 1 To $a_Sub[0][0]
        If $idnr = $a_Sub[$x][2] Then
            $foundId = $a_Sub[$x][1]
            $found = 1
            ExitLoop
        EndIf
    Next
    If $found < 0 Then
        $foundId = $h_myTreeCTRL
    EndIf

    $a_Dat[0][0] = $a_Dat[0][0] + 1
    $tmp = $a_Dat[0][0]
    $a_Dat[$tmp][1] = $name
    $a_Dat[$tmp][2] = GUICtrlCreateTreeViewItem($name, $foundId)
    $a_Dat[$tmp][3] = $i1
    $a_Dat[$tmp][4] = $i2
    $a_Dat[$tmp][5] = $i3
    $a_Dat[$tmp][6] = $i4
    _GUICtrlTreeView_SetIcon($h_myTreeCTRL, $a_Dat[$tmp][2], "shell32.dll", 1)
EndFunc   ;==>AddLV_Info

GUISetState()

While 1
    $gmsg=GUIGetMsg()
    Switch $gmsg
        Case $GUI_event_close
            Exit
        Case Else
            for $x=1 to $a_Dat[0][0]
                If $gmsg=$a_Dat[$x][2] Then
                    GUICtrlSetData ($Input1,$a_Dat[$x][1])                          ;this line is used internaly (LV item name)
                    GUICtrlSetData ($Input2,$a_Dat[$x][2])                          ;this line is used internaly (LV item id)
                    GUICtrlSetData ($Input3,$a_Dat[$x][3])  ;The actual info starts here
                    GUICtrlSetData ($Input4,$a_Dat[$x][4])
                    GUICtrlSetData ($Input5,$a_Dat[$x][5])
                    GUICtrlSetData ($Input6,$a_Dat[$x][6])
                EndIf
            Next
    EndSwitch
WEnd

Func CW($txt)
    ConsoleWrite($txt & @CRLF)
EndFunc   ;==>CW

 

P.S. there are no array limit checks, add them if needed.

Edited by Dan_555

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By roeselpi
      hello again,
      it has been a long time since i have been here and a long time since i last used autoit. ever so often when the time allows me to, then i follow up on an idea that i had a long time ago. i have done all the work on paper but now it is up to writing it in autoit and i keep stumbling over many little issues here and there. sometimes after a few days i will try again and get a step further but sometimes it just will not help no matter how long i try and think about a solution. for most of you it will be the basics but for me it is not all that easy, but at least i give it a try.
      right, down to business:
      here is my code:
      #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <Array.au3> #include <String.au3> ; ; PART 1: define replacements and check with msgbox ; Global $y, $z $y = "Yes" $z = "No" MsgBox(0,"replacements", $y & @CRLF & $z) ;the replacements in a message box ; ; PART 2: set the texts and check via console and msgbox ; Global $my1string = "abab" ;the first specified text MsgBox(0,"my1string", $my1string) ;the message box to output the first specified text Global $my2string = "icic" ;the second specified text MsgBox(0,"my2string", $my2string) ;the message box to output the second specified text ; ; PART 3: transform the strings to individual arrays ; $my1array = StringSplit($my1string, "") $my1array[0] = "" _ArrayDelete($my1array, 0) _ArrayDisplay($my1array, "my1array") ;the display of the first specified array $my2array = StringSplit($my2string, "") $my2array[0] = "" _ArrayDelete($my2array, 0) _ArrayDisplay($my2array, "my2array") ;the display of the first specified array ; ; PART 4: create an empty array for filling ; Global $OutputArray[4] $OutputArray[0] = "" _ArrayDisplay($OutputArray, "OutputArray") ;the display of the first specified array ; ; PART 5: compare & fill empty OutputArray with data after evaluation ; Global $i, $j, $k For $i = 0 to UBound($my1array) -1 For $j = 0 to UBound($my2array) -1 For $k = 0 to UBound($OutputArray) -1 If $my1array[$i] = "a" And $my2array[$j] = "i" Then $OutputArray[$k] = $y Else $OutputArray[$k] = $z EndIf Next Next Next _ArrayDisplay($OutputArray, "OutputArray") ;the display of the Newly filled Array In "Part 2" i make a string that is converted to an array in "Part 3" ... Now, I know that "a" and "i" are always in the exact same spot in both arrays and so i wanted to compare this and make a further array to document my findings by saying "yes" or "no" ... however my new array keeps saying just "no" allthough i can clearly see and know that it should say:
      yes no yes no my guess is that there is something wrong within my for-loops and that the counting is somehow "off" i guess that when the first for-loop is finished it reaches the second whilst the second for-loop is checking the first which would explain why it always says "no" instead of seeing the obvious.
      so my question would be: what is wrong with my for-loop? or where am i making an error that ultimately gives me the wrong results?
      help is much appreciated.
      kind regards
      roeselpi
       
       
      PS: sorry for my not so great english spelling ... stupid german sitting here trying out intermediate english skills.
    • By paw
      I use SetSoundDevice to control my audio devices but the UI was either
       
      blurry like this:
      or unusable like this:

      so I made this horrible thing to add scaling to the GUI:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_HiDpi=y #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/sf /sv /rm #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <File.au3> ;~ _convertGUI("") If $CmdLine[0] <> 0 Then _convertGUI($CmdLine[1]) Func _convertGUI($sFilePath) If $sFilePath <> "" Then Local $aArray = FileReadToArray($sFilePath) Else ;TEST DATA Local $aArray[6] = ['$H_Res_Language = GUICtrlCreateProgress(5, 120, 210 + 25, 480, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE)) ; $CBS_DROPDOWNLIST)', _ 'Local $h_Ok = GUICtrlCreateButton("Ok", 72, 224, 81, 33, 0)', _ 'GUICreate($Warning_TiTle, 700, 310, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MINIMIZEBOX)', _ 'GUICtrlCreateLabel("Output type: ", 30, 130, 65, 20) ;, $SS_RIGHT)', _ '$H_FieldNameEdit = GUICtrlCreateEdit($INP_FieldNameEdit, 100,260+25, 500, 150 - 25) ;comment', 'Local $H_CANCEL = GUICtrlCreateGraphic("Cancel", 224, 224, 97, 33, 0)'] EndIf Local $hTimer = TimerInit(), $iGUIElementCount = 0, $sResult = "", $sFileName = "", $sDrive = "", $sDir = "", $sExtension = "" If @Compiled Then _PathSplit($sFilePath, $sDrive, $sDir, $sFileName, $sExtension) $sFileName = StringRegExpReplace($sFilePath, "^.*\\", "") EndIf For $i = 0 To (UBound($aArray) - 1) If StringRegExp($aArray[$i], "GUICtrlCreate|GUICreate") Then $sResult = _splitComma($aArray[$i]) If Not @error Then $aArray[$i] = $sResult $iGUIElementCount += 1 EndIf Next ConsoleWrite("t = " & TimerDiff($hTimer) & " GUI elements = " & $iGUIElementCount & " lines = " & (UBound($aArray) - 1) & @CRLF) If $sFileName <> "" Then Local $hFile = FileOpen("edited." & $sFileName, 2) _FileWriteFromArray("edited." & $sFileName, $aArray) FileClose($hFile) EndIf Exit EndFunc ;==>_convertGUI Func _splitComma($sString) Local $sSplitResult = "", $sTrimmedR = "", $sTrimmedL = "" Local $aSplit = StringSplit($sString, ',') If Not @error Then $sTrimmedR = "" $sTrimmedL = "" For $j = 1 To $aSplit[0] If StringRegExp($aSplit[1], "(?:.GUICtrlCreateGraphic|GUICtrlCreateProgress|GUICtrlCreateSlider|GUICtrlCreateTab|GUICtrlCreateTreeView)") Then If $j = 1 Then While StringLeft($aSplit[$j], 1) <> '(' $sTrimmedL &= StringLeft($aSplit[$j], 1) $aSplit[$j] = StringTrimLeft($aSplit[$j], 1) WEnd $aSplit[$j] = StringTrimLeft($aSplit[$j], 1) EndIf EndIf If $j = $aSplit[0] Then While StringRight($aSplit[$j], 1) <> ')' $sTrimmedR &= StringRight($aSplit[$j], 1) $aSplit[$j] = StringTrimRight($aSplit[$j], 1) WEnd $aSplit[$j] = StringTrimRight($aSplit[$j], 1) EndIf If StringRegExp($aSplit[$j], "[0-9]") And $aSplit[$j] <> -1 And $aSplit[$j] <> 0 And $aSplit[$j] <> 1 And Not StringInStr($aSplit[$j], ')') Then If StringRegExp($aSplit[$j], "\-|\+") Then ;put parenthesis around + or - $aSplit[$j] = '(' & $aSplit[$j] & ")*$g_DPI" Else $aSplit[$j] = $aSplit[$j] & "*$g_DPI" EndIf EndIf If $j < $aSplit[0] Then $sSplitResult &= $aSplit[$j] & ',' ElseIf $j = $aSplit[0] Then $sSplitResult &= $aSplit[$j] & ')' Else $sSplitResult &= $aSplit[$j] EndIf Next If $sTrimmedR <> "" Then $sSplitResult &= StringReverse($sTrimmedR) If $sTrimmedL <> "" Then $sSplitResult = $sTrimmedL & '(' & $sSplitResult Else SetError(1) Return EndIf ConsoleWrite($sSplitResult & @CRLF) Return $sSplitResult EndFunc ;==>_splitComma
      And now it looks good: 
      but it doesn't work on everything, for example the "GUICtrlCreateLabel("Output type: ", 30, 130, 65, 20) ;, $SS_RIGHT)" (from the autoit3wrapper gui)
      because the comment contains a parenthesis and it would break completely if there were variables as parameters..
      Is there some kind of parser around that I could use instead or maybe someone who has already done something like this?
    • By TXTechie
      Hello Everyone,
      I've developed my own GUI using AutoIt and I'm allowing users to minimize the GUI, but I also want to include some kind of timer so that it will automatically restore the GUI after something like 30 minutes or an hour. However, I also want them to be able to manually restore the GUI by clicking the application's icon in the taskbar.
      I've searched through the forums, but I'm not sure how to get started.
      Any ideas or functions to research are appreciated!
      Regards,
      TX Techie
    • By jcpetu
      Hi people, I'm trying to dynamically populate a TreeView based on a script from Water that I modified for my needs. but I can't figured it out how to make it work.
      Here what I have in case anyone can help me, thanks in advance:
      #include <array.au3> #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> Local $aTV1[14][3] = [ _ ['1', 'Text 1', -1], _ ;-1 idicates it's an index item ['2', 'Text 2',-1], _ ['3', 'Text 3',-1], _ ['1-1', 'Text 1-1',0], _ ['1-2', 'Text 1-2',0], _ ['2-1', 'Text 2-1',0], _ ['2-2', 'Text 2-2',0], _ ['2-1-1', 'Text 2-1-1',0], _ ['2-1-2', 'Text 2-1-2',0], _ ['2-1-2-1', 'Text 2-1-2-1',0], _ ['2-1-2-1-1', 'Text 2-1-2-1-1',0], _ ['3-1', 'Text 3-1',0], _ ['3-1-1', 'Text 3-1-1',0], _ ['3-1-1-1', 'Text 3-1-1-1',0]] ;_ArrayDisplay($aTV1) Local $Gui = GUICreate('TreeView Example', 500, 600) Local $tv = GUICtrlCreateTreeView(10, 30, 450, 550) GUISetState() _pop_treeview($tv, $aTV1) While 1 Switch GUIGetMsg() Case $gui_event_close Exit EndSwitch WEnd Func _pop_treeview($hTV, $array) Local $TimeInitial = TimerInit(), $Hours, $Mins, $Secs, $item _ArraySort($array, 0, 0, 0, 0) ;------------------------- sort Ascending on column 0 ;_ArrayDisplay($array) $idxroot = _GUICtrlTreeView_Add($hTV, 0, "index") For $i = 0 To UBound($array) - 1 ConsoleWrite("$array[" & $i & "][" & 0 & "] = " & $array[$i][0] & @CRLF) If $array[$i][0] = '' Then ExitLoop ;--------------- Exit at first empty element $item = '' If $array[$i][2] = -1 Then ;------------------------ Add root element _GUICtrlTreeView_AddChild($hTV, $idxroot, $array[$i][1]) Else $item = StringLeft($array[$i][0], StringInStr($array[$i][0], "-", 1, -1) - 1) ConsoleWrite("$item = " & $item & @CRLF) $Found = _ArrayBinarySearch($array, $item, 0, 0, 0) ;search on column 0 Switch $Found Case 0 ;----------------------------------- Value wasn't found in array ConsoleWrite("Item NOT found @error= " & @error & @CRLF) Case Else ConsoleWrite("Item found " & @CRLF) _GUICtrlTreeView_AddChild($hTV, $Found, $array[$i][1]) EndSwitch EndIf Next _GUICtrlTreeView_Expand($hTV) EndFunc ;==>_pop_treeview  
    • By Jangal
      Hello friends
      This app is slow
      How to increase its speed?
       
      #include <Array.au3> #include <StringConstants.au3> #include <File.au3> #include <String.au3> Global $aWord[][2]  = [[1, "google"],[2,"hello"]]


        Global $sFileName = @ScriptDir & "\1.txt" ; 2MB Text File Local $sFileRead = FileRead($sFileName) Local $res = StringRegExp($sFileRead, "(*UCP)\b[\pL\d]{2,}", 3) _ArrayDisplay($res)   for $sWord in $res     $iIndex = _ArraySearch($aWord, $sWord, 0, 0, 0, 0, 1, 2)     ;MsgBox(0,0,$iIndex)     if $iIndex == -1 Then         Local $aFill = [[0,$sWord]]         _ArrayAdd($aWord,$aFill)        ;      Else         $aWord[$iIndex][0] +=1     EndIf   Next _ArrayDisplay($aWord)

      1.txt
×
×
  • Create New...