Sign in to follow this  
Followers 0
iGryc

FileOpen not working

6 posts in this topic

tried many different things and still not openin teh file. i compiled simply:

$file = FileOpen("test.txt",0) to exe and sent to my cousin, couldnt open the test.txt file either

and yes i had test.txt in the same directory.

i can watch as the autoit flashes by in my task bar but the text file is not opening. any reasons this is happening?

code from the help file:

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

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileClose($file)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

fileopen open the file but it's hidden so you can't see it.

it doesn't run it.

if you want to open it (like if you left click on it) use this script

Run('Notepad.exe "test.txt"')

Edited by Pain

Share this post


Link to post
Share on other sites

iGryc, what is it that you actually want to do with opening the file. The FileOpen creates a handle to file which is put in the memory. It is not actually visible to the user.

If it is that what you try to do, you should use the FileRead command as well

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

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

$text = FileRead($file)

MsgBox(0,"FileContent",$text)

FileClose($file)

In the beginning there was nothing and then even that exploded - anonymous

Share this post


Link to post
Share on other sites

o my bad lol. I WILL USE THE EXCUSE OF BEEN UP for a very long time and am tired as ASKDMALSD.

:)

thanks for the reply. helpful people on these forums

Share this post


Link to post
Share on other sites

iGryc, what is it that you actually want to do with opening the file. The FileOpen creates a handle to file which is put in the memory. It is not actually visible to the user.

If it is that what you try to do, you should use the FileRead command as well

i was trying to do what pain clarified, which was have a file opened with a program and displayed to the user. was unaware fileopens actions were 'invisible' so to speak.

thanks for the helpful replies

Share this post


Link to post
Share on other sites

in FAQ :

Only a few file extensions are usually "runable" - these are .exe, .bat, .com, .pif. Other file types like .txt and .msi are actually executed with another program. When you double click on a "myfile.msi" file what actually happens in the background is that "msiexec.exe myfile.msi" is executed. So to run a .msi file from AutoIt you would do:

RunWait("msiexec myfile.msi")

Or, run the command "start" which will automatically work out how to execute the file for you:

RunWait(@COMSPEC & " /c Start myfile.msi")

Or, use the ShellExecuteWait function which will automatically work out how to execute the file for you:

ShellExecuteWait("myfile.msi")


sorry for my spelling mistakes. its due to be fast !!!

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