Sign in to follow this  
Followers 0
Him

Write and read *.* all files

11 posts in this topic

Hi everyone, I'm new to Autoit and I'd like to create a program to write to any file (not just .txt or .doc etc) and to read this text when asked.

Is this possible under AutoIt? Happy Xmas


[size="1"][font="Tahoma"]On the internet, nobody knows you're a dog.[/font][/size]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Are you asking how to work with binary files? If so take a look at BinaryString() in the helpfile. Merry Christmas to you as well. :P

Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Look up: FileWrite() and FileRead() in your helpfile

Welcome to the forums and Merry Christmas!

Kurt

Edited by _Kurt

Awaiting Diablo III..

Share this post


Link to post
Share on other sites

I'd like to input some text to an .mp3 file for example and read it with my program later.

I want the mp3 file to continue be functionable however. Thanks!


[size="1"][font="Tahoma"]On the internet, nobody knows you're a dog.[/font][/size]

Share this post


Link to post
Share on other sites

I'd like to input some text to an .mp3 file for example and read it with my program later.

I want the mp3 file to continue be functionable however. Thanks!

Good luck with that - AutoIt would not be the program needed to write to MP3's or any other file except for ASCII text. Each program that writes a file will use its own format. If you write something to read and write to that format then maybe you will get a chance to do what you are talking about.

Maybe someone else can chime in about file headers - can they be written and retrieved maybe like 128 chars or something - might need hex editor?


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

I'm not sure if you are trying to change .mp3 data or whatever, because I believe that will not work. Let's make an example real quick for you:

;THIS IS UNTESTED, probably works though
#include <File.au3>
GuiCreate("example")
$input = GuiCtrlCreateInput("",50, 50)
$ok    = GuiCtrlCreateButton("OK", 50, 80)
$get   = GuiCtrlCreateButton("Read file",50, 120)
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $ok
            $read = GuiCtrlread($input)
            FileWrite(@scriptdir & "\test.dat", $read)
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $get
            $rd = FileRead(@scriptdir & "\test.dat")
            GuiCtrlSetData($input, $rd)
    EndSelect
WEnd

UNTESTED

If this isn't what you want, just tell me.

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

I'd like to input some comments to any file and read them using my program.

for example input the lyric of a song to an wav file and read them later using my programme.

Is this possible? Thanks in advance!


[size="1"][font="Tahoma"]On the internet, nobody knows you're a dog.[/font][/size]

Share this post


Link to post
Share on other sites

I have no experience in wav files or anything, can't really help. If you give me more precise information (i.e. you want to find all the x's in the file, or you want to find x in your file and display it in your program).

>< Nothing I can do,

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

I want to write data to the end of the file and read it later. It could start for instance $x = "HLGEGJKASDFHGQJKWHT789T3KIU5Y73QTGUIAWHI"

My programme will find $x in the file and will read from $x to the end and display it.


[size="1"][font="Tahoma"]On the internet, nobody knows you're a dog.[/font][/size]

Share this post


Link to post
Share on other sites

Okay, I think I understand most of what you want. Let's start by solving the

It could start for instance $x = "HLGEGJKASDFHGQJKWHT789T3KIU5Y73QTGUIAWHI"

My programme will find $x in the file and will read from $x to the end and display it.

Okay, so let's say that $x = "blahblahblah TEST blahblahblah" and the TEST part of $x changes alot throughout the file, but the blahblahblah part never changes. So let's say the written part of the file is:

blahblahblah THIS blahblahblah

blahblahblah IS A blahblahblah

blahblahblah TEST blahblahblah

You'd use something like this:

$file = FileRead("file.txt")
$reg = StringRegExp($file, "blahblahblah (.*?) blahblahblah", 3)
Msgbox(0,"",$reg[0] & @CRLF & $reg[1] & @CRLF & $reg[2])

This would come up as a message box that says this:

THIS

IS A

TEST

Hopefully I explained this correctly, gotta run,

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Lazy cat wrote a udf to read mp3 tags. It doesn't support writing however.

http://www.autoitscript.com/fileman/users/Lazycat/udfs.html

You could also try storing the data in a files NTFS stream.

Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

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