Jump to content
Sign in to follow this  
bleed

Problem with GUI with FileSelectFolder

Recommended Posts

bleed

Hello.

This is my first post so far, but I have been reading and learning alot about AutoIt for several weeks now. The help file, and the search feature on the forum here are simply amazing. Every time when I got a problem, I would find how to fix it, untill now.

Anyways, this GUI that I`m trying to get to run my 1st .exe that I wrote in AutoIt is giving me a real !@#$. The application I`m attending to get it to run with, is working like a clockwork, but for gui...I realy need a help.

What happens is in this part of the code, is that when I try to insert a 2nd piece of code instead of commented lines, my all tabs simply disappear, all except the first one. I have been trying to figure it on my own, but my head really hurts at this point bacause I`m trying to find a solution for the last 11 hrs.

Thanks alot for any help and/or directions you can give me.

; AutoIt 3.0.103 example
; 17 Jan 2005 - CyberSlug
; This script shows manual positioning of all controls;
;   there are much better methods of positioning...
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>

    $linex = ("comment")
    $line0 = ("comment1")
    $line1 = ("ListServer")
    $line2 = ("ListServer")
    $line3 = ("ListServer")
    $line4 = ("ListServer")
    $line5 = ("ListServer")
    $line6 = ("ListServer")
    $line7 = ("ListServer")
    $line8 = ("ListServer")
    $line9 = ("ListServer")
    $line10 = ("ListServer")
    $line11 = ("ListServer")
    $line12 = ("ListServer")
    $line13 = ("ListServer")
    $line14 = ("ListServer")
    $line15 = ("ListServer")
    $line = "[MyFile]"

; GUI
    GuiCreate("Label100", 603, 400)
    GuiSetIcon(@WorkingDir & "\Label.ico", 0)
    GuiCtrlCreateTab(2, 5, 600, 295)
    GuiCtrlCreateTabItem($line1)
    GuiCtrlCreateInput("Extra Name 1", 50, 50, 130, 20)
    GuiCtrlCreateLabel("Extra 1", 4, 55)
    GuiCtrlCreateInput(" ID for Extra 1", 50, 80, 130, 20)
    GuiCtrlCreateLabel(" ID", 4, 85)
    GuiCtrlCreateInput(" PW for Extra 1", 50, 110, 130, 20)
    GuiCtrlCreateLabel(" PW", 4, 115)
    GuiCtrlCreatecombo("test", 50, 140, 130, 20)
    GUICtrlSetData(-1, "test1|test2|test3|test4|test5|test6|test7|test8|", "test")
    GuiCtrlCreateLabel("Server:", 4, 145)
    GuiCtrlCreateLabel("Select (1-4):", 4, 175)
    GuiCtrlCreatecombo("1", 140, 172, 40, 20)
    GUICtrlSetData(-1, "2|3|4", "1")
    GuiCtrlCreateLabel("Loc. 1-4:", 4, 205)
        $position1 = GuiCtrlCreateRadio("Position 1", 60, 202, 100)
        $position2 = GuiCtrlCreateRadio("Position 2", 160, 202, 100)
        $position3 = GuiCtrlCreateRadio("Position 3", 260, 202, 100)
        $position4 = GuiCtrlCreateRadio("Position 4", 360, 202, 100)
    GUICtrlSetState($position1, $GUI_CHECKED)
    GUIStartGroup()
;$patch = GuiCtrlCreateInput("Path to the File folder (not .exe)", 200, 50, 230, 20)
;$button = GUICtrlCreateButton("Browse", 450, 50, 50, 20)
    GUICtrlCreateTabItem("")
    GuiCtrlCreateLabel("General Settings:", 4, 310)
    GuiCtrlCreateLabel("Stuck protection every:", 4, 330)
        $stuckprot1 = GuiCtrlCreateRadio("15 Min.", 158, 328, 60)
        $stuckprot2 = GuiCtrlCreateRadio("30 Min.", 225, 328, 60)
        $stuckprot3 = GuiCtrlCreateRadio("45 Min.", 290, 328, 60)
        $stuckprot4 = GuiCtrlCreateRadio("60 Min.", 358, 328, 60)
        $stuckprotOff = GuiCtrlCreateRadio("OFF", 418, 328, 60)
    GUICtrlSetState($stuckprotOff, $GUI_CHECKED)
    GUIStartGroup()
    
    GuiCtrlCreateTabItem("")
    GuiCtrlCreateTabItem($line2)
    
    GuiCtrlCreateTabItem($line3)
    
    GuiCtrlCreateTabItem($line4)
    
    GuiCtrlCreateTabItem($line5)
    
    GuiCtrlCreateTabItem($line6)
    
    GuiCtrlCreateTabItem($line7)
    
    GuiCtrlCreateTabItem($line8)
    
    GuiCtrlCreateTabItem($line9)
    
    GuiCtrlCreateTabItem($line10)
    
    GuiCtrlCreateTabItem($line11)
    
    GuiCtrlCreateTabItem($line12)
    
    GuiCtrlCreateTabItem($line13)
    
    GuiCtrlCreateTabItem($line14)
    
    GuiCtrlCreateTabItem($line15)
    
    GuiCtrlCreateTabItem("")
    GuiSetState()
    While GuiGetMsg() <> $GUI_EVENT_CLOSE
    WEnd

#2nd part

$Label1 = GUICtrlCreateLabel("File name:", 200, 50, 230, 20)
    $patch = GuiCtrlCreateInput("Path to the SBot folder for this Char (not .exe)", 200, 50, 230, 20)
    $button = GUICtrlCreateButton("Browse", 450, 50, 50, 20)
    GUISetState()
    While 1
        $Msg = GUIGetMsg()
        If $button = $Msg Then
            $message = "Chose a file"
            $var = FileSelectFolder ($message, "" & "\", "", 1 + 1)
            If @error Then
                MsgBox(4096, "", "No File(s) chosen")
            Else
                $var = FileGetLongName($var)
                $tmp = StringTrimLeft($var, 3)
                $tmp = StringRegExpReplace($tmp, '(?<=\\).*?(?=\\)', '...')
                $tmp = StringLeft($var, 3) & $tmp
                GUICtrlSetData($patch, $tmp)
            EndIf
        EndIf
        If $Msg = $GUI_EVENT_CLOSE Then Exit
    WEnd

Share this post


Link to post
Share on other sites
Authenticity

; AutoIt 3.0.103 example
; 17 Jan 2005 - CyberSlug
; This script shows manual positioning of all controls;
;   there are much better methods of positioning...
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>

$linex = ("comment")
$line0 = ("comment1")
$line1 = ("ListServer")
$line2 = ("ListServer")
$line3 = ("ListServer")
$line4 = ("ListServer")
$line5 = ("ListServer")
$line6 = ("ListServer")
$line7 = ("ListServer")
$line8 = ("ListServer")
$line9 = ("ListServer")
$line10 = ("ListServer")
$line11 = ("ListServer")
$line12 = ("ListServer")
$line13 = ("ListServer")
$line14 = ("ListServer")
$line15 = ("ListServer")
$line = "[MyFile]"

; GUI
$hGUI = GUICreate("Label100", 603, 400)
GUISetIcon(@WorkingDir & "\Label.ico", 0)
GUICtrlCreateTab(2, 5, 600, 295)
$TabItem1 = GUICtrlCreateTabItem($line1)
GUICtrlCreateInput("Extra Name 1", 50, 50, 130, 20)
GUICtrlCreateLabel("Extra 1", 4, 55)
GUICtrlCreateInput(" ID for Extra 1", 50, 80, 130, 20)
GUICtrlCreateLabel(" ID", 4, 85)
GUICtrlCreateInput(" PW for Extra 1", 50, 110, 130, 20)
GUICtrlCreateLabel(" PW", 4, 115)
GUICtrlCreateCombo("test", 50, 140, 130, 20)
GUICtrlSetData(-1, "test1|test2|test3|test4|test5|test6|test7|test8|", "test")
GUICtrlCreateLabel("Server:", 4, 145)
GUICtrlCreateLabel("Select (1-4):", 4, 175)
GUICtrlCreateCombo("1", 140, 172, 40, 20)
GUICtrlSetData(-1, "2|3|4", "1")
GUICtrlCreateLabel("Loc. 1-4:", 4, 205)
$position1 = GUICtrlCreateRadio("Position 1", 60, 202, 100)
$position2 = GUICtrlCreateRadio("Position 2", 160, 202, 100)
$position3 = GUICtrlCreateRadio("Position 3", 260, 202, 100)
$position4 = GUICtrlCreateRadio("Position 4", 360, 202, 100)
GUICtrlSetState($position1, $GUI_CHECKED)
GUIStartGroup()
;$patch = GuiCtrlCreateInput("Path to the File folder (not .exe)", 200, 50, 230, 20)
;$button = GUICtrlCreateButton("Browse", 450, 50, 50, 20)
GUICtrlCreateTabItem("")
GUICtrlCreateLabel("General Settings:", 4, 310)
GUICtrlCreateLabel("Stuck protection every:", 4, 330)
$stuckprot1 = GUICtrlCreateRadio("15 Min.", 158, 328, 60)
$stuckprot2 = GUICtrlCreateRadio("30 Min.", 225, 328, 60)
$stuckprot3 = GUICtrlCreateRadio("45 Min.", 290, 328, 60)
$stuckprot4 = GUICtrlCreateRadio("60 Min.", 358, 328, 60)
$stuckprotOff = GUICtrlCreateRadio("OFF", 418, 328, 60)
GUICtrlSetState($stuckprotOff, $GUI_CHECKED)
GUIStartGroup()

GUICtrlCreateTabItem("")
GUICtrlCreateTabItem($line2)

GUICtrlCreateTabItem($line3)
GUICtrlCreateTabItem($line4)
GUICtrlCreateTabItem($line5)
GUICtrlCreateTabItem($line6)
GUICtrlCreateTabItem($line7)
GUICtrlCreateTabItem($line8)
GUICtrlCreateTabItem($line9)
GUICtrlCreateTabItem($line10)
GUICtrlCreateTabItem($line11)
GUICtrlCreateTabItem($line12)
GUICtrlCreateTabItem($line13)
GUICtrlCreateTabItem($line14)
GUICtrlCreateTabItem($line15)
GUICtrlCreateTabItem("")

GUISwitch($hGUI, $TabItem1)

$Label1 = GUICtrlCreateLabel("File name:", 200, 50, 230, 20)
$patch = GUICtrlCreateInput("Path to the SBot folder for this Char (not .exe)", 200, 75, 230, 20)
$button = GUICtrlCreateButton("Browse", 450, 75, 50, 20)
GUISetState()
While 1
    Switch GUIGetMsg()
        Case $button
            $message = "Choose a file"
            $var = FileSelectFolder($message, "" & "\", "", 1 + 1)
            If @error Then
                MsgBox(4096, "", "No File(s) chosen")
            Else
                $var = FileGetLongName($var)
                $tmp = StringTrimLeft($var, 3)
                $tmp = StringRegExpReplace($tmp, '(?<=\\).*?(?=\\)', '...')
                $tmp = StringLeft($var, 3) & $tmp
                GUICtrlSetData($patch, $tmp)
            EndIf
            
        Case $GUI_EVENT_CLOSE 
            ExitLoop
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
bleed

WOW! Thanx Authenticity, I see where I got stuck now. GUISwitch is the main thing I had overseen here. Is it mandatory for GUICtrlCreateInput to have GUICtrlCreateLabel assosiated with?

Thanks again ^_^

Share this post


Link to post
Share on other sites
Authenticity

It is to switch the active tab that will get the new controls.

Share this post


Link to post
Share on other sites
bleed

It is to switch the active tab that will get the new controls.

Thanks again man, You have really helped me a lot.

I just have finished the entire GUI and it`s fireing up like a charm ^_^

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  

×