Vikramjeet Posted March 30, 2020 Share Posted March 30, 2020 For $A1 = 8 To $EPRrow1 If $DutyAdd <> "" and $KeyAdd1 <> "" and $DutyDel <> "" and $KeyDel1 <> "" Then Send("HB"& ($oExcel.Application.Cells($A1,2).Value) & ($oExcel.Application.Cells($A1,3).Value)) Sleep(300) Send("{ENTER}") Sleep(400) Send("H/AUTH "& $AUTH1) Sleep(300) Send("{ENTER}") Sleep(300) ADDDTY () DELDTY () ADDKEY () DELKEY () Hello. I am trying to run functions ADDDTY () , DELDTY () , ADDKEY () , DELKEY () one after the other. However, only the 1st Function (ADDDTY) runs and the rest do not. How do I make sure that all 4 functions run Link to comment Share on other sites More sharing options...
Subz Posted March 30, 2020 Share Posted March 30, 2020 Have a look at the _Excel functions within AutoIt Help File, also you would need to post the functions so we can see why they're not working. Link to comment Share on other sites More sharing options...
Vikramjeet Posted March 30, 2020 Author Share Posted March 30, 2020 Thank you for your response. By themselves, each function works. Even if I rearrange the order, then only the first function works. Func ADDDTY () Send("{ESC}") Sleep(300) Send("H/DTY"& $DutyAdd) Sleep(400) Send("{ENTER}") Sleep(600) Send("{ESC}") Sleep(100) EndFunc ;========================================================================================================== ;===== ** DELETE DUTY CODE ** ======================================================================================== Func DELDTY () Send("{ESC}") Sleep(300) Send("H/DTYD"& $DutyDel) Sleep(400) Send("{ENTER}") Sleep(600) Send("{ESC}") Sleep(100) EndFunc Link to comment Share on other sites More sharing options...
Subz Posted March 30, 2020 Share Posted March 30, 2020 Add some error checking for example after each function, MsgBox(4096, "Debug", "ADDDTY() Run") etc... my guess is that it's losing focus of the application and so you aren't seeing any results, I'd recommend using ControlSend as you can then define the application path. Link to comment Share on other sites More sharing options...
Vikramjeet Posted March 30, 2020 Author Share Posted March 30, 2020 I think what is happening is that once it leaves the main function and goes to ADDDTY (), it never comes back to execute the next function DELDTY () expandcollapse popupFor $A1 = 8 To $EPRrow1 If $DutyAdd <> "" and $KeyAdd1 <> "" and $DutyDel <> "" and $KeyDel1 <> "" Then Send("HB"& ($oExcel.Application.Cells($A1,2).Value) & ($oExcel.Application.Cells($A1,3).Value)) Sleep(300) Send("{ENTER}") Sleep(400) Send("H/AUTH "& $AUTH1) Sleep(300) Send("{ENTER}") Sleep(300) ADDDTY () DELDTY () ;===== ** ADD DUTY ** ======================================================================================== Func ADDDTY () Send("{ESC}") Sleep(300) Send("H/DTY"& $DutyAdd) Sleep(400) Send("{ENTER}") Sleep(600) Send("{ESC}") Sleep(100) EndFunc ;========================================================================================================== ;===== ** DELETE DUTY ** ======================================================================================== Func DELDTY () Send("{ESC}") Sleep(300) Send("H/DTYD"& $DutyDel) Sleep(400) Send("{ENTER}") Sleep(600) Send("{ESC}") Sleep(100) EndFunc ;===================================== Link to comment Share on other sites More sharing options...
Subz Posted March 30, 2020 Share Posted March 30, 2020 Thats why you need to do error checking like I mentioned, can you tell us what app this is for? ADDDTY () MsgBox(4096, "Debug", "ADDDTY() has run") DELDTY () MsgBox(4096, "Debug", "DELDTY() has run") Link to comment Share on other sites More sharing options...
Vikramjeet Posted March 30, 2020 Author Share Posted March 30, 2020 (edited) ADDDTY () MsgBox($MB_ICONINFORMATION, "Debug", "ADDDTY has run") DELDTY () MsgBox($MB_ICONINFORMATION, "Debug", "DELDTY has run") Did that. I dont get the the first message. Which makes me feel that it is not coming back once it goes to ADDDTY () Edited March 30, 2020 by Vikramjeet Link to comment Share on other sites More sharing options...
Subz Posted March 30, 2020 Share Posted March 30, 2020 Then you need to debug ADDDTY() function by adding ConsoleWrite, MsgBox etc.. to see what is occurring. Link to comment Share on other sites More sharing options...
TheXman Posted March 31, 2020 Share Posted March 31, 2020 (edited) 1 hour ago, Vikramjeet said: I think what is happening is that once it leaves the main function and goes to ADDDTY (), it never comes back to execute the next function DELDTY () expandcollapse popupFor $A1 = 8 To $EPRrow1 If $DutyAdd <> "" and $KeyAdd1 <> "" and $DutyDel <> "" and $KeyDel1 <> "" Then Send("HB"& ($oExcel.Application.Cells($A1,2).Value) & ($oExcel.Application.Cells($A1,3).Value)) Sleep(300) Send("{ENTER}") Sleep(400) Send("H/AUTH "& $AUTH1) Sleep(300) Send("{ENTER}") Sleep(300) ADDDTY () DELDTY () ;===== ** ADD DUTY ** ======================================================================================== Func ADDDTY () Send("{ESC}") Sleep(300) Send("H/DTY"& $DutyAdd) Sleep(400) Send("{ENTER}") Sleep(600) Send("{ESC}") Sleep(100) EndFunc ;========================================================================================================== ;===== ** DELETE DUTY ** ======================================================================================== Func DELDTY () Send("{ESC}") Sleep(300) Send("H/DTYD"& $DutyDel) Sleep(400) Send("{ENTER}") Sleep(600) Send("{ESC}") Sleep(100) EndFunc ;===================================== Where is the NEXT that ends the FOR statement? Also, where is the EndIf that ends the IF statement? Edited March 31, 2020 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Vikramjeet Posted March 31, 2020 Author Share Posted March 31, 2020 expandcollapse popup;===== ** SELECTION ** ======================================================================================== START () FUNC START () If $DutyCodeAdd <> "" Then ;'If' this applies then run ADDDTY() and then move to the next If. However if this 'If' does not apply, then move to next 'If" For $A1 = 8 To $EPRrow1 Send("HB"& ($oExcel.Application.Cells($A1,2).Value) & ($oExcel.Application.Cells($A1,3).Value)) Sleep(300) Send("{ENTER}") Sleep(400) Send("H/AUTH "& $AUTH1) Sleep(300) Send("{ENTER}") Sleep(300) ADDDTY () If $DutyCodeDel <> "" Then ;'If' this applies then run DELDTY() and then move to the next If. However if this 'If' does not apply, then move to ;next 'If' DELDTY () If $KeywordsAdd1 <> "" Then ; 'If' this applies then run ADDKEY() and then move to the next If. However if this 'If' does not apply, then ;move to next 'If" ADDKEY () If $KeywordsDel1 <> "" Then ;'If' this applies then run DELKEY(). However if this 'If' does not apply, then do nothing DELKEY () EndIf EndIf EndIf Send("HE") Sleep(300) Send("{ENTER}") Sleep(300) Send("{ESC}") Sleep(300) Send("I") Sleep(300) Send("{ENTER}") Sleep(300) Send("{ESC}") Sleep(300) Next EndIf $oExcel.Application.Quit MsgBox($MB_ICONINFORMATION, "INFORMATION", "Processing Complete") EndFunc ;===== ** ADD DUTY CODE ** ======================================================================================== Func ADDDTY () Send("{ESC}") Sleep(300) Send("H/DTY"& $DutyCodeAdd) Sleep(400) Send("{ENTER}") Sleep(600) Send("{ESC}") Sleep(100) EndFunc ;========================================================================================================== ;===== ** DELETE DUTY CODE ** ======================================================================================== Func DELDTY () Send("{ESC}") Sleep(300) Send("H/DTYD"& $DutyCodeDel) Sleep(400) Send("{ENTER}") Sleep(600) Send("{ESC}") Sleep(100) EndFunc ;========================================================================================================== Here is the code. I am trying to do this 1- If Condition 1 matches ,Then (If Condition 1 does not match then do nothing and move to step 2) Do something and move to next If. (Step 2) 2- If Condition 2 matches, Then (If Condition 2 does not match then do nothing and move to step 3) Do something and move to next If. (Step 3) 3- If Condition 3 matches, Then (If Condition 3 does not match then do nothing and move to step 4) Do something and move to next If. (Step 4) 4- If Condition 4 matches, Then Do something and End Link to comment Share on other sites More sharing options...
TheXman Posted March 31, 2020 Share Posted March 31, 2020 You obviously are not running your code through AU3Check. Because if you were, you would see the following errors and warnings: expandcollapse popup>Running AU3Check (3.3.14.5) params:-w 3 -w 4 -w 6 from:C:\Portable Apps\AutoIt3 input:C:\Projects\Personal\AutoIt\Test\a3_temp.au3 "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(5,17) : warning: $DutyCodeAdd: possibly used before declaration. If $DutyCodeAdd <> ~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(6,28) : warning: $EPRrow1: possibly used before declaration. For $A1 = 8 To $EPRrow1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(7,59) : warning: $oExcel: possibly used before declaration. Send("HB"& ($oExcel.Application.Cells($A1,2).Value) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(11,31) : warning: $AUTH1: possibly used before declaration. Send("H/AUTH "& $AUTH1) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(16,29) : warning: $DutyCodeDel: possibly used before declaration. If $DutyCodeDel <> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(18,34) : warning: $KeywordsAdd1: possibly used before declaration. If $KeywordsAdd1 <> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(20,38) : warning: $KeywordsDel1: possibly used before declaration. If $KeywordsDel1 <> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(41,31) : warning: $MB_ICONINFORMATION: possibly used before declaration. MsgBox($MB_ICONINFORMATION, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(5,17) : error: $DutyCodeAdd: undeclared global variable. If $DutyCodeAdd <> ~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(6,28) : error: $EPRrow1: undeclared global variable. For $A1 = 8 To $EPRrow1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(7,59) : error: $oExcel: undeclared global variable. Send("HB"& ($oExcel.Application.Cells($A1,2).Value) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(11,31) : error: $AUTH1: undeclared global variable. Send("H/AUTH "& $AUTH1) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(16,29) : error: $DutyCodeDel: undeclared global variable. If $DutyCodeDel <> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(18,34) : error: $KeywordsAdd1: undeclared global variable. If $KeywordsAdd1 <> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(20,38) : error: $KeywordsDel1: undeclared global variable. If $KeywordsDel1 <> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(41,31) : error: $MB_ICONINFORMATION: undeclared global variable. MsgBox($MB_ICONINFORMATION, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(19,25) : error: ADDKEY(): undefined function. ADDKEY () ~~~~~~~~~~~~~~~~~~~~~~~~^ "C:\Projects\Personal\AutoIt\Test\a3_temp.au3"(21,29) : error: DELKEY(): undefined function. DELKEY () ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Projects\Personal\AutoIt\Test\a3_temp.au3 - 10 error(s), 8 warning(s) CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Vikramjeet Posted March 31, 2020 Author Share Posted March 31, 2020 (edited) Complete code in the attached file. Edited March 31, 2020 by Vikramjeet Link to comment Share on other sites More sharing options...
TheXman Posted March 31, 2020 Share Posted March 31, 2020 (edited) 23 minutes ago, Vikramjeet said: Here is the code. I am trying to do this 1- If Condition 1 matches ,Then (If Condition 1 does not match then do nothing and move to step 2) Do something and move to next If. (Step 2) 2- If Condition 2 matches, Then (If Condition 2 does not match then do nothing and move to step 3) Do something and move to next If. (Step 3) 3- If Condition 3 matches, Then (If Condition 3 does not match then do nothing and move to step 4) Do something and move to next If. (Step 4) 4- If Condition 4 matches, Then Do something and End If <cond1> Then ;do something EndIf If <cond2> Then ;do something EndIf If <cond3> Then ;do something EndIf If <cond4> Then ;do something EndIf Exit or Return Edited March 31, 2020 by TheXman Vikramjeet 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Vikramjeet Posted March 31, 2020 Author Share Posted March 31, 2020 That did the trick !!! Lesson learned. Thank you so much TheXman Link to comment Share on other sites More sharing options...
Vikramjeet Posted March 31, 2020 Author Share Posted March 31, 2020 For $A1 = 8 To $EPRrow1 Send("HB"& ($oExcel.Application.Cells($A1,2).Value) & ($oExcel.Application.Cells($A1,3).Value)) Sleep(300) Send("{ENTER}") Sleep(400) Send("H/AUTH "& $AUTH1) Sleep(300) Send("{ENTER}") Sleep(300) If $DutyCodeAdd <> "" Then ADDDTY () EndIf If $DutyCodeDel <> "" Then DELDTY () EndIf If $KeywordsAdd1 <> "" Then ADDKEY () EndIf If $KeywordsDel1 <> "" Then DELKEY () EndIf Send("HE") Sleep(300) Send("{ENTER}") Sleep(300) Send("{ESC}") Sleep(300) Send("I") Sleep(300) Send("{ENTER}") Sleep(300) Send("{ESC}") Sleep(300) Next Lean and clean 😉 Link to comment Share on other sites More sharing options...
TheXman Posted March 31, 2020 Share Posted March 31, 2020 (edited) If you are just executing a single statement, then you can make it even leaner & cleaner: If $DutyCodeAdd <> "" Then ADDDTY() If $DutyCodeDel <> "" Then DELDTY() If $KeywordsAdd1 <> "" Then ADDKEY() If $KeywordsDel1 <> "" Then DELKEY() 😀 Edited March 31, 2020 by TheXman Vikramjeet 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Vikramjeet Posted March 31, 2020 Author Share Posted March 31, 2020 Nice. Thank you!! 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