Jump to content
Sign in to follow this  
aviv9

script opens the excel file again and again

Recommended Posts

aviv9

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).

Share this post


Link to post
Share on other sites
water

Is this the whole script?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
aviv9

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

Share this post


Link to post
Share on other sites
FireFox

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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
aviv9

Thanks a lot that solved the problem.

Edited by aviv9

Share this post


Link to post
Share on other sites
FireFox

Oh and please use the autoit tags to post your code :)

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
water

A few suggestions on how to improve your script:

  • Always check for errors immediately after a function call e.g. after _ExcelBookOpen
  • Don't use screen coordinates to click on buttons or enter data. They depend ons creen resolution and position of the window you try to automate
  • Use 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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×