Followers 0

# Getting a AutoIt has encountered a problem and needs to close error.

## 15 posts in this topic

Okay, I made 2 list boxes so when u delete one it will add it to the other and delete it from the other one, and the same way around...

but, when u click the ADD button windows gives me this error. "AutoIt has encountered an error and needs to close"

is it just my os?

is their something wrong with my code?

Do

$msg = GUIGetmsg() Select Case$msg = $Control_Add_Button$IncludeFile = _GUICtrlListGetCaretindex($Control_IncludeList_Have) _GUICtrlListAddItem($Control_Includelist_Have, $IncludeFile) _GUICtrlListDeleteItem($Control_Includes_ToBeUsed_List, $IncludeFile) Case$msg = $Control_Remove_Button$IncludeFile = _GUICtrlListGetCaretindex($Control_Includes_TobeUsed_List) _GUICtrlListDeleteItem($Control_IncludeList_Have, $IncludeFile) _GUICtrlListAddItem($Control_Includes_ToBeUsed_List, $IncludeFile) EndSelect Until$msg = $GUI_EVENT_CLOSE #### Share this post ##### Link to post ##### Share on other sites is this just happening on one PC, or other PCs in your enviroment? #### Share this post ##### Link to post ##### Share on other sites Okay, I made 2 list boxes so when u delete one it will add it to the other and delete it from the other one, and the same way around... but, when u click the ADD button windows gives me this error. "AutoIt has encountered an error and needs to close" is it just my os? is their something wrong with my code? Do$msg = GUIGetmsg()
Select
Case $msg =$Control_Add_Button
$IncludeFile = _GUICtrlListGetCaretindex($Control_IncludeList_Have)
_GUICtrlListAddItem($Control_Includelist_Have,$IncludeFile)
_GUICtrlListDeleteItem($Control_Includes_ToBeUsed_List,$IncludeFile)
Case $msg =$Control_Remove_Button
$IncludeFile = _GUICtrlListGetCaretindex($Control_Includes_TobeUsed_List)
_GUICtrlListDeleteItem($Control_IncludeList_Have,$IncludeFile)
_GUICtrlListAddItem($Control_Includes_ToBeUsed_List,$IncludeFile)
EndSelect

Until $msg =$GUI_EVENT_CLOSE

Don't argue with an idiot; people watching may not be able to tell the difference.

##### Share on other sites

now its not working at all.... and no, i have'nt tried it on other machines. only mine.

##### Share on other sites

think it would help if you supplied the script, I retested those functions and they work fine.

Don't argue with an idiot; people watching may not be able to tell the difference.

##### Share on other sites

Thanks everyone, but i finnally got it to work! It was my fault, i had a few things flipped around in the opposite order, it was reading from the listbox that had nothing in it. Thanks again everyone.

##### Share on other sites

Thanks everyone, but i finnally got it to work! It was my fault, i had a few things flipped around in the opposite order, it was reading from the listbox that had nothing in it. Thanks again everyone.

np, i think your better off using the _GUICtrlListSelectedIndex, the _GUICtrlListGetCaretindex can be tricky

Don't argue with an idiot; people watching may not be able to tell the difference.

##### Share on other sites

Anything causing AutoIt to hard-crash needs the attention of the developers. Could you please consider writing and posting a short, complete snippet of code to cause this error?

##### Share on other sites

#9 ·  Posted (edited)

well... here is the entire script i was using......

;Game Maker for AutoIt3
#include <GuiConstants.au3>
#include <GuiList.au3>
#include <file.au3>
#include <array.au3>
#include <Media.au3>
$MainGUI = GUICreate("Game Maker Au3", 847, 620, -1, -1);Creates the Main GUI GUISetBkColor(0x9D886B) ;File Menu and Context Menu$FileMenu = GUICtrlCreateMenu("File")
$ActionsMenu = GUICtrlCreateMenu("Actions")$HelpMenu = GUICtrlCreateMenu("Help")
$AddSprite_ActionsMenu = GUICtrlCreateMenuItem("Add Sprite",$ActionsMenu)
$AddObject_ActionsMenu = GUICtrlCreateMenuItem("Add Object",$ActionsMenu)
$AddMusic_ActionsMenu = GUICtrlCreateMenuItem("Add Music/Sound",$ActionsMenu)
$Help_HelpMenu = GUICtrlCreateMenuItem("Help",$HelpMenu)
;GUI Controls - Main GUI Window
$Control_SpriteListBox = GUICtrlCreateList("", 77, 155, 140, 71)$Control_ProgramLogo = GUICtrlCreatePic("logo.gif", 150, 0, 500, 120)
$Control_MediaGroup = GUICtrlCreateGroup("Media", 10, 130, 241, 403)$Control_SpritesIcon = GUICtrlCreateIcon("Sprites_Icon.ico", 0, 20, 155, 50, 50)
$Control_SpritesLabel = GUICtrlCreateLabel("Sprites", 76, 139, 100, 14)$Control_ObjectsIcon = GUICtrlCreateIcon("Objects_Icon.ico", 0, 15, 251, 50, 39)
$Control_ObjectsList = GUICtrlCreateList("", 74, 252, 143, 71)$Control_ObjectsLabel = GUICtrlCreateLabel("Objects", 76, 236, 67, 15)
$Control_MusicIcon = GUICtrlCreateIcon("Music_Icon.ico", 0, 12, 351, 53, 39)$Control_SoundsList = GUICtrlCreateList("", 74, 350, 143, 71)
$Control_SoundsLabel = GUICtrlCreateLabel("Music and Sounds", 75, 330, 100, 14)$Control_GameObjectsGroup = GUICtrlCreateGroup("Game Objects", 250, 130, 167, 247)
$Control_GameObjects_ObjectsList = GUICtrlCreateList("", 261, 201, 145, 58)$Control_GameObjects_ObjectsLabel = GUICtrlCreateLabel("Objects", 307, 156, 49, 17)
$Control_GameObjects_SoundsLabel = GUICtrlCreateLabel("Background Music", 288, 267, 98, 12)$Control_GameObjects_SoundsList = GUICtrlCreateList("", 261, 314, 145, 58)
$Control_GameScreeGroup = GUICtrlCreateGroup("Game Screen", 416, 130, 418, 407)$Control_GameInformation_Button = GUICtrlCreateButton("Game Information", 11, 543, 163, 39)
$Control_GameSettings_Button = GUICtrlCreateButton("Game Settings", 173, 542, 190, 40)$Control_GlobalSettings_Button = GUICtrlCreateButton("Global Settings", 363, 541, 165, 41)
$Control_CreateGame_Button = GUICtrlCreateButton("Create Game", 715, 540, 126, 46)$Control_RoomsGroup = GUICtrlCreateGroup("Rooms", 252, 378, 163, 154)
$Control_Rooms_RoomsList = GUICtrlCreateList("", 257, 455, 151, 71)$Control_Rooms_RoomsIcon = GUICtrlCreateIcon("Rooms_Icon.ico", 0, 295, 394, 63, 55)
$Control_MusicIcon = GUICtrlCreateIcon("Music_Icon.ico", 0, 310, 286, 39, 23)$Control_Objects_Icon = GUICtrlCreateIcon("Objects_Icon.ico", 0, 310, 170, 39, 23)
;End Of GUI Controls for MAIN GUI
$SpritesContextMenu = GUICtrlCreateContextMenu($Control_SpriteListBox)
$AddSprite_ActionsMenu = GUICtrlCreateMenuItem("Add Sprite",$SpritesContextMenu)
$SpritePropteries = GUICtrlCreateMenuItem("Properties",$SpritesContextMenu)
$MusicContextMenu = GUICtrlCreateContextMenu($Control_SoundsList)
$AddSounds = GUICtrlCreateMenuItem("Add Sound/Music",$MusicContextMenu)
$MusicProperties = GUICtrlCreateMenuItem("Properties",$MusicContextMenu)
$ObjectsContextMenu = GUICtrlCreateContextMenu($Control_ObjectsList)
$AddObjects = GUICtrlCreateMenuItem("Add Object",$ObjectsContextMenu)
$ObjectProperties = GUICtrlCreateMenuItem("Properties",$ObjectsContextMenu)
$RoomsContextMenu = GUICtrlCreateContextMenu($Control_Rooms_RoomsList)
$AddRoom = GUICtrlCreateMenuItem("Add Room",$RoomsContextMenu)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg() Select Case$msg = $GUI_EVENT_CLOSE Exit Case$msg = $Control_GameInformation_Button GameInformation() Case$msg = $Control_GameSettings_Button GameSettings() Case$msg = $Control_GlobalSettings_Button GlobalSettings() Case$msg = $AddSprite_ActionsMenu AddSprite() Case$msg = $AddSounds AddMusic() Case$msg = $AddObjects AddObjects () Case$msg = $AddRoom AddRoom () Case$msg = $MusicProperties MusicProperties() EndSelect WEnd Func GameInformation();GameInfo.gdf GUISwitch($MainGUI)
$InformationGUI = GUICreate("Game Information", 550, 436, -1, -1)$Control_EditBox = GUICtrlCreateEdit("Put your Game Information in here. When the user presses F1, this screen will be displayed.", 0, 50, 550, 386)
$Control_Logo = GUICtrlCreatePic("GameInformation.jpg", 122, 6, 418, 38)$Control_Submit_Button = GUICtrlCreateButton("Submit", 7, 6, 104, 41)
GUISetState(@SW_SHOW)
Do
$msg = GUIGetMsg() Select Case$msg = $Control_Submit_Button$GDFile = FileOpen("GameInfo.gdf", 1)
FileWrite($GDFile, GUICtrlRead($Control_EditBox))
FileClose($GDFile) MsgBox(0, "Data Saved.", "Your Game information data has been saved. it is now safe for you to exit this window") EndSelect Until$msg = $GUI_EVENT_CLOSE GUISwitch($InformationGUI)
GUIDelete($InformationGUI) EndFunc ;==>GameInformation Func GlobalSettings(); GameData.gdf$GlobalSettings = GUICreate("Global Settings", 621, 449, -1, -1, BitOR($WS_OVERLAPPEDWINDOW,$WS_CLIPSIBLINGS))
$Control_IncludesGroup = GUICtrlCreateGroup("#Includes", 3, 49, 277, 312)$Control_IncludeList_Have = GUICtrlCreateList("", 12, 92, 122, 175)
$Control_Add_Button = GUICtrlCreateButton("Add", 9, 288, 96, 21)$Control_Remove_Button = GUICtrlCreateButton("Remove", 9, 310, 98, 20)
$Control_Submit_Button = GUICtrlCreateButton("Submit", 443, 390, 166, 54)$Control_Cancel_Button = GUICtrlCreateButton("Cancel", 4, 393, 179, 50)
$Control_GlobalSettings_Label = GUICtrlCreateLabel("Global Settings", 252, 16, 107, 19)$Control_Window_Width = GUICtrlCreateLabel("Game Window Width:", 344, 92, 113, 15)
$Control_Window_Height = GUICtrlCreateLabel("Game Window Height:", 345, 121, 114, 16)$Control_Window_Width_Input = GUICtrlCreateInput("", 472, 88, 115, 24)
$Control_Window_Height_Input = GUICtrlCreateInput("", 472, 115, 115, 23)$Control_GameName_Label = GUICtrlCreateLabel("Game Name:", 345, 152, 70, 17)
$Control_GameName_Input = GUICtrlCreateInput("", 449, 144, 140, 27)$Control_GameVersion_Label = GUICtrlCreateLabel("Game Version:", 346, 184, 73, 20)
$Control_GameVersion_Input = GUICtrlCreateInput("", 449, 176, 140, 25)$Control_Includes_CurrentlyHave_Label = GUICtrlCreateLabel("Currently Have:", 21, 69, 94, 12)
$Control_Includes_ToBeUsed_list = GUICtrlCreateList("", 133, 92, 133, 175)$Control_Includes_ToBeUsed_Label = GUICtrlCreateLabel("Available", 172, 70, 48, 14)
$Control_GameCaption_Label = GUICtrlCreateLabel("Game Caption: ", 347, 213, 81, 16)$Control_GameCaption_Input = GUICtrlCreateInput("", 449, 206, 140, 24)
$Control_InitialLives_Label = GUICtrlCreateLabel("Initial Lives:", 356, 265, 62, 16)$Control_InitialLives_Input = GUICtrlCreateInput("3", 451, 260, 37, 22)
$Control_InitialHealth_Label = GUICtrlCreateLabel("Initial Health(100)", 355, 304, 88, 16)$Control_InitialHealth_Input = GUICtrlCreateInput("100", 452, 299, 58, 21)
$Control_InitialScore_Label = GUICtrlCreateLabel("Initial Score:", 355, 340, 68, 17)$Control_InitalScore_Input = GUICtrlCreateInput("0", 452, 337, 74, 22)
$Control_Browse_Button = GUICtrlCreateButton("Browse...", 9, 331, 98, 19) GUISetState()$includes = _FileListToArray (@HomeDrive & "\program files\AutoIt3\beta\include", "*.au3")
For $i = 1 To$includes[0]
GUICtrlSetData($Control_Includes_ToBeUsed_list,$includes[$i]) Next Do$msg = GUIGetMsg()
Select
Case $msg =$Control_Add_Button
;Add File from opposite list box, and erase it from the opposite list box
$IncludeFile = _GUICtrlListSelectedIndex ($Control_Includes_ToBeUsed_list)
$FileName = GUICtrlRead($Control_Includes_ToBeUsed_list)
_GUICtrlListAddItem ($Control_IncludeList_Have,$FileName)
_GUICtrlListDeleteItem ($Control_Includes_ToBeUsed_list,$IncludeFile)
Case $msg =$Control_Remove_Button
;remove file from list box, and add it to the opposite
$IncludeFile = _GUICtrlListSelectedIndex ($Control_IncludeList_Have)
$FileName = GUICtrlRead($Control_IncludeList_Have)
_GUICtrlListDeleteItem ($Control_IncludeList_Have,$IncludeFile)
_GUICtrlListAddItem ($Control_Includes_ToBeUsed_list,$FileName)
Case $msg =$Control_Submit_Button
$File = FileOpen("GameData.gdf", 1) FileWriteLine($File, GUICtrlRead($Control_Window_Width_Input)) FileWriteLine($File, GUICtrlRead($Control_Window_Height_Input)) FileWriteLine($File, GUICtrlRead($Control_GameCaption_Input)) FileWriteLine($File, GUICtrlRead($Control_GameVersion_Input)) FileWriteLine($File, GUICtrlRead($Control_GameName_Input)) FileWriteLine($File, GUICtrlRead($Control_InitalScore_Input)) FileWriteLine($File, GUICtrlRead($Control_InitialLives_Input)) FileWriteLine($File, _GUICtrlListCount ($Control_IncludeList_Have)) For$i = 1 To _GUICtrlListCount ($Control_IncludeList_Have) FileWriteLine($File, _GUICtrlListGetText ($Control_IncludeList_Have,$i))
Next
FileClose($File) EndSelect Until$msg = $GUI_EVENT_CLOSE GUISwitch($GlobalSettings)
GUIDelete($GlobalSettings) EndFunc ;==>GlobalSettings Func GameSettings();GameSettings.gdf GUISwitch($MainGUI)
$GameSettings = GUICreate("Game Settings", 446, 412, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))$Control_GameSettings_MainGroup = GUICtrlCreateGroup("Game Settings", 12, 7, 426, 387)
$Control_GameSettings_Label_ScriptOutputDirectory = GUICtrlCreateLabel("AutoIt Script output Directory", 30, 49, 148, 15)$Control_GameSettings_OutputFile = GUICtrlCreateInput("", 27, 81, 312, 25)
$Control_GameSettings_BrowseButton = GUICtrlCreateButton("Browse...", 345, 80, 88, 25)$Control_GameSettings_GameAuthor_Label = GUICtrlCreateLabel("Game Author:", 26, 117, 86, 15)
$Control_GameSettings_GameAuthor = GUICtrlCreateInput("", 27, 135, 356, 29)$Control_GameSettings_GameCredits_Label = GUICtrlCreateLabel("Game Credits", 28, 176, 99, 17)
$Control_GameSettings_GameCredits = GUICtrlCreateEdit("", 26, 195, 404, 117)$Control_GameSettings_SubmitButton = GUICtrlCreateButton("Submit", 120, 332, 185, 48)
GUISetState()
Do
$msg = GUIGetMsg() Select Case$msg = $Control_GameSettings_BrowseButton Global$SourceOutputFile = FileSaveDialog("OutPut Source", "", "AU3 (*.au3)")
GUICtrlSetData($Control_GameSettings_OutputFile,$SourceOutputFile)
Case $msg =$Control_GameSettings_SubmitButton
$File = FileOpen("GameSettings.gdf", 1) FileWriteLine($File, GUICtrlRead($Control_GameSettings_OutputFile)); Line 1 = Output File FileWriteLine($File, GUICtrlRead($Control_GameSettings_GameAuthor)); Line 2 = Game Author FileWriteLine($File, GUICtrlRead($Control_GameSettings_GameCredits)); Line 3 to x = Game Credits FileClose($File)
EndSelect
Until $msg =$GUI_EVENT_CLOSE
GUISwitch($GameSettings) GUIDelete($GameSettings)
EndFunc ;==>GameSettings
Func BuildGame()
EndFunc ;==>BuildGame
Func Help()
;;;;Open Help File
EndFunc ;==>Help
$ImageFile = FileOpenDialog("Sprite File", "", "Images (*.jpg;*.gif;*.bmp)")$ImageWidth = InputBox("Sprite Width:", "What would you like the width of your sprite to be?", "32")
$ImageHeight = InputBox("Sprite Height:", "What would you like the height of your sprite to be?", "32")$ControlID = InputBox("Control ID", "Name of this Object in Variable Form:")
GUICtrlSetData($Control_SpriteListBox, GUICtrlRead($Control_SpriteListBox) & $ControlID) Dim$ControlID[4]
Return $ControlID[0] =$ControlID
Return $ControlID[1] =$ImageFile
Return $ControlID[2] =$ImageWidth
Return $ControlID[3] =$ImageHeight
$SoundFile = FileOpenDialog("Music File", "", "Music Files (*.wav;*.mp3;*.wma;*.mid)")$ControlID = InputBox("Control ID", "Name of this Object in Variable Form:")
GUICtrlSetData($Control_SoundsList, GUICtrlRead($Control_SoundsList) & $ControlID) Dim$ControlID[3]
Return $ControlID[0] =$ControlID
Return $ControlID[1] =$SoundFile
Return $ControlID[2] = FileGetSize($SoundFile)
Func MusicProperties()
GUISwitch($MainGUI) GUICreate("Music/Sound Properties", 463, 187, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) Dim$ControlID[1]
$ControlID[0] = _GUICtrlListGetSelItems ($Control_SoundsList)
$Group = GUICtrlCreateGroup("Music/Sound Properties", 11, 10, 440, 162)$File = GUICtrlCreateLabel($ControlID[0], 30, 40, 100, 20)$FileSize = GUICtrlCreateLabel("File Size: ", 31, 57, 56, 15)
$Play = GUICtrlCreateButton("Play", 79, 132, 74, 28)$Pause = GUICtrlCreateButton("Pause", 161, 132, 74, 28)
$Stop = GUICtrlCreateButton("Stop", 243, 134, 82, 27) GUISetState() Do$msg = GUIGetMsg()
Select
Case $msg =$Play
_MediaCreate ()
;### Tidy Error: Level error -> WEnd is closing previous case
WEnd
Exit
;### Tidy Error: Level error -> EndFunc is closing previous Select
EndFunc ;==>MusicProperties
;### Tidy Error: Level error -> "Do" Not closed before Func statement.
;### Tidy Error: Level error -> "Func" cannot be inside any IF/Do/While/For/Case/Func statement.
EndFunc ;==>AddObject

Their is a little bit of missing code in their somewhere.... sry bout that

Edited by CHRIS95219

##### Share on other sites

#10 ·  Posted (edited)

Do
$msg = GUIGetMsg() Select Case$msg = $Play _MediaCreate () ;### Tidy Error: Level error -> WEnd is closing previous case WEnd Should Do be While 1? Was bugging me, thinking that I just looked at it real quick... so While 1; was Do instead of While 1$msg = GUIGetMsg()
Select
Case $msg =$Play
_MediaCreate()
Exit; was in the wrong spot it looked like
EndSelect; was missing
Wend
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

##### Share on other sites

yeah.. i did'nt notice that... thx

##### Share on other sites

yeah.. i did'nt notice that... thx

Next time try to submit a complete SMALL script.

Thanks for those which try to help you. The media.au3 was missing, in this specific case it could have been commented out and the function referenced too.

I is always a surprise to me that somebody don't try to understand the error message and confuse them saying there is an hard crash instead of an error display by au3check or even by autoit if executed.

##### Share on other sites

no.. i think i changed the code since then... It was'nt a parse error... it was, a "AutoIt has encountered an error and needs to close".

##### Share on other sites

no.. i think i changed the code since then... It was'nt a parse error... it was, a "AutoIt has encountered an error and needs to close".

so your script is not reproducing the error !!!

##### Share on other sites

so your script is not reproducing the error !!!

oh... i see, i did'nt no it does that, i thought it would just give a basic compilation error....sry bout that