Jump to content
Sign in to follow this  
akira2891

Help with check fields

Recommended Posts

akira2891

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

Share this post


Link to post
Share on other sites
alienclone

send tab instead of send enter?


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

>Exit code: 0

REAL search results

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

Share this post


Link to post
Share on other sites
akira2891

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

Share this post


Link to post
Share on other sites
akira2891

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

Share this post


Link to post
Share on other sites
alienclone

i use ="" to represent empty


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

>Exit code: 0

REAL search results

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

Share this post


Link to post
Share on other sites
akira2891

ok thx now it works

Share this post


Link to post
Share on other sites
water

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
  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
akira2891

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

Share this post


Link to post
Share on other sites
alienclone

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

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

  • Like 1

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

>Exit code: 0

REAL search results

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

Share this post


Link to post
Share on other sites
akira2891

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

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
Sign in to follow this  

×