Jump to content

How can i clean my GUI code


sliwek
 Share

Recommended Posts

i have lots labels and think how can i sort or rename or recount all names in gui

$Tabsheet1 = GUICtrlCreateTabItem("..")
$InfoBox = GUICtrlCreateGroup("..", 72, 48, 489, 129)
$Label74 = GUICtrlCreateLabel("..", 80, 64, 516, 17)
$Label74 = GUICtrlCreateLabel("..", 80, 80, 516, 17)
$Label74 = GUICtrlCreateLabel("..", 80, 96, 516, 17)
$Label74 = GUICtrlCreateLabel("..", 80, 112, 516, 17)
$buttonNew1 = GUICtrlCreateButton("..", 80, 140, 90, 30, $WS_GROUP)
$LabelNew2 = GUICtrlCreateLabel("..", 175, 150, 100, 100)
$Label74 = GUICtrlCreateLabel("..", 80, 128, 516, 17)
$Label74 = GUICtrlCreateLabel("..", 80, 144, 516, 17)
$InfoBox = GUICtrlCreateGroup("..", 72, 188, 489, 189)
$Label74 = GUICtrlCreateLabel("..", 80, 204, 516, 17)
$Label75 = GUICtrlCreateLabel("..", 80, 220, 516, 17)
$Label76 = GUICtrlCreateLabel("..", 80, 236, 516, 17)
$Label74 = GUICtrlCreateLabel("..", 80, 253, 516, 17)
$Label74 = GUICtrlCreateLabel("..", 80, 270, 516, 17)

and i have whole my gui like that. how can i recount my Labels, InfoBoxs? its about 500 lines code

Edited by sliwek
Link to comment
Share on other sites

What I usually do is use an array for my gui elements, like so:

$GUIArray[0] =      GUICreate("QuickCopy", 170, 510, @DesktopWidth-190, 75)
    ;BASIC DETAILS
    $GUIArray[1] =      GUICtrlCreateRadio("Product Name", 25, 25)
    $GUIArray[16] =     GUICtrlCreateCheckbox("Automate Product Code", 25, 45)
    ;PRICE DETAILS
    $GUIArray[2] =      GUICtrlCreateRadio("Final Price", 25, 90)
    ;DESCRIPTION
    $GUIArray[3] =      GUICtrlCreateRadio("Description", 25, 135)
    ;IMAGES
    $GUIArray[4] =      GUICtrlCreateRadio("Images", 25, 180) ;Copies the image URL into an array
    $GUIArray[17] =     GUICtrlCreateButton("Add URL", 100, 175)
    ;ADVANCED DETAILS
    $GUIArray[5] =      GUICtrlCreateRadio("Wholesale Price", 25, 225)
    $GUIArray[6] =      GUICtrlCreateRadio("Brand", 25, 245)
    $GUIArray[7] =      GUICtrlCreateRadio("Notes", 25, 265)
    $GUIArray[8] =      GUICtrlCreateRadio("Product Search Tags", 25, 285)
    ;POSTAGE
    $GUIArray[9] =      GUICtrlCreateRadio("Fixed Cost", 25, 330)
    ;SEARCH ENGINE OPTIMISATION
    $GUIArray[10] =     GUICtrlCreateRadio("Title", 25, 375)
    $GUIArray[11] =     GUICtrlCreateRadio("Keywords", 25, 395)
    $GUIArray[12] =     GUICtrlCreateRadio("Description", 25, 415)
    ;BUTTONS
    $GUIArray[13] =     GUICtrlCreateButton("Clear All Values", 10, 445, 150, 25)
    $GUIArray[14] =     GUICtrlCreateButton("Paste All", 10, 475, 150, 25)
    $GUIArray[15] =     GUICtrlCreateButton("Calculate", 100, 130)
    ;GROUPS
    GUICtrlCreateGroup("Basic Details",                 10,     10,     150,    60)
    GUICtrlCreateGroup("Price Details",                 10,     75,     150,    40)
    GUICtrlCreateGroup("Description",                    10,        120,    150,    40)
    GUICtrlCreateGroup("Images",                        10,     165,    150,    40)
    GUICtrlCreateGroup("Advanced Details",              10,     210,    150,    100)
    GUICtrlCreateGroup("Postage",                       10,     315,    150,    40)
    GUICtrlCreateGroup("Search Engine Optimisation",    10,     360,    150,    80)

If you view that in notepad or the scite editor and replace each group of four spaces with a tab character, you will also notice that when creating the groups, I laid it all out neatly (but it doesnt look like it on the forums). Ofcourse, everyone does it as they like to, that is just how I do it. I do a different array for each GUI, by the way.

Edited by Mikeman27294
Link to comment
Share on other sites

You could store the ControlIds in an array. So to create and change them you could simply loop through the array.

Can you post a screenshot of the GUI you ahve so far?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

It seems you created your GUI in Koda.

You can manually assign Name property for each control in GUI directly in Koda instead of default LabelNNN.

yea at start it was in koda but i updating program for few years in SciTE script.

that my first working program in AutoIt and just wanted clean it little :)

tried back to koda but cant import gui because of labels names

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...