Sign in to follow this  
Followers 0
Alan

Incrementing DOWN command?

13 posts in this topic

I have included my total script at the end of this POST. What this script does is open an excel file and save it as a TAB delimited text file. The script runs one time, selects the first excel file in the OPEN dialog box, opens it, and then saves it as a TAB delimited text file. However, what I want to be able to do is to run this complete script 800 times and each time I want to select the next excel file (there are 800 of them) to open and save as a TAB delimited text file. Midway through the script I have put some comments around that part of the script where I need to increment the DOWN command by one each time the complete script is run so it will select the next excel file to open. Just as a note, I know I also need to add the command at the beginning and end of the script to repeat the complete script 800 times. I think I know how to do that. What I need help with is incrementing the DOWN command in the middle of the script so it will select the next file to open.

Can anyone help me solve this problem? Thanks in advance!

; =========== Scriptlet Starts Here ===========

Send, ^{ESC}

Send, {UP 7}

Send, {RIGHT}{ENTER}

Send, {LEFT}

send, {DOWN 3}{ENTER}

WinWaitActive, Microsoft Excel - PERSONAL

Send, !{F}{ENTER}

Repeat, 4

Send, {TAB}

EndRepeat

Send, {RIGHT}{ENTER}

Repeat, 6

Send, {TAB}

EndRepeat

Send, {DOWN}

Send, {DOWN}

Send, {DOWN}{ENTER}

Send, {DOWN}

;=============

;INCREMENT THE {DOWN} COMMAND TO SELECT NEXT INDIVIDUAL EXCEL FILE EACH TIME THE TOTAL SCRIPT LOOPS

Send, {DOWN}{ENTER}

;=============

Send, {TAB}

Send, {TAB}

Send, {TAB}{ENTER}

Send, !{F}

Send, {DOWN}

Send, {DOWN}{ENTER}

Send, {TAB}

Send, {DOWN}

Send, {DOWN}

Send, {DOWN}

Send, {DOWN}{ENTER}

Send, {TAB}

Send, {TAB}

Send, {TAB}

Send, {UP}

Send, {Up}

Send, {Up}{ENTER}

Send, {TAB}

Send, {TAB}

Send, {TAB}

Repeat, 9

Send, {DOWN}

EndRepeat

Send, {DOWN}{ENTER}

Send, {TAB}

Send, {TAB}

Send, {TAB}{ENTER}{ENTER}{ENTER}

Send, !{F}

Repeat, 7

Send, {DOWN}

EndRepeat

Send, {DOWN}{ENTER}

Send, {RIGHT}{ENTER}

; =========== Scriptjlet Ends Here ===========

Share this post


Link to post
Share on other sites



Do you mean the first time through press down once, the second time press down twice, etc? If that is the case, just put that one Send("{DOWN}") in a loop that loops $n times, and just keep incrementing $n.

Is that what you meant?

Share this post


Link to post
Share on other sites

Yes this is what I want to do. However, I do not know how to do the loop correctly. Can you help?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$n = 1
$Count = 0
While $Count <> 800
   Send("{DOWN " & $n & "}")
   $n = $n + 1
   $Count = $Count + 1
Wend

Using a While...Wend loop is just one way of doing this, you could also use a Do...Until and a For...Next Loop

Edited by Burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

$i = 1
Do
  ; All your other code

    Send("{DOWN " & $x & "}")

  ; All your other code

    $i = $i + 1
Until $i = 800

Edited by automagician

Share this post


Link to post
Share on other sites

Thanks for the help! I'll give it a try...

Share this post


Link to post
Share on other sites

Automagician

I entered all the code as follows but I get an AutoIt Error that says:

Line1:

$1=1

Error: Unknown command

$i = 1

Do

; All your other code

Send, ^{ESC}

Send, {UP 7}

Send, {RIGHT}{ENTER}

Send, {LEFT}

send, {DOWN 3}{ENTER}

WinWaitActive, Microsoft Excel - PERSONAL

Send, !{F}{ENTER}

Repeat, 4

Send, {TAB}

EndRepeat

Send, {RIGHT}{ENTER}

Repeat, 6

Send, {TAB}

EndRepeat

Send, {DOWN}

Send, {DOWN}

Send, {DOWN}{ENTER}

Send, {DOWN}

Send("{DOWN " & $i & "}")

; All your other code

Send, {TAB}

Send, {TAB}

Send, {TAB}{ENTER}

Send, !{F}

Send, {DOWN}

Send, {DOWN}{ENTER}

Send, {TAB}

Send, {DOWN}

Send, {DOWN}

Send, {DOWN}

Send, {DOWN}{ENTER}

Send, {TAB}

Send, {TAB}

Send, {TAB}

Send, {UP}

Send, {Up}

Send, {Up}{ENTER}

Send, {TAB}

Send, {TAB}

Send, {TAB}

Repeat, 9

Send, {DOWN}

EndRepeat

Send, {DOWN}{ENTER}

Send, {TAB}

Send, {TAB}

Send, {TAB}{ENTER}{ENTER}{ENTER}

Send, !{F}

Repeat, 7

Send, {DOWN}

EndRepeat

Send, {DOWN}{ENTER}

Send, {RIGHT}{ENTER}

$i = $i + 1

Until $i = 2

Share this post


Link to post
Share on other sites

I thought it looked a bit funny lol, with Repeat, 9. I thought he was just showing us that he wanted it repeated 9 times lol.


[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

Yes, I thought something was strange with that too...

Alan, you should upgrade to v3, the syntax is slightly different, but the code that I gave you will work in v3.....sorry for the mixup.

Share this post


Link to post
Share on other sites

Automagician

Thanks for the heads up. I will convert to V3.

Share this post


Link to post
Share on other sites

If your tab delimited files have the same name as the corresponding excel files then you could check each excel file to see if it had a corresponding tab delimited file, If true then move to next excel file, if not, create one.


[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites

quaizywabbit

Thanks for the suggestion. I like it the idea because then I don't have to know exactly how many files I have and then have to loop exactly that many times. Unforetunately being completely new to programming and using AutoIt I was wondering if you could help kick start me by giving me some code ideas on how to implement it.

I thank all you guys for being on the forum and for your willingness to help a newbee.

Alan,

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