Jump to content

FileRead - after Compiling to .exe


t1ll.3nd
 Share

Recommended Posts

Hi there,

after compiling my Script to .exe it won't read the extern file and only has the data of the extern file inside which i had there when i created the exe .. mean the content is constant.

$file = FileOpen("www.txt", 0)

$pw = FileReadLine($file)

FileClose($file)

On my PC it works .. but on other it won't and only uses the strings which where in the file which i had on my PC ..

Link to comment
Share on other sites

Hi there,

after compiling my Script to .exe it won't read the extern file and only has the data of the extern file inside which i had there when i created the exe .. mean the content is constant.

On my PC it works .. but on other it won't and only uses the strings which where in the file which i had on my PC ..

Are you using fileinstall to include the file www.txt in your exe.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Sorry, i don't know what do you mean with "fileinstall" .. i only have the .exe and created the .txt myself.

If you require the file to be available for use on other computers you need to use FileInstall to build it in as part of the exe. You will find information and examples in the help file. If you just need the file to record something from your script you will need to open it for writing not just reading.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

What BigDod is trying to tell you is that your www.txt file needs to reside in the same directory as your executable.

Also, is that all of your code? It's not doing anything except opening a file, reading a line, and then closing it.

Try this:

$file = FileOpen("www.txt", 0)
$pw = FileReadLine($file)
MsgBox(32,"Reading www.txt.","Information on line is:" & $pw")
FileClose($file)
Link to comment
Share on other sites

No its only the part .. but the rest isn't important for this .. because the rest works :P

ControlSetText("Bla", "", "Edit1", "$pw" )

Here the $pw is used ...

how could i implent this feature that everbody can change his own pw?

and yes the file is in the same directory of course .. same file structure like at my Desk ..

Link to comment
Share on other sites

  • Moderators

You could use an .ini file rather than a .txt file. Set it up as a "poor man's database" :P

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Yes but the .txt should also works .. its really simple and it works on my PC .. but i dont know why it uses the string from my pc .. when its on another ..

If you wish to write to the file the line $file = FileOpen("www.txt", 0) should be $file = FileOpen("www.txt", 1) or $file = FileOpen("www.txt", 2).

As to why it reads the string from your pc, we would need to see more of the script to see what is happening.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

  • Moderators

Well, sounds like you hard coded it personally. Did you do a FileInstall() like BigDod said with the .txt file, or are you creating the text file on that person's computer <hold on chasing my tale >, If you're doing a FileInstall(), you have to make sure that the <hold almost got that thing> information in that file isn't saved with information about your PC.

Tell you what, I can't seem to get this dang 'tale', post the code that you are getting the information from the 'end user', and and where you're putting it at in the .txt, BTW... If you're constantly writing stuff to a file to be used as information, and .ini may be more appropriate.

The 'chasing the tale' bit is because, the simple code you provide (basically from the help file), doesn't tell us what the problem is, you have to provide some of the tools ... ie.. The .txt file you're using and script you're having a problem with ... to get some real answers.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

No its only the part .. but the rest isn't important for this .. because the rest works :P

ControlSetText("Bla", "", "Edit1", "$pw" )

Here the $pw is used ...

how could i implent this feature that everbody can change his own pw?

and yes the file is in the same directory of course .. same file structure like at my Desk ..

Just wanted to make sure. :lmao:

The 'chasing the tale' bit is because, the simple code you provide (basically from the help file), doesn't tell us what the problem is, you have to provide some of the tools ... ie.. The .txt file you're using and script you're having a problem with ... to get some real answers.

Well said SmOke_N.
Link to comment
Share on other sites

No its not from the help file.

I scripted an Autologin for a game.

It reads the user PW from a .txt which is in the same directory as the .exe.

It only READS - the PW is handwritten into the file and the .txt also created by the user himself.

.txt content:

jdfnjfnf (something like this .. only 1 word .. )

lua file:

$i=0

$file = FileOpen("pww.txt", 0)

$pw = FileReadLine($file)

FileClose($file)

While $i <= 10

;;some clicking around ...

ControlSetText("Application", "", "Edit1", "$pw" )

;;someclicking around..

$i = $i + 1

WEnd

That's it ..

Link to comment
Share on other sites

  • Moderators

Well for one, you have you're $PW variable in quotes, that's not gonna work. Let's say I have

$pw = FileReadLine($file)

instead of that line being sent, you have the actual "$" and "p" and "w" being sent.

Why not:

ControlSend("Application", "", "Edit1", $pw) ??

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators
:P What do you feel was the problem, so that others that may ask the same question and do a search may find a simple solotuion? :lmao:

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

That would depend on where you're A) Creating the .txt file or :P If the txt file will be in the au3.exe directory.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

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