Jump to content

Need help with my first program


 Share

Recommended Posts

Best Autoscripters,

I hope someone can help me with my script. it's going to be fun.

ahwell the code is:

#include
#include
#include
#Region ### START Koda GUI section ### Form=c:\users\tti007\desktop\test.kxf
$menu_start = GUICreate("menu_start", 153, 209, 301, 264)
$name = GUICtrlCreateButton("Name", 40, 8, 75, 25)
$race = GUICtrlCreateButton("Race", 40, 32, 75, 25)
$class = GUICtrlCreateButton("Class", 40, 56, 75, 25)
$sex = GUICtrlCreateButton("Sex", 40, 80, 75, 25)
$start = GUICtrlCreateButton("Start", 40, 120, 75, 25)
$load = GUICtrlCreateButton("Load game", 40, 168, 75, 25)
$save = GUICtrlCreateButton("Save Game", 40, 144, 75, 25)
$gold = 100
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $save
IniWrite ("U:\test.ini","section", "name", $name1)
IniWrite ("U:\test.ini","section", "class", $class1)
IniWrite ("U:\test.ini","section", "race", $race1)
IniWrite ("U:\test.ini","section", "sex", $sex1)
IniWrite ("U:\test.ini","section", "gold", $gold)
Case $load
IniRead ("U:\test.ini", "section", "name")
IniRead ("U:\test.ini", "section", "class")
IniRead ("U:\test.ini", "section", "race")
IniRead ("U:\test.ini", "section", "sex")
IniRead ("U:\test.ini", "section", "gold")
Case $race
$race1 = InputBox ("race", "Hello "&$name1 &" What is your race?")
Case $class
$class1 = InputBox ("class", "Hello "&$name1 &" What is your class?")
Case $sex
$sex1 = InputBox ("sex", "Hello "&$name1 &" What is your sex?")
Case $name
$name1 = InputBox ("hello", "What's your name?")
Case $start
#Region ### START Koda GUI section ### Form=c:\users\tti007\desktop\test2.kxf
$game = GUICreate("test", 1026, 691, 523, 269)
$statsg = GUICtrlCreateGroup("", 0, 0, 1025, 57)
$namel = GUICtrlCreateLabel("name: "&$name1, 16, 24, 75, 17)
$racel = GUICtrlCreateLabel("Race: "&$race1, 184, 24, 75, 17)
$classl = GUICtrlCreateLabel("Class: "&$class1, 368, 24, 75, 17)
$sexl = GUICtrlCreateLabel("Sex: "&$sex1, 520, 24, 75, 17)
$goldl = GUICtrlCreateLabel("Gold: "&$gold, 640, 24, 75, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$menug = GUICtrlCreateGroup("", 0, 56, 209, 633)
$menub = GUICtrlCreateButton("Menu", 64, 656, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$maing = GUICtrlCreateGroup("", 208, 56, 817, 633)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd


EndSwitch
WEnd

and my question is when i try to press the load button the program gets shutdown but that's not what i want i want the ini file to be loaded and get the information i saved.

the rest of my script works as i intented to be. except that when i press start the menu is still open but ahwell xD i can fix that later

Greetz

Link to comment
Share on other sites

  • Moderators

satanttin,

water is quite right - please read the Forum rules (the link is also at bottom right of each page) - particularly the bit about not discussing game interaction - before you post again. Thread locked. :naughty:

But welcome to the AutoIt forum - and see you soon with a legitimate question I hope. :)

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

I have contacted the OP and he has convinced me that this is code for a game he is writing in AutoIt and not interaction with a 3rd party app. As such I am reopening the thread. :)

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

water is quite right ..

Copy & paste error :bye: It's somdcomputerguy who is quite right ;)

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

>"C:Program Files (x86)AutoIt3SciTE..autoit3.exe" /ErrorStdOut "C:Userstti007Desktoptest.au3"

C:Userstti007Desktoptest.au3 (29) : ==> Incorrect number of parameters in function call.:

IniRead ("U:test.ini", "section", "name")

^ ERROR

>Exit code: 1 Time: 1.325

this is a error i get when i press load game

Link to comment
Share on other sites

You have to specify 4 parameters. The last one is the value to be returned if the key can't be found.

See the help file for details: IniRead

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

  • Moderators

satanttin,

Take a look at where this code differs from yours and see if you can work out why I have changed it: ;)

#include <GUIConstantsEx.au3>

Global $sName, $sClass, $sRace, $sSex, $iGold
Global $sIni = @ScriptDir & "\Test.ini" ; "U:\test.ini" ; You need to change this back

$hMenu_start = GUICreate("menu_start", 153, 209, 301, 264)
$cName = GUICtrlCreateButton("Name", 40, 8, 75, 25)
$cRace = GUICtrlCreateButton("Race", 40, 32, 75, 25)
$cClass = GUICtrlCreateButton("Class", 40, 56, 75, 25)
$cSex = GUICtrlCreateButton("Sex", 40, 80, 75, 25)
$cStart = GUICtrlCreateButton("Start", 40, 120, 75, 25)
$cLoad = GUICtrlCreateButton("Load game", 40, 168, 75, 25)
$cSave = GUICtrlCreateButton("Save Game", 40, 144, 75, 25)
$iGold = 100
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cSave
            IniWrite($sIni, "section", "name", $sName)
            IniWrite($sIni, "section", "class", $sClass)
            IniWrite($sIni, "section", "race", $sRace)
            IniWrite($sIni, "section", "sex", $sSex)
            IniWrite($sIni, "section", "gold", $iGold)
        Case $cLoad
            ; You need to assign the value to a variable - and supply a default return
            $sName = IniRead($sIni, "section", "name", "Error")
            $sClass = IniRead($sIni, "section", "class", "Error")
            $sRace = IniRead($sIni, "section", "race", "Error")
            $sSex = IniRead($sIni, "section", "sex", "Error")
            $iGold = IniRead($sIni, "section", "gold", "Error")
        Case $cRace
            $sRace = InputBox("race", "Hello " & $sName & " What is your race?")
        Case $cClass
            $sClass = InputBox("class", "Hello " & $sName & " What is your class?")
        Case $cSex
            $sSex = InputBox("sex", "Hello " & $sName & " What is your sex?")
        Case $cName
            $sName = InputBox("hello", "What's your name?")
        Case $cStart
            ; Leave this loop and start another - that way you do not get stuck in the loop that was here
            GUIDelete($hMenu_start)
            ExitLoop
    EndSwitch
WEnd

$hGame = GUICreate("test", 1026, 691, 523, 269)
$cStatsg = GUICtrlCreateGroup("", 0, 0, 1025, 57)
$cName = GUICtrlCreateLabel("name: " & $sName, 16, 24, 75, 17)
$cRace = GUICtrlCreateLabel("Race: " & $sRace, 184, 24, 75, 17)
$cClass = GUICtrlCreateLabel("Class: " & $cClass, 368, 24, 75, 17)
$cSex = GUICtrlCreateLabel("Sex: " & $sSex, 520, 24, 75, 17)
$cGold = GUICtrlCreateLabel("Gold: " & $iGold, 640, 24, 75, 17)
;GUICtrlCreateGroup("", -99, -99, 1, 1) ; No need to close the groups if you start another
$cMenug = GUICtrlCreateGroup("", 0, 56, 209, 633)
$cMenub = GUICtrlCreateButton("Menu", 64, 656, 75, 25)
;GUICtrlCreateGroup("", -99, -99, 1, 1)
$cMaing = GUICtrlCreateGroup("", 208, 56, 817, 633)
GUICtrlCreateGroup("", -99, -99, 1, 1) ; But you do need to close the group here
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Please ask if you have any questions - after you have searched the Help file a bit first of course. :D

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

satanttin,

Take a look at where this code differs from yours and see if you can work out why I have changed it: ;)

#include <GUIConstantsEx.au3>

Global $sName, $sClass, $sRace, $sSex, $iGold
Global $sIni = @ScriptDir & "\Test.ini" ; "U:\test.ini" ; You need to change this back

$hMenu_start = GUICreate("menu_start", 153, 209, 301, 264)
$cName = GUICtrlCreateButton("Name", 40, 8, 75, 25)
$cRace = GUICtrlCreateButton("Race", 40, 32, 75, 25)
$cClass = GUICtrlCreateButton("Class", 40, 56, 75, 25)
$cSex = GUICtrlCreateButton("Sex", 40, 80, 75, 25)
$cStart = GUICtrlCreateButton("Start", 40, 120, 75, 25)
$cLoad = GUICtrlCreateButton("Load game", 40, 168, 75, 25)
$cSave = GUICtrlCreateButton("Save Game", 40, 144, 75, 25)
$iGold = 100
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $cSave
IniWrite($sIni, "section", "name", $sName)
IniWrite($sIni, "section", "class", $sClass)
IniWrite($sIni, "section", "race", $sRace)
IniWrite($sIni, "section", "sex", $sSex)
IniWrite($sIni, "section", "gold", $iGold)
Case $cLoad
; You need to assign the value to a variable - and supply a default return
$sName = IniRead($sIni, "section", "name", "Error")
$sClass = IniRead($sIni, "section", "class", "Error")
$sRace = IniRead($sIni, "section", "race", "Error")
$sSex = IniRead($sIni, "section", "sex", "Error")
$iGold = IniRead($sIni, "section", "gold", "Error")
Case $cRace
$sRace = InputBox("race", "Hello " & $sName & " What is your race?")
Case $cClass
$sClass = InputBox("class", "Hello " & $sName & " What is your class?")
Case $cSex
$sSex = InputBox("sex", "Hello " & $sName & " What is your sex?")
Case $cName
$sName = InputBox("hello", "What's your name?")
Case $cStart
; Leave this loop and start another - that way you do not get stuck in the loop that was here
GUIDelete($hMenu_start)
ExitLoop
EndSwitch
WEnd

$hGame = GUICreate("test", 1026, 691, 523, 269)
$cStatsg = GUICtrlCreateGroup("", 0, 0, 1025, 57)
$cName = GUICtrlCreateLabel("name: " & $sName, 16, 24, 75, 17)
$cRace = GUICtrlCreateLabel("Race: " & $sRace, 184, 24, 75, 17)
$cClass = GUICtrlCreateLabel("Class: " & $cClass, 368, 24, 75, 17)
$cSex = GUICtrlCreateLabel("Sex: " & $sSex, 520, 24, 75, 17)
$cGold = GUICtrlCreateLabel("Gold: " & $iGold, 640, 24, 75, 17)
;GUICtrlCreateGroup("", -99, -99, 1, 1) ; No need to close the groups if you start another
$cMenug = GUICtrlCreateGroup("", 0, 56, 209, 633)
$cMenub = GUICtrlCreateButton("Menu", 64, 656, 75, 25)
;GUICtrlCreateGroup("", -99, -99, 1, 1)
$cMaing = GUICtrlCreateGroup("", 208, 56, 817, 633)
GUICtrlCreateGroup("", -99, -99, 1, 1) ; But you do need to close the group here
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

Please ask if you have any questions - after you have searched the Help file a bit first of course. :D

M23

hey thanks for the fix :3 i will study the script to see what i did wrong :)

btw i saw u made a mistake in it though:P

$cClass = GUICtrlCreateLabel("Class: " & $cClass, 368, 24, 75, 17)

it needed to be

$cClass = GUICtrlCreateLabel("Class: " & $sClass, 368, 24, 75, 17)

but that was the only little piece that was wrong so fixed in a minute:)

So yeah i think i can continue with my game ^^

thanks for the help people :)

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