Sign in to follow this  
Followers 0
vladinator

Folder listing for WoW accounts (my small project...)

5 posts in this topic

#1 ·  Posted (edited)

I am working on some code to make it easier to copy a profile from one character to another trough a AutoIT script.

Even if you don't play World of Warcraft, you can probably help me with the coding issue I got in my source below:

(ctrl+f and find "the issue" if you have problems finding my problem)

#include <GUIConstants.au3>
#include <Array.au3>

; Check if WoW is installed trough the registry
Global $WoWInstall = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Blizzard Entertainment\World of Warcraft", "InstallPath")
Global $FolderName = $WoWInstall & "\WTF\Account"
Dim $Folders[1]

If $WoWInstall Then
    
; Get folder names
    Local $Search
    Local $File
    Local $FileAttributes
    Local $FullFilePath
    $Search = FileFindFirstFile($FolderName & "\*.*")
    While 1
        If $Search = -1 Then
            ExitLoop
        EndIf
        $File = FileFindNextFile($Search)
        If @error Then ExitLoop
        $FullFilePath = $FolderName & "\" & $File
        $FileAttributes = FileGetAttrib($FullFilePath)
        If StringInStr($FileAttributes,"D") Then
            _ArrayAdd($Folders,$File)
        EndIf

    WEnd
    FileClose($Search)

; List them in a listbox (gui)
    GUICreate("Account Listing", 320,150,-1,-1)
    $close = GUICtrlCreateButton("Exit", 15,20,72,25)
    $mylist = GUICtrlCreateList("", 100,20,200,100)
    GUICtrlSetLimit(-1,200)

; the issue
    GUICtrlSetData(-1,$Folders[1])
    GUICtrlSetData(-1,$Folders[2])
    GUICtrlSetData(-1,$Folders[3])
    GUICtrlSetData(-1,$Folders[4])
    GUICtrlSetData(-1,$Folders[5])
;but if the folders that are scanned are more than the numbers I type, it crashes
;if so I need some function to list all from 1-# (# = number of the total folders that are in the array, summed up)
;at the moment, it only lists 5 folders max, if you got less than 5 folders it will give a error and exit...

    GUISetState ()
    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
             Case $msg = $close
                Exit
        EndSelect
    WEnd
    
Else
    MsgBox(48, "Error", "World of Warcraft was not found in the registry. Is the game installed?")
    Exit
EndIf

I am not a professional coder so there is probably going to be a lot of tweaking I could have done to make the program work even smoother but for now I am unable to do so. I guess you do need practical knowledge.. books wont help you learn some things. :)

If you wonder about my project, it is about making character profiles copying easier.. from one character to the other. Many people are not able to work with files, so to help them I am trying to work something out. Thinking about making the GUI quite easy to use for anyone, with some few steps.

1 = Select the account you are going to work with (the code above)

2 = Select the realm and then the character you will copy from

3 = Select the realm and then the character you will copy to

Based on character and realm picking, I will put in another code to open up each .lua (config file) that just got copied from the "main" to the "alt" character, then rename old realm name to the new realm name as well as the old character name to the new character name.

At least that's how far I have thought about this. :P

Edited by VRor

Share this post


Link to post
Share on other sites



I've been looking through your code and it looks pretty "clean" to me - it should work as intended ... but ...

What to do for a start: replace all your GUI part (which seem to create problems) with a simple _ArrayDisplay and see what results you get - if all the files are listed in your _ArrayDisplay then you will know where the problem is (in the GUI) so you will be able to find a solution.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

The problem is that I can't have these:

GUICtrlSetData(-1,$Folders[1])

GUICtrlSetData(-1,$Folders[2])

GUICtrlSetData(-1,$Folders[3])

GUICtrlSetData(-1,$Folders[4])

GUICtrlSetData(-1,$Folders[5])

I would need something similar to this (I would guess):

For $i = 1 to $m Step 1
    GUICtrlSetData(-1,$Folders[$i])
Next

"$i = 1" because 0 is nothing in our array, it starts at 1.

"to $m" the thing I need help with. $m needs to get the number of arrays (since it depends on the person using the program, he might have 5 accounts, or 9 accounts stored in the Account directory so this needs to actually get the folder count/array count and use that as a number for the "max" value in the *For* code)

So if the user got 6 accounts, * $m = "6" *. If 8 accounts, * $m = "8" * :)

I hope I express myself the correct way here. :P

Edited by VRor

Share this post


Link to post
Share on other sites

The problem is that I can't have these:

GUICtrlSetData(-1,$Folders[1])

GUICtrlSetData(-1,$Folders[2])

GUICtrlSetData(-1,$Folders[3])

GUICtrlSetData(-1,$Folders[4])

GUICtrlSetData(-1,$Folders[5])

I would need something similar to this (I would guess):

For $i = 1 to $m Step 1
    GUICtrlSetData(-1,$Folders[$i])
Next

"$i = 1" because 0 is nothing in our array, it starts at 1.

"to $m" the thing I need help with. $m needs to get the number of arrays (since it depends on the person using the program, he might have 5 accounts, or 9 accounts stored in the Account directory so this needs to actually get the folder count/array count and use that as a number for the "max" value in the *For* code)

So if the user got 6 accounts, * $m = "6" *. If 8 accounts, * $m = "8" * :)

I hope I express myself the correct way here. :P

For $i = 1 to ubound($Folders)-1 Step 1
    GUICtrlSetData(-1,$Folders[$i])
Next

it think this works


[font="Impact"]Never fear, I is here.[/font]

Share this post


Link to post
Share on other sites

For $i = 1 to ubound($Folders)-1 Step 1
    GUICtrlSetData(-1,$Folders[$i])
Next

it think this works

Thank you Alek, it did work without a flaw. Guess this topic is done, I will make a new one if I encounter a issue I can't solve within 6 hours of self searching. :)

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