
Vikramjeet
Active Members-
Posts
89 -
Joined
-
Last visited
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by Vikramjeet
-
Thank You!!!
-
If StringInStr($line, 'BOB') Then How can I make the script read ONLY BOB in the string and ignore BOBBY or ABCBOB Thank You
-
Sleep Until specific Text is found in Log
Vikramjeet replied to Vikramjeet's topic in AutoIt General Help and Support
I figured it. Thank you for looking Do Local $file = "CAPTURE.log" FileOpen($file, 0) For $t = _FileCountLines($file) - 7 to _FileCountLines($file) $line = FileReadLine($file, $t) If StringInStr($line, 'PROCESS COMPLETE') Then ExitLoop EndIf Next Until StringInStr($line, 'PROCESS COMPLETE') -
Sleep Until specific Text is found in Log
Vikramjeet replied to Vikramjeet's topic in AutoIt General Help and Support
;***************************************************************** Local $file = "CAPTURE.log" FileOpen($file, 0) For $t = _FileCountLines($file) - 7 to _FileCountLines($file) $line = FileReadLine($file, $t) $WaitTill = StringInStr($line, "PROCESS COMPLETE") ;Sleep (2000) Next Do sleep (1000) Until $WaitTill = "PROCESS COMPLETE" ;***************************************************************** I am sending formats using key strokes into an app. The app accepts the format and returns a response. The app takes more time to return a response for certain formats. I want the script to sleep till it gets the defined response (PROCESS COMPLETE). I am not calling to read the logs constantly. I only call to read the logs at specific moments during the run and only look at the last 7 lines of the log file. The log file is in a notepad like format and may be up to 5000 lines. After I call the script to look at the last 7 lines of the log file, I want it to wait till it finds 'PROCESS COMPLETE' message in the log file. -
I have a script that reads the last 7 lines of an active log file. By active I mean that the file is being written while the script runs. How can I make the script to 1- keep reading the last 7 lines till a specific text appears. 2- Once the specific text appears, then get out of the loop and proceed to other tasks Thank You
-
include-once #include <File.au3> #include <Excel.au3> #include <String.au3> #include <MsgBoxConstants.au3> Local $file = "TEST.log" FileOpen($file, 0) $TTLPax = 1 For $i = _FileCountLines($file) - $TTLPax to _FileCountLines($file) $line = FileReadLine($file, $i) Global $TktNo = StringMid($line, 8, 13) ; reads 13 characters from $Line starting from the 8th character msgbox(0,'',$TktNo) ; This is just for me to debug For $NoOfPax = 1 to 2 local $TTLSeg = 2 msgbox(0,'',$TTLSeg) msgbox(0,'',"7ABC"& $TktNo &"'N"& $NoOfPax &".1'C1,2'S1,2'B") ; This makes 7ABC1234567890123'N1.1'C1,2'S1,2'B ;But in the next loop I want the value to be 7ABC1234567890333'N2.1'C1,2'S1,2'B Next ExitLoop Next *TEST JAMES BAKER 1.NYC-23JAN 2.TJ 1234567890123 3.TJ 1234567890333 I am reading a file with last 5 lines as above. I want to be able to loop through and pick the values as follows 1- Pick 1234567890123 2- Use it to build a format with N1.1 3- Pick 1234567890333 2- Use it to build a format with N2.1 Need help with the loop. Thank You
-
$iCount = ($oExcel.Application.Cells($A1,6).Value) $step = 10 For $N1 = 7 To 10 * $iCount Step $step Send("-"& ($oExcel.Application.Cells($A1,$N1).Value) &"/"& ($oExcel.Application.Cells($A1,$N1+1).Value)) Sleep(400) Send("{ENTER}") Sleep(700) Send("{ESC}") Sleep(300) Send ($oExcel.Application.Cells($A1,$N1+7).Value) Sleep(400) Send("{ENTER}") Sleep(700) Send("{ESC}") Sleep(300) I think we got it to work. 1- So I wanted the script to read the data from cell ($A1,6) to know how many times to loop. 2- If the value in cell ($A1,6) is 5, then the script will loop from 7 to 50 (10 X 5) 3- Because of the $Step, it will jump 10 numbers. That means it will go 7, 17 (7+10), 27 (17+10), 37 (27+10), 47 (37+10) 4- The loop will stop at 47 since 50 is the end of loop and next loop counter value will go over 50 5- $N1 starts from value 7 which make the script read cell value starting ($A1,7) Thank you for your help We did it đŸ™‚
-
$step = 10 For $N1 = 7 To (10 X ($oExcel.Application.Cells($A1,2).Value)) Step $step How to indicate the loop 'To' value as 10 x value extracted from a specific excel cell, and start from 7 and then increase the loop in multiples - 7, (10X2) = 20, (10X3) = 30, (10X4) = 40. But because we start from 7 and step up by 10, the loop counter would go 7, 17, 27, 37.....
-
For $A1 = 12 To 11 + $Total For $B1 = 1 To ($oExcel.Application.Cells($A1,6).Value) ; This value is from the Excel file. It can be from 1 - 9. For $N1 = 7 To ??? ; This is based on the value of $B1 ((1 = 7, 2 = 17, 3 = 27, 4 = 37, 5 = 47) Send("-"& ($oExcel.Application.Cells($A1,$N1).Value) &"/"& ($oExcel.Application.Cells($A1,$N1+1).Value)) Sleep(400) Send("{ENTER}") Sleep(700) Next Next Next I am not able to figure how to loop $N1 as follows If the Value of $B1 = 1 then $N1 = 7 If the Value of $B1 = 2 then $N1 = 17 If the Value of $B1 = 3 then $N1 = 27 If the Value of $B1 = 4 then $N1 = 37 The value of $N1 comes from $B1 where 1 = 7, 2 = 17, 3 = 27, 4 = 37, 5 = 47) Thank You
-
Nice. Thank you!!
-
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 đŸ˜‰
-
That did the trick !!! Lesson learned. Thank you so much TheXman
-
Complete code in the attached file.
-
;===== ** 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
-
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 ()
-
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 () 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 () ;===== ** 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 ;=====================================
-
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
-
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
-
Got it. Thank you so much!!!
-
-
Thank you for your help. Excel file attached Details.xlsm
-
#include-once #include <File.au3> #include <MsgBoxConstants.au3> Global $filePath $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 0 WinActivate("Notepad") Global $hWnd = WinWaitActive("Notepad", "", 5) $filePath = _PathFull("Details.xlsm") $oExcel.Application.WorkBooks.Open ($filePath) Global $HomeStation1 = $oExcel.Application.Cells(7,2).Value Global $AccountCode1 = $oExcel.Application.Cells(7,3).Value Global $OAC1 = $oExcel.Application.Cells(7,4).Value Global $Suffix1 = $oExcel.Application.Cells(7,5).Value Global $AUTH1 = $oExcel.Application.Cells(7,6).Value START () Func START () Send("{ESC}") Sleep(700) Send("I") Sleep(700) Send("{ENTER}") Sleep(2000) ;I want to pick up data from Sheet 2, cell B2 and send it to notepad Send("{ESC}") Sleep(700) Send("AAA"& $HomeStation1) ;This data comes from Sheet 1 Sleep(2000) Send("{ENTER}") Sleep(2000) Send("{ESC}") Sleep(700) $oExcel.Application.Quit MsgBox(4096, "INFORMATION", "Processing Complete") EndFunc I am trying a script that picks data from an excel file and sends it to an open notepad file. I am not able to get my head around how to switch between 2 sheets within one Excel file. My Excel file 'Details.xlsm' has 2 sheets. I want to be able to read data from both the sheets without opening the file. Your help with script is much appreciated
-
Error:Error opening File
Vikramjeet replied to Vikramjeet's topic in AutoIt General Help and Support
Got it. It is working now. Thanks for your advice -
#include-once #include <MsgBoxConstants.au3> #Include <File.au3> $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 0 HotKeySet("{DEL}", "ExitScript") Func ExitScript() $oExcel.Application.Quit MsgBox($MB_ICONERROR, "MESSAGE", 'PROCESS ABORTED') Exit EndFunc WinActivate("Application") Global $hWnd = WinWaitActive("Application", "", 5) $oExcel.Application.WorkBooks.Open("C:\Users\Charlie\Desktop\Data.xlsx") I do not have AutoIt installed on my machine. I am using the 'AutoIt– Self Extracting Archive' to execute my script. I am getting the below error when I execute the script. What am I missing Line 2 (File "C\Users\Charlie\Desktop\Script.au3"): #include <MsgBoxConstants.au3> Error:Error opening File
-
#include <GuiConstantsEx.au3> $hGUI = GUICreate("CONTROL", 250, 100) GUICtrlCreateLabel("START or STOP", 57, 20, 150, 20) GUICtrlSetFont(3, 11, 2000) $StartService_Button = GUICtrlCreateButton("Start", 30, 55, 75, 25) $StopService_Button = GUICtrlCreateButton("Stop", 145, 55, 75, 25) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $StartService_Button _ServiceStartStop(1) Case $StopService_Button _ServiceStartStop() EndSwitch WEnd Func _ServiceStartStop($sFlag = 0) If $sFlag = 1 Then Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "C:\Users\Charlie\Desktop\Script1.au3"') Else ; How do I force stop Script 1 when I hit the STOP button EndIf EndFunc I have been able to create a Pop up with options 'START' and 'STOP'. I am able to start another script - Script1.au3 when I click the 'START' button. However I am not able to figure how to force stop Script1.au3 while it is running. My I please get ideas on how to stop Script1.au3 using the 'STOP' button. Thanks