Jump to content

New to AutoIt


AMS
 Share

Recommended Posts

I need to open an external program and within that program I need to open a file, copy all the text in it, paste it into a new Notepad document, save the Notepad document with the file's original name and then loop this. How would I go about doing this?

;~ Read in a file ->FileFindFirstFile ( "filename" )

;~ Check if file exists ->FileExists ( "path" )

;~ Open file ->FileOpen ( "filename" [, mode ] )

;~ Get file name -> FileRead ( "filehandle/filename" [, count] )

;~ Get text/data from file

;~ open new notepad document

;~ notepad receives data

;~ notepad saves new document as original file name

; repeat ->FileFindNextFile ( search )

This is what I attempted to plan out, but I just started using AutoIt yesterday so I'm not really sure if I'm doing it right.

Thanks for any help you might be able to lend me ;)

Link to comment
Share on other sites

_FileReadToArray and _FileReadFromArray might be other useful function.

Ok, but my current problem is that I can't seem to be able to open a file inside the program. Do you know how I could do that?

Link to comment
Share on other sites

Um, probably is easier to open a file with a program rather than open a file from inside the program.

FileOpen() if it is a txt file.

Which leads to the question of what program are you trying to open.

Edited by xenon2050
Link to comment
Share on other sites

Um, probably is easier to open a file with a program rather than open a file from inside the program.

FileOpen

But then won't the program have to close and then open again once I set the loop up? I was hoping I could just leave the program open and it would batch process them so to speak. I'll try that though and see how it goes.

Link to comment
Share on other sites

But then won't the program have to close and then open again once I set the loop up? I was hoping I could just leave the program open and it would batch process them so to speak. I'll try that though and see how it goes.

Well I'm no Autoit guru so I'm not sure of the best way to do that. Another option is using notepad's command line way to open a file: notepad.exe TextFileName

You could try using shortcut keys ControlSend, but then I don't know how you could select the file you are trying to open.

Link to comment
Share on other sites

If it's a text file, use fileread

You will be able to read the entire contents of the file without physically opening it, make changes and save a new file with the changes.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

If it's a text file, use fileread

You will be able to read the entire contents of the file without physically opening it, make changes and save a new file with the changes.

Oh yeah, completely forgot about that. But he still hasn't said if its actually a text file yet.

Link to comment
Share on other sites

There are a lot of ways to skin that particular cat. Personally i'd say read in the file and close it, with any of the options given already, or just _FileReadToArray and make one continuous string with _ArrayToString. at that point you'll have one nice delimited string of the file contents that you can chop up and replace any way you like using StringRegExp or StringReplace() etc -and then just do filewrite, or ControlSetText("Untitled - Notepad","",15,$YourModifiedString) especially if you want to proofread the document before saving the first couple of times.

Link to comment
Share on other sites

probably a good bet if he was originally looking to do the work in notepad ;)

It's a program called BobCAD and the file format is .cnc, what appears to be a proprietary format. That's why things like Notepad can not open these files without it looking all crazy like. It needs to be open within BobCAD to be rendered properly :)

Link to comment
Share on other sites

It's a program called BobCAD and the file format is .cnc, what appears to be a proprietary format. That's why things like Notepad can not open these files without it looking all crazy like. It needs to be open within BobCAD to be rendered properly ;)

and you want to export from that to notepad? does it have an export/save as text functionality within the program?
Link to comment
Share on other sites

  • 2 months later...

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
 Share

  • Recently Browsing   0 members

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