Jump to content

GUICtrlCreateInput vs InputBox

Recommended Posts


Hi there! I don't know if I'm posting it in the right place, but yeah, sorry for that :D
Anyway, Does GUICtrlCreateInput() have the functionality for mandatory Input like InputBox()?  I know that in InputBox(), putting the letter M after the first character indicates that input is mandatory, so clicking the ok button will do nothing. Does GuiCtrlCreateInput() have one? or do I need to manually do it using condition and loops?

Share this post

Link to post
Share on other sites

An InputBox is a standalone function, whereas GuiCtrlCreateInput requires it's own Gui, within the Gui you can define these settings for example before the user clicks submit, you can get it to check that the input has a value etc..., basic example below.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

Func Example()
    GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, $WS_EX_ACCEPTFILES)
    Local $idInput1 = GUICtrlCreateInput("", 10, 5, 205, 20)
        _GUICtrlEdit_SetCueBanner ($idInput1, "<Folder Path> *Required", True)
    Local $idBrowse = GUICtrlCreateButton("Browse...", 220, 5, 90, 20)
    Local $idInput2 = GUICtrlCreateInput("", 10, 35, 300, 20)
    Local $idBtn = GUICtrlCreateButton("Ok", 40, 75, 60, 20)


    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
            Case $idBrowse
                Local $sBrowse = FileSelectFolder("Please Select Folder...", "")
                If @error Then ContinueLoop
                GUICtrlSetData($idInput1, $sBrowse)
            Case $idBtn
                If GUICtrlRead($idInput1) = "" Then ContinueLoop MsgBox(4096, "InputBox1", "Select Folder Path Required")
                If FileExists(GUICtrlRead($idInput1)) = 0 Then ContinueLoop MsgBox(4096, "InputBox1", GUICtrlRead($idInput1) & " is not a valid folder path.")

EndFunc   ;==>Example


Share this post

Link to post
Share on other sites

@bowker in shorter answer to your question, No, there is no parameter you can use during initialization of the GuiCtrlCreateInput that will make it mandatory.

√-1 2^3 ∑ π, and it was delicious!

Share this post

Link to post
Share on other sites

@JLogan3o13 I see. Thank you very much for answering :) 

@Subz Thank you for giving an example :) I will try to implement the logic to my code :)

Share this post

Link to post
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

  • Similar Content

    • mar3011
      By mar3011
      hello, I want to set in the inputbox field random key from the keyboard to which the function will be assigned, for example F4 function start notepad ALT + A function start notepad for one function. Thank you for any help.  
    • JuanFelipe
      By JuanFelipe
      Cambiar a español Hello friends, I need help with a problem I have, I want to know if there is any way to update a GUI already running, that is I have a GUI of a certain size and with a button I would like to enlarge it:
      example: $ form1 = GUICreate ("", 200,100,0,0)   When you press the button, the gui increases its size, and actuates the new size.
    • BogdanNicolescu
      By BogdanNicolescu
      While 1 / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / WEnd OR:

      HotKeySet("{ESC}", "Terminate") While 1 MouseClick("Right",674,422) MouseClick("Left",673,447) Sleep(2000) / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / MouseClick("Left",675,339) SLeep(3000) WEnd Func Terminate()     Exit 0 EndFunc  
      Sorry if i should't let this here to be found by newbies like me -.-'
    • santoshM
      By santoshM
      Dear friends i am facing a problem , i have created a window in autoit some time it is moving with the mouse curser even if iam not clicking the window 
    • sumanth1980
      By sumanth1980
      Here i am wrote a simple lines to install basic applications but when i clicked on one application/program to install it was working fine but when i cancel the program in the middle to install another program it was not working. I am not an expert in this but i want a solution for this ... Can any one help me on this....