AMS Posted August 19, 2010 Share Posted August 19, 2010 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 More sharing options...
boshi Posted August 19, 2010 Share Posted August 19, 2010 _FileReadToArray and _FileReadFromArray might be other useful function. Link to comment Share on other sites More sharing options...
AMS Posted August 19, 2010 Author Share Posted August 19, 2010 _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 More sharing options...
TonyP Posted August 19, 2010 Share Posted August 19, 2010 (edited) 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 August 19, 2010 by xenon2050 Link to comment Share on other sites More sharing options...
AMS Posted August 19, 2010 Author Share Posted August 19, 2010 Um, probably is easier to open a file with a program rather than open a file from inside the program.FileOpenBut 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 More sharing options...
TonyP Posted August 19, 2010 Share Posted August 19, 2010 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 TextFileNameYou 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 More sharing options...
kaotkbliss Posted August 19, 2010 Share Posted August 19, 2010 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 gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
TonyP Posted August 19, 2010 Share Posted August 19, 2010 If it's a text file, use filereadYou 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 More sharing options...
seandisanti Posted August 20, 2010 Share Posted August 20, 2010 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 More sharing options...
seandisanti Posted August 20, 2010 Share Posted August 20, 2010 Oh yeah, completely forgot about that. But he still hasn't said if its actually a text file yet.probably a good bet if he was originally looking to do the work in notepad Link to comment Share on other sites More sharing options...
AMS Posted August 20, 2010 Author Share Posted August 20, 2010 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 More sharing options...
seandisanti Posted August 20, 2010 Share Posted August 20, 2010 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 More sharing options...
CNCMONKEY Posted November 6, 2010 Share Posted November 6, 2010 and you want to export from that to notepad? does it have an export/save as text functionality within the program?is this file a binary file perhaps? and not a encrypted txt? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now