HardCopy Posted August 7, 2005 Share Posted August 7, 2005 Hi the following code causes autoit to crash Release + beta - Autoit / tried each - both crash. Could some one confirm if getting same result. reduced code for testing only. Idea is user clicks button asking for a few digit input. Closes after x seconds. #include <GuiConstants.au3> GuiCreate("MyGUI", 392, 323,(@DesktopWidth-392)/2, (@DesktopHeight-323)/2 ) $Button_1 = GuiCtrlCreateButton("Test", 60, 50, 70, 40) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 test() Case Else ;;; EndSelect WEnd Exit func test() $testbox=GUICtrlCreateInput("Test",200,70,100,25) Sleep(3000) GUICtrlDelete($testbox) EndFunc Type something into the box, it closes automatically after 3 seconds then press TEST button again to repeat , BANG autoit crashes. Is my code doing something illegal here? Or is this a bug. Thanks HardCopy Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad Link to comment Share on other sites More sharing options...
hgeras Posted August 7, 2005 Share Posted August 7, 2005 #include <GuiConstants.au3> GuiCreate("MyGUI", 392, 323,(@DesktopWidth-392)/2, (@DesktopHeight-323)/2 ) $Button_1 = GuiCtrlCreateButton("Test", 60, 50, 70, 40) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 test() EndSelect WEnd Exit func test() Dim $testbox ; <-- You have to do this to nullify the control completely $testbox=GUICtrlCreateInput("Test",200,70,100,25) Sleep(3000) GUICtrlDelete($testbox) EndFunc Now it doesnt crash... C ya Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF Link to comment Share on other sites More sharing options...
HardCopy Posted August 7, 2005 Author Share Posted August 7, 2005 #include <GuiConstants.au3> GuiCreate("MyGUI", 392, 323,(@DesktopWidth-392)/2, (@DesktopHeight-323)/2 ) $Button_1 = GuiCtrlCreateButton("Test", 60, 50, 70, 40) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 test() EndSelect WEnd Exit func test() Dim $testbox; <-- You have to do this to nullify the control completely $testbox=GUICtrlCreateInput("Test",200,70,100,25) Sleep(3000) GUICtrlDelete($testbox) EndFuncNow it doesnt crash...C ya<{POST_SNAPBACK}>hgerasNope still crashes !...Thx for your time thoughHardCopy Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 7, 2005 Moderators Share Posted August 7, 2005 (edited) #include <GuiConstants.au3> GuiCreate("MyGUI", 392, 323,(@DesktopWidth-392)/2, (@DesktopHeight-323)/2 ) $Button_1 = GuiCtrlCreateButton("Test", 60, 50, 70, 40) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 test() EndSelect WEnd Exit func test() $testbox=GUICtrlCreateInput("Test",200,70,100,25) GUISetState(); you added a new GUI control, but never set the state for the GUI again Sleep(3000) GUICtrlDelete($testbox) EndFunc Edit: Fixed misspelled word. Edited August 7, 2005 by ronsrules 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. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 7, 2005 Moderators Share Posted August 7, 2005 Or this might be better... dunno (not really a gui nut ) func test() $testbox=GUICtrlCreateInput("Test",200,70,100,25) GUICtrlSetState($testbox,""); you added a new guictrl, but never set the state for the gui again Sleep(3000) GUICtrlDelete($testbox) EndFunc 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. Link to comment Share on other sites More sharing options...
hgeras Posted August 7, 2005 Share Posted August 7, 2005 (edited) Now this code works 100%... #include <GuiConstants.au3> GuiCreate("MyGUI", 392, 323,(@DesktopWidth-392)/2, (@DesktopHeight-323)/2 ) $Button_1 = GuiCtrlCreateButton("Test", 60, 50, 70, 40) Dim $testbox GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 test() EndSelect WEnd Exit func test() $testbox=GUICtrlCreateInput("Test",200,70,100,25) Sleep(3000) Guictrlsetdata($testbox,"Test");<-- Add this before deleting the control GUICtrlDelete($testbox) EndFunc The crash happens when the control has different data when it was first made and then deleted.... So if you Create input ,be sure to return it in its creation data.In that case , when it was made it had "Test" for data. If you write in the input "12345" then it will crash next time you press button.So you set the data in the input right before deleting it again to "Test".If the creation value was "" then you should put "" again before deleting.... C ya Edited August 7, 2005 by hgeras Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF Link to comment Share on other sites More sharing options...
HardCopy Posted August 7, 2005 Author Share Posted August 7, 2005 Now this code works 100%...#include <GuiConstants.au3> GuiCreate("MyGUI", 392, 323,(@DesktopWidth-392)/2, (@DesktopHeight-323)/2 ) $Button_1 = GuiCtrlCreateButton("Test", 60, 50, 70, 40) Dim $testbox GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 test() EndSelect WEnd Exit func test() $testbox=GUICtrlCreateInput("Test",200,70,100,25) Sleep(3000) Guictrlsetdata($testbox,"Test");<-- Add this before deleting the control GUICtrlDelete($testbox) EndFuncThe crash happens when the control has different data when it was first made and then deleted.... So if you Create input ,be sure to return it in its creation data.In that case , when it was made it had "Test" for data. If you write in the input "12345" then it will crash next time you press button.So you set the data in the input right before deleting it again to "Test".If the creation value was "" then you should put "" again before deleting....C ya<{POST_SNAPBACK}>@ron / no go ron, i tried that already.Well done hgeras, that did it. Thank you both for sharing the problem.@developers, no mention of this in documentation, can it be added.? Or is this just unique failure in the dirty method im using?Hardcopy Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 7, 2005 Moderators Share Posted August 7, 2005 ahh... lol, add the one word "Test", well at least I set hgeras on the right path , glad it works for ya. 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. Link to comment Share on other sites More sharing options...
jpm Posted August 7, 2005 Share Posted August 7, 2005 THanks, wil be fixed in 3.1.1.67 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now