gottygolly Posted April 7, 2015 Share Posted April 7, 2015 I have a script that has a button and a input, I want the user to be able to press enter on the input and send data to a list (This works fine). The problem im having though is if the user types in the input "Hi" or any text and then hits the button it will add "Hi" to the list twice even if the user didn't press enter. Any thoughts on how to fix this? [There is probably an answer to this some where but I didn't know how to search for it.] #include<guiconstants.au3> $gui = GUICreate("",200,200,-1,-1) Opt("GUIOnEventMode",1) GUISetOnEvent(-3,"_Exit") Global $input = GUICtrlCreateInput("",5,5,190,20,$ss_center) GUICtrlSetOnEvent($input,"_Input") $button = GUICtrlCreateButton("Button",5,30,100,25) GUICtrlSetOnEvent($button,"_Input") $list = GUICtrlCreateList("List",5,60,190,100) GUISetState() While 1 Sleep(10) WEnd Func _Exit() Exit EndFunc Func _Input() ;GUICtrlSetState($button,$GUI_FOCUS) ;Tried this but still added it twice. $Read = GUICtrlRead($input) GUICtrlSetData($list,$read&"|") EndFunc Link to comment Share on other sites More sharing options...
Solution sdfaheemuddin Posted April 8, 2015 Solution Share Posted April 8, 2015 (edited) Add style to your bottom $button = GUICtrlCreateButton ( "Button" , 5 , 30 , 100 , 25, $BS_DEFPUSHBUTTON ) No need of GUICtrlSetOnEvent ($input,"_Input") Edited April 8, 2015 by sdfaheemuddin Link to comment Share on other sites More sharing options...
JohnOne Posted April 8, 2015 Share Posted April 8, 2015 That is the problem, comment that line out. The button does its task and then fires an event on the input. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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