Search the Community
Showing results for tags 'else'.
-
hello again, it has been a long time since i have been here and a long time since i last used autoit. ever so often when the time allows me to, then i follow up on an idea that i had a long time ago. i have done all the work on paper but now it is up to writing it in autoit and i keep stumbling over many little issues here and there. sometimes after a few days i will try again and get a step further but sometimes it just will not help no matter how long i try and think about a solution. for most of you it will be the basics but for me it is not all that easy, but at least i give it a try. right, down to business: here is my code: #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <Array.au3> #include <String.au3> ; ; PART 1: define replacements and check with msgbox ; Global $y, $z $y = "Yes" $z = "No" MsgBox(0,"replacements", $y & @CRLF & $z) ;the replacements in a message box ; ; PART 2: set the texts and check via console and msgbox ; Global $my1string = "abab" ;the first specified text MsgBox(0,"my1string", $my1string) ;the message box to output the first specified text Global $my2string = "icic" ;the second specified text MsgBox(0,"my2string", $my2string) ;the message box to output the second specified text ; ; PART 3: transform the strings to individual arrays ; $my1array = StringSplit($my1string, "") $my1array[0] = "" _ArrayDelete($my1array, 0) _ArrayDisplay($my1array, "my1array") ;the display of the first specified array $my2array = StringSplit($my2string, "") $my2array[0] = "" _ArrayDelete($my2array, 0) _ArrayDisplay($my2array, "my2array") ;the display of the first specified array ; ; PART 4: create an empty array for filling ; Global $OutputArray[4] $OutputArray[0] = "" _ArrayDisplay($OutputArray, "OutputArray") ;the display of the first specified array ; ; PART 5: compare & fill empty OutputArray with data after evaluation ; Global $i, $j, $k For $i = 0 to UBound($my1array) -1 For $j = 0 to UBound($my2array) -1 For $k = 0 to UBound($OutputArray) -1 If $my1array[$i] = "a" And $my2array[$j] = "i" Then $OutputArray[$k] = $y Else $OutputArray[$k] = $z EndIf Next Next Next _ArrayDisplay($OutputArray, "OutputArray") ;the display of the Newly filled Array In "Part 2" i make a string that is converted to an array in "Part 3" ... Now, I know that "a" and "i" are always in the exact same spot in both arrays and so i wanted to compare this and make a further array to document my findings by saying "yes" or "no" ... however my new array keeps saying just "no" allthough i can clearly see and know that it should say: yes no yes no my guess is that there is something wrong within my for-loops and that the counting is somehow "off" i guess that when the first for-loop is finished it reaches the second whilst the second for-loop is checking the first which would explain why it always says "no" instead of seeing the obvious. so my question would be: what is wrong with my for-loop? or where am i making an error that ultimately gives me the wrong results? help is much appreciated. kind regards roeselpi PS: sorry for my not so great english spelling ... stupid german sitting here trying out intermediate english skills.
-
$oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 0 #include <MsgBoxConstants.au3> WinActivate("MyApplication") ;Make my application active Local $hWnd = WinWaitActive("MyApplication", "", 5) ;Waits for my application to be the active application $oExcel.Application.WorkBooks.Open("C:\Users\Charlie\Desktop\Data.xlsx") ;Opens an excel file local $iCell = $oExcel.Application.Cells(31,1).Value ;Reads the number from row 1, cell 31 of the open excel file If $hWnd Then For $a = 1 to $iCell Send("G*S/") Send($oExcel.Application.Cells($a,1).Value) Send("'SET/US") Sleep(1000) Send("{ENTER}") Sleep(2000) Send("MB") Send("{ENTER}") Sleep(2000) $file = @ScriptDir & "\DATA.log" $iNum = StringRegExp(FileRead($file), "(?sm).*^\h*(\d{1,3})", 1)[0] ;I am reading the last instance of 1-3 numeric values in the DATA.log file ConsoleWrite($iNum & @CRLF) ;;;This is what I want to add - I also want to read the second last line of the DATA.log file and keep looking for an error 'Invalid Request' ;;;If I find the error 'Invalid Request' then I go back to the start - If $hWnd Then ;;;If I do not find the error then proceed to the below steps If $hWnd Then For $i = 1 To $iNum Send("GSET"& $i &"/USR") Sleep(500) Send("{ENTER}") Sleep(1000) Next Else MsgBox(0, "", '"MyApplication" window not found.') EndIf Next EndIf $oExcel.Application.Quit In the above script, I want to add a condition after 'ConsoleWrite($iNum & @CRLF)'. If I find the text 'Invalid Request' in the second last line of the active DATA.log file then I go back to the start of the loop. However if I do not find the text 'Invalid Request' in the second last line of the Data.log file then i proceed to the further steps
-
my esteemed autoits, i need your help once again. The bold and italics below are what i will be referring to. I need a message box to exit the script if Cancel is pressed and to continue the script if OK is pressed. I have tried multiple ways to do this to no avail. Can someone please breakdown how i go about this via Message box, and or Input box as I'm sure they will follow the same logic. I appreciate your time and assistance. Example: global $url, $username, $password, $sspassword $url = "https://securegateway.fairview.org" $username = "XXX" $password = "YYY" $sspassword = "ZZZ" #include <Constants.au3> #include <msgboxconstants.au3> ShellExecute ($url) WinWaitActive("window") send($username) send("{tab}") send($password) send("{enter}") msgbox($mb_okcancel, "Wait for the page to load then select OK to continue script", "Wait for the page to load then select OK to continue script") if($idok) send("+{tab 8}") send("{enter}") if ($idcancel) then Exit EndIf
-
Hello, i am creating a program that 1. it will check if the computer is connected to the internet 2. will display a message if it is connected 3.if not connected then it will continue to check until the computer connects to the internet then it runs the function which would have been executed if the computer was connected to the internet. what i tried. i connected my computer to the internet and run the code. Which displayed the msgbox that am connected i later turn my internet off and run the cold , i saw it running in process list.. i waited for 5 minutes and it was still waiting for internet connection (running), but when i turned the internet on and got internet connectivity, the app just close without displaying the msg that am connected. Please need help where i went wrong. or if anything should be added. this is the code #AutoIt3Wrapper_icon=1.ico $ping = Ping("www.google.com") If Not @error Then MsgBox("", "AlexFing", "You are connect") Else Do $ping = Ping("www.google.com") Until Not @error EndIf
-
Hello all, i have another question. My script not working, how is it correct ? Need script for this: If is Input 2 empty then call function odoslat() Else call function obrazok2() Thanks for help Func obrazok1() Local $oForm = _IEFormGetObjByName ($oIE, "formpridani") $obrazok1 = GUICtrlRead($Input1) $obrazok2 = GUICtrlRead($Input2) $oUpload = _IEGetObjByName($oForm, "souborp") Sleep (500) _IEAction($oUpload, "focus") Send("{SPACE}") Sleep (500) Send($obrazok1) Send("{Enter}") If $obrazok2 = (0) Then Call ("odoslat") Else Call ("obrazok2") EndIf EndFunc