Sign in to follow this  
Followers 0
t1ll.3nd

FileRead - after Compiling to .exe

22 posts in this topic

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 ..

Share this post


Link to post
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.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
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.

Share this post


Link to post
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.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
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)

Share this post


Link to post
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 ..

Share this post


Link to post
Share on other sites

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


[center]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.[/center]

Share this post


Link to post
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 ..

Share this post


Link to post
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.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

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.


[center]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.[/center]

Share this post


Link to post
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.

Share this post


Link to post
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 ..

Share this post


Link to post
Share on other sites

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) ??


[center]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.[/center]

Share this post


Link to post
Share on other sites

$file = FileOpen(@ScriptDir & "\pww.txt", 0)
$pw = FileReadLine($file)
FileClose($file)
For $i = 1 To 10
;;some clicking around ...
    ControlSetText("Application", "", "Edit1", $pw)
;;someclicking around..
Next

Share this post


Link to post
Share on other sites

I think that was the prob .. im such a dumb-ass :(

I should have saw this cause i know a lil C++ and there it is the same :P

a lot of thanks .. will test it later (atm not possible ..) but i think this was the problem :lmao:

Share this post


Link to post
Share on other sites
: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:

[center]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.[/center]

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

the " " were the problem :P

so i didn't use the var .. i used the $pw as String :lmao:

Do i need

$file = FileOpen(@ScriptDir & "\pww.txt", 0)

?

The @ ScriptDir thing .. ?

Edited by t1ll.3nd

Share this post


Link to post
Share on other sites

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.


[center]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.[/center]

Share this post


Link to post
Share on other sites

It is just a safe guard in case the working directory is not the script directory. It is good practice to do so if you do not mind a little extra code. Your choice.

Share this post


Link to post
Share on other sites

Another Question .. how can i make the script start itself from the beginning if a WinWait Window isn't coming after a certian period of time?^^

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