Jump to content

Recommended Posts

Posted

Hello

I search to make a verify on many input box before display ok button to continue script

If there is a empty box, i d'ont want to continue

I have made my script but i am not satisfy

i am sure that there is more simple to do it

#include <GUIConstants.au3>

GUICreate("Configuration d'un magasin V2", 320,320, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES
GUICtrlCreateLabel ( "Var1", 10,20)
$var1 = GUICtrlCreateInput ( "", 130,  20, 180, 20)
GUICtrlSetLimit(-1,3)
GUICtrlSetState(-1,$GUI_ACCEPTFILES)
GUICtrlCreateLabel ( "Var2", 10,45)
$var2=GUICtrlCreateInput ("", 130,  45, 180, 20)
GUICtrlCreateLabel ( "Var3", 10,70)
$var3=GUICtrlCreateInput ("", 130,  70, 180, 20)
GUICtrlCreateLabel ( "Var4", 10,95)
$var4=GUICtrlCreateInput ("", 130,  95, 180, 20)
GUICtrlCreateLabel ( "Var5", 10,120)
$var5=GUICtrlCreateInput ("", 130,  120, 180, 20)
GUICtrlCreateLabel ( "Var6", 10,145)
$var6=GUICtrlCreateInput ("", 130,  145, 180, 20)
GUICtrlCreateLabel ( "Var7", 10,170)
$var7=GUICtrlCreateInput ("", 130,  170, 180, 20)
GUICtrlCreateLabel ( "Var8", 10,195)
GUICtrlSetLimit(-1,4)
$var8=GUICtrlCreateInput ("", 130,  195, 180, 20)
GUICtrlCreateLabel ( "Var9", 10,220)
$var9=GUICtrlCreateInput ("", 130,  220, 180, 20)
GUICtrlCreateLabel ( "Var0", 10,245)
$var0=GUICtrlCreateInput ("", 130,  245, 180, 20)

GUISetState () 

$msg = 0
While 1
       $msg = GUIGetMsg()
       if GUICtrlRead($var1) and GUICtrlRead($var2) and GUICtrlRead($var3) and GUICtrlRead($var4) and GUICtrlRead($var5) and GUICtrlRead($var6) and GUICtrlRead($var7) and GUICtrlRead($var8) and GUICtrlRead($var9) and GUICtrlRead($var0) Then
          $ok=GUICtrlCreateButton ("Installer", 100, 290, 60, 20)
        
        Endif
       Select
            Case $msg = 23
               exitloop
           Case $msg = $GUI_EVENT_CLOSE
               
               exit
             
       EndSelect
Wend

MsgBox (4096, "Script", $var1)

Is there a way to check empty box only when i clik on ok button and return to inputbox if there is one empty

Because i don't really love to make a loop for this

Please help

i am lost

keyser

Posted

Thanks a lot mister

and a answer in 7 seconds

You are near the record :whistle:

One question, for var8

i have had a line GUICtrlSetLimit(-1,4)

to limit the entry to only 4 numbers

i can type more

Perhaps i have not adapt it well

because it is ok to the first var

Posted

your code says this

GUICtrlCreateLabel ( "Var8", 10,195)
GUICtrlSetLimit(-1,4)
$var8=GUICtrlCreateInput ("", 130,  195, 180, 20)

it should be like this

GUICtrlCreateLabel ( "Var8", 10,195)
$var8=GUICtrlCreateInput ("", 130,  195, 180, 20)
GUICtrlSetLimit(-1,4)

hope that helps

8)

NEWHeader1.png

Posted

You can also use the GuiFocus library, which gives you onfocus and onblur functionality for all controls.

That means if you enter or leave a field by tabbing or clicking on a button a function will be activated.

You can find the library here : http://www.autoitscript.com/fileman/users/HansH/GuiFocus.zip

Forum thread 14979

#include <GUIConstants.au3>
#include <GUIFocus.au3>

;Create window
$Gui = GUICreate("onfocus and onblur example", 240, 200)

$Inp_1 = GUICtrlCreateInput("", 35, 20, 160, 20 )
$Inp_2 = GUICtrlCreateInput("", 35, 50, 160, 20)
$Btn_1 = GUICtrlCreateButton("Save", 70, 85, 70, 25)
GUICtrlSetState(-1, $GUI_DISABLE)  ; Disable button

; DEFINE onfocus and onblur functions
_GuiFocusDefine($Gui, $Inp_1, "", "FLD1_onblur")
_GuiFocusDefine($Gui, $Inp_2, "FLD2_onfocus")

; Set start field and show windo
GUICtrlSetState($Inp_1, $GUI_FOCUS)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    _GuiFocusCheck($Gui)
    if $msg = $GUI_EVENT_CLOSE then ExitLoop
    if $msg = $Btn_1 then MsgBox(64,"Save", "save button executed",2);
WEnd
Exit

Func FLD1_onblur()
    $value = GUICtrlRead($Inp_1)
    if StringLen($value) < 5 Then
        MsgBox(64,"Input Error", "Mandatory field, please fill in at least 5 characters")
        GUICtrlSetState($Inp_1, $GUI_FOCUS)
        GUICtrlSetState($Btn_1, $GUI_DISABLE)
        SetError(1)                             ; signal not to continue with possible onfocus, error encountered
    else
        GUICtrlSetState($Btn_1, $GUI_ENABLE)    ; enable button if content is ok
    Endif
EndFunc

Func FLD2_onfocus()
; if empty set default value ok
    if GUICtrlRead($Inp_2) = "" Then GUICtrlSetData($Inp_2, "ok" )
EndFunc
Posted (edited)

help me please

i become crazy

i can't use GUICtrlRead($var1)

to have the text type in 1st inputbox

i don't understand

i use the code of Larry

Edit : ok i have resolved my issue by insert

$var1 = GUICtrlRead($var1)

between this 2 lines

Case Else
ExitLoop
Edited by keyser
Posted

help me please

i become crazy

i can't use GUICtrlRead($var1)

to have the text type in 1st inputbox

i don't understand

i use the code of Larry

Edit : ok i have resolved my issue by insert

$var1 = GUICtrlRead($var1)

between this 2 lines

Case Else
ExitLoop

<{POST_SNAPBACK}>

I think you want something like this:

$var1 = GUICtrlRead($Inp_1)
Say: "Chuchichäschtli"My UDFs:_PrintImage UDF_WinAnimate UDFGruess Raindancer

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...