Jump to content

Opening Files


Recommended Posts

I just downloaded the program and am trying to get started. I have tried to use the FileOpenDialog function, but ran into problems. If I simply open the dialog box in the .au3 program, the Open button does not respond. If I add MouseClick statements, the program does not execute them until I close the dialog box. I copied the example given and tried to run it. All that happened was that a message box appeared telling me what my selection was. It never opened the file. What am I doing wrong?

Arthur Jay

Link to comment
Share on other sites

I just downloaded the program and am trying to get started. I have tried to use the FileOpenDialog function, but ran into problems. If I simply open the dialog box in the .au3 program, the Open button does not respond. If I add MouseClick statements, the program does not execute them until I close the dialog box. I copied the example given and tried to run it. All that happened was that a message box appeared telling me what my selection was. It never opened the file. What am I doing wrong?

Arthur Jay

You are not doing anything wrong you are expecting too much from the example. The example just lets you see how to select a file and use the selection in another command. If you wish to open the file it is upto to you to tell the script that you want to open the file.

BTW

Welcome to the forums.


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

I just downloaded the program and am trying to get started. I have tried to use the FileOpenDialog function, but ran into problems. If I simply open the dialog box in the .au3 program, the Open button does not respond. If I add MouseClick statements, the program does not execute them until I close the dialog box. I copied the example given and tried to run it. All that happened was that a message box appeared telling me what my selection was. It never opened the file. What am I doing wrong?

Arthur Jay

welcome to the forums, arthur, the FileOpenDialog function actually is just the function to display the "choose a file" box. it returns a string that contains the name and path of the file selected. It does not actually open. typically you want to assign the result to a variable, then open it with FileOpen() or a Run() function. like so:

$file = FileOpenDialog($message, "C:\Windows\", "Images (*.jpg;*.bmp)", 1 + 4 );displays the file open dialog
FileOpen($file,0);actually opens the file for reading
$contents = FileRead($file,FileGetSize($file)); reads the contents of the file to a variable
MsgBox(0,"Contents",$contents);displays the contents

***edit*** fixed a gramatical error.

Edited by cameronsdad
Link to comment
Share on other sites

  • Developers

I just downloaded the program and am trying to get started. I have tried to use the FileOpenDialog function, but ran into problems. If I simply open the dialog box in the .au3 program, the Open button does not respond. If I add MouseClick statements, the program does not execute them until I close the dialog box. I copied the example given and tried to run it. All that happened was that a message box appeared telling me what my selection was. It never opened the file. What am I doing wrong?

Arthur Jay

FileOpenDialog() is just a selection window that returns the file you selected.

If you want to open the file you can start the associated program or just run the file like:

$var = FileOpenDialog("select the file", "", "AutoIt3 Script (*.au3)", 1 + 4 )

If @error Then
    MsgBox(4096,"","No File(s) chosen")
Else
    $var = StringReplace($var, "|", @CRLF)
    Run(@ComSpec & ' /c start ' & $var,'',@SW_HIDE)
EndIf

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

***edit*** fixed a gramatical error.

grammatical :)

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

you've figured me out ron. i can't read... :)

I was just funnin' ya! If I had your schedule, I wouldn't Care about grammar!! :mellow:

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

welcome to the forums, arthur, the FileOpenDialog function actually is just the function to display the "choose a file" box. it returns a string that contains the name and path of the file selected. It does not actually open. typically you want to assign the result to a variable, then open it with FileOpen() or a Run() function. like so:

$file = FileOpenDialog($message, "C:\Windows\", "Images (*.jpg;*.bmp)", 1 + 4 );displays the file open dialog
FileOpen($file,0);actually opens the file for reading
$contents = FileRead($file,FileGetSize($file)); reads the contents of the file to a variable
MsgBox(0,"Contents",$contents);displays the contents

***edit*** fixed a gramatical error.

Thanks for the advice. I'll try again. Before the attempt I described here, I tried to use the FileOpen function to open a blank Excel document. I executed that several times but nothing obvious happened. When I checked the hard drive, I found some apparently blank text files with the name Excel. I read the instructions again, and it appears to me that this function actually creates a text file when you use it. My programming experience is limited, but other efforts (notably in ASYST) relied on more precise commands.

Worse yet, when I tried to do a little clean-up on my hard drive after that attempt, I managed to delete a file that was not insignificant. I later tried to restore it, but the damage had already been done. To top that off, I can't find the CD that came to the original owner of the CPU. So now I am without Excel, no apparent way to revive it, and no funds to buy an update. While I'm stewing over that, I thought I'd try to understand these functions using something less dangerous, like .txt files.

Thanks for your advice. I'll try again later

Arthur Jay

Link to comment
Share on other sites

Thanks for the advice. I'll try again. Before the attempt I described here, I tried to use the FileOpen function to open a blank Excel document. I executed that several times but nothing obvious happened. When I checked the hard drive, I found some apparently blank text files with the name Excel. I read the instructions again, and it appears to me that this function actually creates a text file when you use it. My programming experience is limited, but other efforts (notably in ASYST) relied on more precise commands.

Worse yet, when I tried to do a little clean-up on my hard drive after that attempt, I managed to delete a file that was not insignificant. I later tried to restore it, but the damage had already been done. To top that off, I can't find the CD that came to the original owner of the CPU. So now I am without Excel, no apparent way to revive it, and no funds to buy an update. While I'm stewing over that, I thought I'd try to understand these functions using something less dangerous, like .txt files.

Thanks for your advice. I'll try again later

Arthur Jay

did you just delete the excel.exe file?
Link to comment
Share on other sites

I managed to delete a file that was not insignificant. I later tried to restore it, but the damage had already been done

Understand your frustration. Been there, done that. I dont know how you tried to do a restore. But if you did not write to the excel file, and your disk is not to full and you have not done somthing realy serious on your computer (defragment, write big or many files) there are hope. I have successfully used r-studio with greate success. I'm shure there are freeware stuff doing the trick to. Especialy if you are familiar with linux, dd and mounting disk images.

Regards

Uten

Link to comment
Share on other sites

Understand your frustration. Been there, done that. I dont know how you tried to do a restore. But if you did not write to the excel file, and your disk is not to full and you have not done somthing realy serious on your computer (defragment, write big or many files) there are hope. I have successfully used r-studio with greate success. I'm shure there are freeware stuff doing the trick to. Especialy if you are familiar with linux, dd and mounting disk images.

Regards

Uten

yes, r-studio is awesome. i've used it to recover files from multiple formats ago.
Link to comment
Share on other sites

  • Moderators

yes, r-studio is awesome. i've used it to recover files from multiple formats ago.

And so has the FBI :)

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, r-studio is awesome. i've used it to recover files from multiple formats ago.

I am not comfortable in that environment. I may just slide further into the sink hole if I try.

The file I tried to restore is a PIP file of 1.2kb with an icon that looked just like the 0kb text file I deleted. In looking back on it, I should have been suspicious that they both had the same name. And the PIP file was about 10 years old. Too late we get smart.

Arthur Jay

Link to comment
Share on other sites

  • Moderators

I am not comfortable in that environment. I may just slide further into the sink hole if I try.

The file I tried to restore is a PIP file of 1.2kb with an icon that looked just like the 0kb text file I deleted. In looking back on it, I should have been suspicious that they both had the same name. And the PIP file was about 10 years old. Too late we get smart.

Arthur Jay

Ha, that file is 3yrs older than my son!! Hope you at least try to recover it using some outside method. Obviously it's important enough to keep around to you.

Edit:

And I can't imagine a file that old, not having a backup somewhere around, you've had to reformat along the way??

Edited by SmOke_N

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

welcome to the forums, arthur, the FileOpenDialog function actually is just the function to display the "choose a file" box. it returns a string that contains the name and path of the file selected. It does not actually open. typically you want to assign the result to a variable, then open it with FileOpen() or a Run() function. like so:

$file = FileOpenDialog($message, "C:\Windows\", "Images (*.jpg;*.bmp)", 1 + 4 );displays the file open dialog
FileOpen($file,0);actually opens the file for reading
$contents = FileRead($file,FileGetSize($file)); reads the contents of the file to a variable
MsgBox(0,"Contents",$contents);displays the contents

***edit*** fixed a gramatical error.

I tried to run your program and it gave me the message that the variable was not declared. Where can I get some tutorial help that lays out the essentials? I take it that the semi-colon identifies a comment, right? That low level of understanding is where I am at right now.

Arthur Jay

Link to comment
Share on other sites

I tried to run your program and it gave me the message that the variable was not declared. Where can I get some tutorial help that lays out the essentials? I take it that the semi-colon identifies a comment, right? That low level of understanding is where I am at right now.

Arthur Jay

there is a very good tutorial in scripts and scraps, i'd link you but i don't have the address handy. i'm sure someone is probably posting it as i type this.

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