akira2891 Posted November 17, 2014 Share Posted November 17, 2014 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 expandcollapse popup#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 More sharing options...
alienclone Posted November 17, 2014 Share Posted November 17, 2014 send tab instead of send enter? 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 More sharing options...
akira2891 Posted November 17, 2014 Author Share Posted November 17, 2014 (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 November 17, 2014 by akira2891 Link to comment Share on other sites More sharing options...
alienclone Posted November 17, 2014 Share Posted November 17, 2014 https://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm 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 More sharing options...
akira2891 Posted November 17, 2014 Author Share Posted November 17, 2014 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 More sharing options...
Solution alienclone Posted November 17, 2014 Solution Share Posted November 17, 2014 i use ="" to represent empty 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 More sharing options...
akira2891 Posted November 17, 2014 Author Share Posted November 17, 2014 ok thx now it works Link to comment Share on other sites More sharing options...
water Posted November 17, 2014 Share Posted November 17, 2014 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 akira2891 1 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
akira2891 Posted November 17, 2014 Author Share Posted November 17, 2014 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 More sharing options...
alienclone Posted November 17, 2014 Share Posted November 17, 2014 If GUICtrlRead($input1) <> "" Then ; this should work If not GUICtrlRead($input1) = "" Then ; this may also work akira2891 1 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 More sharing options...
akira2891 Posted November 17, 2014 Author Share Posted November 17, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now