Sign in to follow this  
Followers 0
tekhed

Need help getting out of this Loop function

5 posts in this topic

I have been trying for literally days to get ANY type of function to work. I have SCiTE open on the left, AutoIT help open on the right, and I've sat for hours trying all manner of functions with different syntaxes, etc. I am becoming convinced that I do not have a firm enough understanding of this language to accomplish the task I set forth. The script as follows:

$text = ClipGet()

Do

Call("window1")

send("^v{TAB 6}")

Call("window2")

Send("{RIGHT}^c")

Call("window1")

send("^v{TAB 2}")

Call("window2")

Send("{RIGHT}^c")

Call("window1")

send("^v{TAB}")

Call("window2")

Send("{RIGHT}^c")

Call("window1")

send("^v{TAB 4}")

Call("window2")

Send("{RIGHT}^c")

Call("window1")

send("^v{TAB 2}")

Call("window2")

Send("{RIGHT}^c")

Call("window1")

send("^v{TAB}")

Call("window2")

Send("{RIGHT}^c")

Call("window1")

send("^v{ENTER}")

sleep(2000)

send("{ENTER}")

sleep(2000)

Call("window2")

send("{DOWN}{LEFT 6}^ ")

il $text = "done"

Exit

Func window1()

WinActivate("WEBDATA - Microsoft Internet Explorer")

EndFunc

Func window2()

WinActivate("Microsoft Excel - WEBDATA.xls")

EndFunc

Merely copies data from an excel sheet and pastes it into a broswer. I CANNOT FOR THE LIFE OF ME get AutoIT to stop after the cell becomes empty, or even has some type data other than numerical, like "done". Any help would be MUCH appreciated, and I realize I probably should have posted earlier, instead of getting so upset... :)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You think that code runs? You are missing a while statement to match the do statement...

I don't know how to trap excel data, but you could search the forum I believe I have seen something that traps data from excel.

*** Matt @ MPCS

Edited by Matt @ MPCS

Share this post


Link to post
Share on other sites

OK SO MAKE SURE "WEBDATA - Microsoft Internet Explorer" is open and also

"Microsoft Excel - WEBDATA.xls"

I dont have excel in this computer but this should work. There are easier ways to do this and also you should do error checking!!

the first line checks the clipboard so if you have copied the word --- done --- on

the clipboard it will stop before it runs but I figured there was a reason why you

where checking the clipbard before the script copied something to it.

getout(ClipGet()) ;get from the clipboard (your last COPY ? )

window1() ; go to explorer

send("^v{TAB 6}") ;paste

window2() ; go to excel

Send("{RIGHT}^c") ;copy to clipboard

getout(ClipGet()) ;test to see if it is done

window1() ;go to explorer ...... repeat

send("^v{TAB 2}")

Call("window2")

Send("{RIGHT}^c")

window1()

send("^v{TAB}")

Call("window2")

Send("{RIGHT}^c")

window1()

send("^v{TAB 4}")

Call("window2")

Send("{RIGHT}^c")

window1()

send("^v{TAB 2}")

Call("window2")

Send("{RIGHT}^c")

window1()

send("^v{TAB}")

Call("window2")

Send("{RIGHT}^c")

window1()

send("^v{ENTER}")

sleep(2000)

send("{ENTER}")

sleep(2000)

window1()

send("{DOWN}{LEFT 6}^ ")

Func window1()

sleep(100)

WinActivate("WEBDATA - Microsoft Internet Explorer")

sleep(100)

WinWaitActive("WEBDATA - Microsoft Internet Explorer")

sleep(100)

EndFunc

Func window2()

sleep(100)

WinActivate("Microsoft Excel - WEBDATA.xls")

sleep(100)

WinWaitActive("Microsoft Excel - WEBDATA.xls")

sleep(100)

EndFunc

Func getout($text)

if $text = "done" Then

Exit

EndIf

EndFunc

; just copied your script and fixed the sintax

Share this post


Link to post
Share on other sites

Doesn't work. I can't even get ClipGet() to play nice with Excel at all, with more simple requests. Seems like Excel doesn't copy data to the clipboard in a way that lets AutoIT read it correctly(?) or something... BUT, it WILL work if I change it a bit and the getout() function reads:

Func getout($text)

if $text = 99999 Then

Exit

EndIf

EndFunc

Unfortunately, I really would like it to work using a single word, such as "done". Some of the other data being copied are #'s themselves, so it might look confusing, or end unexpectedly. Thanks for your help though!

P.S. What is 'error checking'? I know it sounds like a naive question, but I'm unsure of the definition.

Share this post


Link to post
Share on other sites

Just found out copying a cell from Excel might be seen as a carriage return when pasted elsewhere, which is why I couldn't use the @error function when the script reached a blank cell either... :)

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  
Followers 0