Jump to content
Sign in to follow this  
TJCochran

Renaming a File in a loop

Recommended Posts

TJCochran

I am trying to write a short program that can basically click a mouse (over say the scan button for a scanner) every 2 minutes for a few hours. I now have a program that can do the clicking, but I am having trouble figuring out the loop (I literally started using AutoIt today). I want the file name of each scan to change (otherwise it is overwritten) to scan01, scan02, etc. Any suggestions?

Opt("MouseCoordMode",0)

MouseClick("left", 1180,200,3)

;figure out how to rename file
Sleep(60000) ; 60 seconds so the scanner can finish before the program tries to move and rename the file
FileMove("C:\Users\TJCochran\Documents\doc.jpg", "C:\Users\TJCochran\Desktop\Bacteria Scans\Scan", 0)
Sleep(120000) ; 2 minutes

Share this post


Link to post
Share on other sites
kylomas

TJCochran,

Some possibilities, see the help file for syntax / usage.

Also, use the full version of SCITE.

#include <date.au3>

Opt("MouseCoordMode",0)

local $file_incr = 1        ; suffix file with a number...could also be a data/time stamp

while 1                        ; start loop

    MouseClick("left", 1180,200,3)

    ;figure out how to rename file
    Sleep(60000) ; 60 seconds so the scanner can finish before the program tries to move and rename the file

    ; using an incrementing number

    FileMove("C:\Users\TJCochran\Documents\doc.jpg", "C:\Users\TJCochran\Desktop\Bacteria Scans\Scan" & $file_incr, 0)
    $file_incr += 1                ; increment file sequence number

    ; using timestamp

    FileMove("C:\Users\TJCochran\Documents\doc.jpg", "C:\Users\TJCochran\Desktop\Bacteria Scans\Scan" & _nowcalc(), 0)

    Sleep(120000) ; 2 minutes

wend                        ; end loop

kylomas

edit: incidentally, none of the above was tested, just suggestions

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
TJCochran

This is wonderful! It works perfectly. Thank you very much!

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  

×