Eambo Posted January 20, 2011 Posted January 20, 2011 Hi again everyone! Thanks to those who helped me in my other post, I'm making awesome progress. I'm stuck on something that's probably very simple, and I hope someone can help :-) Let's say for example, I have this: $FileSaveLocation = FileSaveDialog("Save File", $DefaultFolder & $DownloadLine, "All (*.*)") To further this example: $DefaultFolder = C:\Program Files\ $DownloadLine = DownloadFolder So essentially the above should default to C:\Program Files\DownloadFolder. This doesn't seem to be working so well for me. Have I done something very silly? Any advice or criticism is welcome! :-)
ReaImDown Posted January 20, 2011 Posted January 20, 2011 (edited) Hi again everyone! Thanks to those who helped me in my other post, I'm making awesome progress. I'm stuck on something that's probably very simple, and I hope someone can help :-) Let's say for example, I have this: $FileSaveLocation = FileSaveDialog("Save File", $DefaultFolder & $DownloadLine, "All (*.*)") To further this example: $DefaultFolder = C:\Program Files\ $DownloadLine = DownloadFolder So essentially the above should default to C:\Program Files\DownloadFolder. This doesn't seem to be working so well for me. Have I done something very silly? Any advice or criticism is welcome! :-) $DefaultFolder = "C:\Program Files\" $DownloadLine = "DownloadFolder" now it'd work EDIT: to check if you've declared something correctly, use a msgbox $DefaultFolder = "C:\Program Files\" $DownloadLine = "DownloadFolder" $test = $DefaultFolder $ $DownloadLine msgbox(0,"",$test) and see what pops up ^.^ Edited January 20, 2011 by ReaImDown [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Varian Posted January 20, 2011 Posted January 20, 2011 What result are you getting? Are you certain that there is a "\" between the folders? Verify you syntax with a console write or a msgbox
Eambo Posted January 20, 2011 Author Posted January 20, 2011 (edited) I'm actually slightly confused. It's popping up the SaveFileDialog. If I press cancel, it downloads the file to the correct directory. I guess a nasty little workaround would be... Is there a way I can automate the 'cancel' pressing before the user gets a change to change the default file directory? :-) I need to do a bit more testing, but from what I can see this is happening O.O Edit: Nevermind, I take it back. It's making a file, however there's nothing in it O.o So what I'm experiencing right now is that for some reason it's defaulting to what seems to be the @ScriptDir. There's definitely a trailing backslash in there, so I don't know why it's doing that... Edited January 20, 2011 by Eambo
ReaImDown Posted January 20, 2011 Posted January 20, 2011 add me to msn, I'll be happy to help... randy@get-fucked.net [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Varian Posted January 20, 2011 Posted January 20, 2011 OK, you need to add a cancel check. Add this line after your FilSaveDialog() lineIf @error Then ;exit or return or function call
Varian Posted January 20, 2011 Posted January 20, 2011 add me to msn, I'll be happy to help...randy@get-fucked.netHuh????
Eambo Posted January 20, 2011 Author Posted January 20, 2011 Okay, I'm messing with my code and need to stop it :-) Essentially I've got this: - An Error Log - Code that extracts this error log - The error log then points to a website to download a replacement file So here's an example: [ERROR] C:\Program Files\Files\Broken.reg This then gets converted to a web address as follows: www.downloadfix.com/Files/Broken.reg So we'll say my default folder is 'Files'. I'm running my script from there. What I want the script to do is to pre-populate the download so they literally only have to press save. So it should be saving as "Broken.reg" in the /Files folder. I have this code: $DefaultFolder=@ScriptDir $DownloadFolder = $DefaultFolder & "\" & $DownloadLine $DownloadLine = the extracted error message. From what I can see it should be working, I've got a msgbox that shows it as C:\Program Files\Files\Broken.reg But when it gets to the 'save' prompt, it's in the @ScriptDir, and the text box for save is blank. Which means the user would have to manually navigate to the folder to save it. I either want this prepopulated, or I simply want it to download - no prompt. Is there a way to do either of these? Thanks everyone for your help :-)
Varian Posted January 20, 2011 Posted January 20, 2011 (edited) Do you mean that the default file name should (broken.reg) should be in the text box? Or should C:\Program Files\Files\Broken.reg be in the text box? On that note, in your line you never specified a default file name. You did not have enough options listed to set the default name. It should have something like this $FileSaveLocation = FileSaveDialog("Save File", $DefaultFolder & $DownloadLine, "All (*.*)", 16, $DownloadLine)That would give the user a prompt like in the attached picture. Also, if the directory that you have for initial directory does not exist BEFORE the FileSaveDialog() function, the @ScriptDir will be the initial folder that is selected. So make sure that "C:\Program Files\Files" exists before using that function. Edited January 20, 2011 by Varian
AdmiralAlkex Posted January 20, 2011 Posted January 20, 2011 Hardcoding "C:\Program Files\" is bad. What if the user is on a x64 OS? What if they don't have a English Windows? (Program Files is localized) Use @ProgramFilesDir or something instead. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Eambo Posted January 20, 2011 Author Posted January 20, 2011 Hardcoding "C:\Program Files\" is bad. What if the user is on a x64 OS? What if they don't have a English Windows? (Program Files is localized)Use @ProgramFilesDir or something instead.Sorry Admiral, this was more of a generic example, it's not actually what I'm programming :-) I'm using @ScriptDir and working from there :-)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now