Jump to content

GUICtrlCreateInput Help


Recommended Posts

I'm trying to make a game in AutoIt (Just for fun and practice) anyway I have a form that asks for username and character name then should write both to an ini file, but it only writes one to the ini file and then exits out of the program.

Any help would be awesome.

(note this is only a portion of my code if you need to see it all I can post it )

Global $fPath = @ScriptDir & "\Data\Path"


Func gamestart()

#Region ### START mm GUI section ### Form=
$mm = GUICreate("MainMenu", 238, 199, 337, 189)
$tName = GUICtrlCreateInput("", 64, 64, 113, 21)
$uName = GUICtrlCreateInput("", 64, 120, 113, 21)
GUICtrlCreateLabel("ToonName", 90, 40, 57, 17)
GUICtrlCreateLabel("UserName", 91, 96, 54, 17)
$Enter = GUICtrlCreateButton("Enter", 90, 151, 57, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END mm GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($mm)
         Case $Enter
            $iniTName = GUICtrlRead($tName)
            $iniUName = GUICtrlRead($uName)
            MsgBox(1,"test", $iniTName & @LF & $iniUName)
            DirCreate($fPath)
            IniWrite($fPath & "\" & "InFo","Name","ToonName",$iniTName)
            MsgBox(1,"","wrote" & " " & $iniTName);for debugging
            IniWrite(fPath & "\" & "InFo","Name","UserName",$iniUName)
            MsgBox(1,"","wrote" & " " & $iniUName);for debugging
EndFunc

    EndSwitch
WEnd

 

 

Edited by TwistedXion
Link to comment
Share on other sites

  • Moderators

TwistedXion,

Move the EndFunc line to after the WEnd - at the moment you end the function immediately you write the first set of ini elements.

Might I suggest installing the SciTE4AutoIt3 package (look under the "AutoIt Resources" menu) - that way you automatically get a whole slew of utilities to help you code, including Au3Check which would have picked up on this error.

M23

Edit: There is no problem with this thread as the OP has stated that the game is being created and coded in AutoIt, something which we actively encourage.

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

KickStarter15,

See my edit above.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

 

1 minute ago, Melba23 said:

TwistedXion,

Move the EndFunc line to after the WEnd - at the moment you end the function immediately you write the first set of ini elements.

Might I suggest installing the SciTE4AutoIt3 package (look under the "AutoIt Resources" menu) - that way you automatically get a whole slew of utilities to help you code, including Au3Check which would have picked up on this error.

M23

Okay, that make's sense.:D

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

5 minutes ago, Melba23 said:

TwistedXion,

Move the EndFunc line to after the WEnd - at the moment you end the function immediately you write the first set of ini elements.

1

I had actually picked up on that myself but it still terminates after the first iniwrite  

Link to comment
Share on other sites

  • Moderators

TwistedXion,

So post what you have now.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

If I need it I can post everything I have so far

but here is everything pertaining to the func and the ini file

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#RequireAdmin

Global $fPath = @ScriptDir & "\Data\Path"
gamestart()

Func gamestart()

#Region ### START mm GUI section ### Form=
$mm = GUICreate("MainMenu", 238, 199, 337, 189)
$tName = GUICtrlCreateInput("", 64, 64, 113, 21)
$uName = GUICtrlCreateInput("", 64, 120, 113, 21)
GUICtrlCreateLabel("ToonName", 90, 40, 57, 17)
GUICtrlCreateLabel("UserName", 91, 96, 54, 17)
$Enter = GUICtrlCreateButton("Enter", 90, 151, 57, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END mm GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($mm)
         Case $Enter
            $iniTName = GUICtrlRead($tName)
            $iniUName = GUICtrlRead($uName)
            MsgBox(1,"test", $iniTName & @LF & $iniUName)
            DirCreate($fPath)
            IniWrite($fPath & "\" & "InFo","Name","ToonName",$iniTName)
            Sleep(1000)
            MsgBox(1,"","wrote" & " " & $iniTName)
            IniWrite(fPath & "\" & "InFo","Name","UserName",$iniUName)
            Sleep(1000)
            MsgBox(1,"","wrote" & " " & $iniUName)


    EndSwitch
WEnd
EndFunc

 

Link to comment
Share on other sites

the msg boxes are only for debugging so I could see how far the script was getting and if it was actually getting the input or not, it's getting all the info and displaying it in the msg box it just does not write the 2ed iniwrite to the inifile but it does the 1st one 

Edited by Melba23
Removed quote
Link to comment
Share on other sites

  • Moderators

TwistedXion,

Try adding a leading $ to the path in the second IniWrite. Again a problem that would have been picked up by Au3Check (as it was for me just now)

And when you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button which just pads the thread unnecessarily.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

TwistedXion,

So go and download SciTE4AutoIt3 - it saves a lot of those kind of moments......

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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