Jump to content

Input and button setting data to list.


Go to solution Solved by sdfaheemuddin,

Recommended Posts

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

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