Jump to content

Recommended Posts

Posted

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 ===========

Posted

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?

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

qq

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
Posted

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

Posted

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.

Posted

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
Posted

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,

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...