Jump to content

Help with check fields


Go to solution Solved by alienclone,

Recommended Posts

Posted

Hi, i have problem with this script.

How can i check inputfield if empty go on second

I tried like this but he dont skip first field even if its empty

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


GUICreate("Form 1", 682, 293, 561, 164)
$input1 = GUICtrlCreateInput("", 16, 48, 649, 21)
$input2 = GUICtrlCreateInput("", 16, 138, 649, 21)
GUICtrlSetLimit(-1, 90)
$input3 = GUICtrlCreateInput("", 16, 222, 649, 21)
GUICtrlSetLimit(-1, 90)
GUICtrlCreateLabel("Input 1", 16, 16, 100, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
GUICtrlCreateLabel("Input 2", 16, 102, 78, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
GUICtrlCreateLabel("Input 3", 16, 188, 46, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
GUISetState(@SW_SHOW)

HotKeySet("{F3}", "_msgSend")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _msgSend()
    If GUICtrlRead($input1) >= 0 Then
        Send("{ENTER}")
        Sleep(1000)
        Send(GUICtrlRead($input1))
        Send("{ENTER}")
        Sleep(500)
    EndIf

    Send("{ENTER}")
    Sleep(1000)
    Send(GUICtrlRead($input2))
    Send("{ENTER}")
    Sleep(500)

    Send("{ENTER}")
    Sleep(1000)
    Send(GUICtrlRead($input3))
    Send("{ENTER}")
    Sleep(500)
EndFunc
Posted (edited)

I have problem with this only, i need to check if field is not empty what operator to use > or = '' or  = 0

If GUICtrlRead($input1) >= 0 Then

its not like in other languages like in php for example, so if 1st field is empty skip it, else if 2nd field empty skip it else do stuff.

Im confused with this comparsion operators in autoit <> >= =< 

If ($input) == '' {
    echo 'dont do enything';
} else if ($input2) == '' {
    echo 'dont do nothing';
} else {
    echo 'do stuff';
}
Edited by akira2891
Posted

This is so confused :/

So zero is threated like empty field as i saw, why then when i compare if field is greater than nothing i get this message "Field 1 empty !"

so if field is empty or i put something in it give me message that is empty 

there is no operator like       if ( !empty )    or    if ( empty ) ?

If GUICtrlRead($input1) > 0 Then
        Send("{ENTER}")
        Sleep(1000)
        Send(GUICtrlRead($input1))
        Send("{ENTER}")
        Sleep(500)
    Else
        MsgBox(48, "Error", "Field 1 empty !")
    EndIf
Posted

If you need to make sure that spaces are treated as empty as well I suggest:

#include <StringConstants.au3>
If StringStripWS(GUICtrlRead($input1), $STR_STRIPALL) = "" Then

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

its a bit hard because im learning autoit, i know php but this is diferent especialy this comparsion operators like this for example

// php
if (!empty($var1)) { // if not empty
    // do stuff
}


// autoit
If GUICtrlRead($input1) = "" Then ; how to check here if not empty
                Send("{ENTER}")
        Sleep(1000)
        Send(GUICtrlRead($input1))
        Send("{ENTER}")
        Sleep(500)
    EndIf
Posted

Now works normal 

Func _msgSend()
    If Not GUICtrlRead($input1) = "" Then
        Send("{ENTER}")
        Sleep(1000)
        Send(GUICtrlRead($input1))
        Send("{ENTER}")
        Sleep(500)
    EndIf

    If Not GUICtrlRead($input2) = "" Then
        Send("{ENTER}")
        Sleep(1000)
        Send(GUICtrlRead($input2))
        Send("{ENTER}")
        Sleep(500)
    EndIf

    If Not GUICtrlRead($input3) = "" Then
        Send("{ENTER}")
        Sleep(1000)
        Send(GUICtrlRead($input3))
        Send("{ENTER}")
        Sleep(500)
    EndIf
EndFunc

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