aviv9 Posted March 16, 2013 Share Posted March 16, 2013 Hello my friends, I wrote a simple script that writes a column in excel to a web page. But the script opens the excel again and again for no reason This is my script: Local $oExcel = _ExcelBookOpen(//here I put the excel path) Global $aArray = _ExcelReadSheetToArray($oExcel) MouseClick("left",$start_pos_web_x,$start_pos_web_y,1,0) For $i = 1 To 5 Send($aArray[$i][1]) Send("{TAB}") Send("{TAB}") Next I want to paste the array items in the web page (first I go to the first form-which is done with the mouseClick function, and then I skip the forms with 2 tabs). I don't understand why it opens the excel each time (its not even in a loop). Link to comment Share on other sites More sharing options...
water Posted March 16, 2013 Share Posted March 16, 2013 Is this the whole script? 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...
aviv9 Posted March 16, 2013 Author Share Posted March 16, 2013 this is most of the script. This is the full one: #include <Array.au3> #include <Excel.au3> HotKeySet("t","doWork") HotKeySet("{ESC}", "Terminate") While 1 Sleep(100) WEnd Func doWork() Const $sFilePath1 = "//my excel file" Global $oExcel = _ExcelBookOpen($sFilePath1) Const $start_pos_web_x=890,$start_pos_web_y=287 If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "File does not exist - Shame on you!") Exit EndIf Global $aArray = _ExcelReadSheetToArray($oExcel) MouseClick("left",$start_pos_web_x,$start_pos_web_y,1,0) For $i = 1 To 5 Send($aArray[$i][1]) Send("{TAB}") Send("{TAB}") Next EndFunc Func Terminate() Exit EndFunc Link to comment Share on other sites More sharing options...
FireFox Posted March 16, 2013 Share Posted March 16, 2013 Hi, The HotKeySet function calls your function until you release the key. Add this in your function to avoid the overlapping : Func doWork() Local Static $blFuncFinished = True If Not $blFuncFinished Then Return ;void $blFuncFinished = False ;doWork here $blFuncFinished = True EndFunc Br, FireFox. Link to comment Share on other sites More sharing options...
aviv9 Posted March 16, 2013 Author Share Posted March 16, 2013 (edited) Thanks a lot that solved the problem. Edited March 16, 2013 by aviv9 Link to comment Share on other sites More sharing options...
FireFox Posted March 16, 2013 Share Posted March 16, 2013 (edited) Oh and please use the autoit tags to post your code Edited March 16, 2013 by FireFox Link to comment Share on other sites More sharing options...
water Posted March 16, 2013 Share Posted March 16, 2013 A few suggestions on how to improve your script:Always check for errors immediately after a function call e.g. after _ExcelBookOpenDon't use screen coordinates to click on buttons or enter data. They depend ons creen resolution and position of the window you try to automateUse the IE UDF to enter data into web form fields (if you use the Internet Explorer) 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...
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