Jump to content

Help with check fields


 Share

Go to solution Solved by alienclone,

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

If GUICtrlRead($input1) <> "" Then ; this should work

If not GUICtrlRead($input1) = "" Then ; this may also work

If @error Then
    MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!")
EndIf

"Yeah yeah yeah patience, how long will that take?"  -Ed Gruberman

REAL search results  |  SciTE4AutoIt3 Editor Full Version

Link to comment
Share on other sites

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