Vikramjeet Posted August 17, 2018 Share Posted August 17, 2018 I have the below script where the sequence is very important as the 1st Script generates a log file and then the 2nd Script uses the value from the log file as the loop counter. Here is the what I want and the sequence Script 1 1- Send("S*D/<The value here should come from cell A1 of excel workbook data.xlsx>/17AUG/US") so the keystrokes sent would be e.g. S*D/321/17AUG/US (321 was the value in excel cell A1) Script 2 2- After Script 1 is complete, Script 2 performs its actions which is sending formats in a loop a certain number of times 3- Once Script 2 completes its actions, I want to go back to Script 1 and this time pick data from Cell A2 of the excel workbook and perform its actions 4- This loop continues till there is no more cells with a value in column A of Excel workbook expandcollapse popup;Script 1 #include <MsgBoxConstants.au3> WinActivate("Application") WinWaitActive("Application") Send("S*D/$Value from Excel$/17AUG/US") Sleep(1000) Send("{ENTER}") Sleep(2000) Send("MB") Sleep(1000) Send("{ENTER}") Sleep(3000) Script2() Func Script2() Local $iPID = Run("Script2.exe") EndFunc ;Script2 #include <MsgBoxConstants.au3> $file = @ScriptDir & "\T.log" $iNum = StringRegExp(FileRead($file), "(?sm).*^\h*(\d{1,3})", 1)[0] ConsoleWrite($iNum & @CRLF) WinActivate("Application") Local $hWnd = WinWaitActive("Application", "", 5) If $hWnd Then For $i = 1 To $iNum Send("GTIM"& $i &"/OVR") ;Send("GTIM"& $i &"/OVR "{ENTER}"") Sleep(1000) ;Send("/OVR") Send("{ENTER}") Sleep(1000) Next Else MsgBox(0, "", '"Application" window not found.') EndIf Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted August 17, 2018 Share Posted August 17, 2018 @Vikramjeet Why don't you use Excel UDF to automate Excel stuffs? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Vikramjeet Posted August 17, 2018 Author Share Posted August 17, 2018 1 hour ago, FrancescoDiMuro said: @Vikramjeet Why don't you use Excel UDF to automate Excel stuffs? I would love to. I started with AutoIt 1 week ago. I have no knowledge or experience of writing scripts. I will work on your suggestion. Thank you for your guidance Link to comment Share on other sites More sharing options...
caramen Posted August 18, 2018 Share Posted August 18, 2018 (edited) 12 hours ago, Vikramjeet said: I would love to. I started with AutoIt 1 week ago. I have no knowledge or experience of writing scripts. I will work on your suggestion. Thank you for your guidance You request a lot of coding from other in multiple posts.... Even if we help you* You dont try anything. Exept CTRL - C , V . Try to learn at le@st. Edited August 18, 2018 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
Vikramjeet Posted August 18, 2018 Author Share Posted August 18, 2018 I am trying and struggling with this. Thank you for your help Link to comment Share on other sites More sharing options...
Vikramjeet Posted August 19, 2018 Author Share Posted August 19, 2018 I have managed to capture cell value from Column A, row 1, 2, 3, 4........without opening the excel file. The script makes a certain 'Application' active. Now instead of showing the cell values in a pop up message, I want the script to send it as key strokes to the 'Application'. How can I achieve this $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 0 WinActivate("Application") WinWaitActive("Application") If IsObj($oExcel) Then For $a = 1 to 5 $oExcel.Application.WorkBooks.Open("C:\Users\Charlie\Desktop\Data.xlsx") msgbox(1 ," ", $oExcel.Application.Cells($a,1).Value ) Next EndIf Link to comment Share on other sites More sharing options...
water Posted August 19, 2018 Share Posted August 19, 2018 You open the Excel workbook but do not see it as it is being done invisible 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...
Vikramjeet Posted August 19, 2018 Author Share Posted August 19, 2018 Well, I actually don't want to open the excel file and still read the data. I need to add something to close it or figure a way to read without opening it Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted August 19, 2018 Share Posted August 19, 2018 @Vikramjeet How can you see what there is in a box without open it? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Vikramjeet Posted August 19, 2018 Author Share Posted August 19, 2018 3 minutes ago, FrancescoDiMuro said: @Vikramjeet How can you see what there is in a box without open it? This script is reading the cell values and doing exactly what I want. Now I need to close the excel file and set the loop to end when the row is blank $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 0 WinActivate("Application") Local $hWnd = WinWaitActive("Application", "", 5) $oExcel.Application.WorkBooks.Open("C:\Users\Charlie\Desktop\Data.xlsx") If $hWnd Then For $a = 1 to 5 Send("S*D/"& $oExcel.Application.Cells($a,1).Value &"'US/NYC") Sleep(1000) Send("{ENTER}") Sleep(3000) Next EndIf Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted August 19, 2018 Share Posted August 19, 2018 With Excel UDF: _Excel_Open(); _Excel_BookOpen(); _Excel_RangeRead(); _Excel_BookClose(); _Excel_Close(). Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Vikramjeet Posted August 19, 2018 Author Share Posted August 19, 2018 Ok. Let me play with that. Can you help exit the loop in my script if blank cell in found or if it finds the word 'END' in a cell Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted August 19, 2018 Share Posted August 19, 2018 @Vikramjeet After reading the value of the cell in your For...Next loop with _Excel_RangeRead(): If $strCellValue <> "" And $strCellValue <> "END" Then ExitLoop Else ; Do your stuffs EndIf Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Vikramjeet Posted August 27, 2018 Author Share Posted August 27, 2018 expandcollapse popup$oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 0 #include <MsgBoxConstants.au3> WinActivate("Application") Local $hWnd = WinWaitActive("Application", "", 5) $oExcel.Application.WorkBooks.Open("C:\Users\Charlie\Desktop\Data.xlsx") ;Opens the excel file. I need to close it at the end of the script local $iCell = $oExcel.Application.Cells(31,1).Value If $hWnd Then For $a = 1 to $iCell Send("S*D/") Send($oExcel.Application.Cells($a,1).Value) Send("'DUL/SX*E") Sleep(1000) Send("{ENTER}") Sleep(3000) Send("MB") Send("{ENTER}") Sleep(3000) $file = @ScriptDir & "\T.log" $iNum = StringRegExp(FileRead($file), "(?sm).*^\h*(\d{1,3})", 1)[0] ConsoleWrite($iNum & @CRLF) If $hWnd Then For $i = 1 To $iNum Send("DSIM"& $i &"/AST") Sleep(2000) Send("{ENTER}") Sleep(2000) Next Else MsgBox(0, "", '"APPLICATION" window not found.') EndIf Next EndIf I have the above script which opens an excel file as not visible. I need to add a line to close it at the end of the script so the user does not have to do that Link to comment Share on other sites More sharing options...
water Posted August 27, 2018 Share Posted August 27, 2018 Why don't you use the Excel UDF that comes with AutoIt. See functions _Excel_Open, _Excel_BookOpen, _Excel_RangeWrite, _Excel_BookClose and _Excel_Close. 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...
caramen Posted August 28, 2018 Share Posted August 28, 2018 Also if you got a process that is open you can easily close it. My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki 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