SorryButImaNewbie Posted November 5, 2014 Share Posted November 5, 2014 I'm writing a script where the users will have to select a file, while the browser is active I can't exit the Fileselector, and I'm not sure how should i go about it (if i click escape it should return to the original GUI, but it just restarts the FileSelectFolder) The script is: case $BrowseButton $SaveDirectory = "" While ($SaveDirectory == "") $SaveDirectory = FileSelectFolder("Select a Folder to Save the Datas", "D:") GUICtrlSetData($FileFolderInput, $SaveDirectory) WEnd I think i should use GUICtrlSetOnEvent but im not sure how, or if it is even the right function to use The script actually works but i want to make it so people can escape the program without choosing a file to upload, once they opened the browser. Thank you guys (just started autoIT but I like it already, hope to learn more) Link to comment Share on other sites More sharing options...
BrewManNH Posted November 5, 2014 Share Posted November 5, 2014 Please post something that is runnable, trying to figure out what you're doing wrong with that snippet isn't going to help. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
MikahS Posted November 5, 2014 Share Posted November 5, 2014 Welcome to the AutoIt forum! For one, using code tags [ autoit ] ;code goes here [ /autoit ] (remove the spaces) will give you syntax highlighting and a box for your code making it very clean. Two, that is not a runnable script that we can test for you, please post your whole script, or a reproducer script that does what you say is the problem. Using onEvent will not be needed here, but I'm glad you are trying to find solutions. SorryButImaNewbie 1 Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
SorryButImaNewbie Posted November 6, 2014 Author Share Posted November 6, 2014 (edited) Thanks for the help guys! (I'll keep in mind what you told me so far ) Sorry if I feel a bit unprofessional here, only learn and worked with object orianted before, and I don't seems to grasp this very well yet! Everything else however runs fine it seems, and I really like what can I (or will be able ) do with this, seems really nice once i get some experience so lets try that highlight: I hope this is what you asked for (I tried it in a unique au3 file and it run for me, with the same "uncloseable" problem)! Thanks in advance! bonusQ: In the preview nothing seems to be displayed after the highlight, I assume that I should just put the script at the end of the post, correct? FileKivalasztas() Func FileKivalasztas() $message = "Üzemanyag Kártya Számok" $filter = "Text files (*.txt)" Global $UzemanyagKartyaFile = "" While ($UzemanyagKartyaFile == "") $UzemanyagKartyaFile = FileOpenDialog($message, "D:\", $filter, $FD_FILEMUSTEXIST) $FileOpen = FileOpen ($UzemanyagKartyaFile) WEnd Global $SaveDirectory = "" While ($SaveDirectory == "") $SaveDirectory = FileSelectFolder("Select a Folder to Save the Datas", "D:\") ;$SaveDirectory = "" (Exit) --- solution for close needed ---- WEnd EndFunc Edited November 6, 2014 by SorryButImStupid Link to comment Share on other sites More sharing options...
orbs Posted November 6, 2014 Share Posted November 6, 2014 if you abort FileSelectFolder() or FileOpendialog(), they return empty string, which is why your While loops keep repeating. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Solution SorryButImaNewbie Posted November 6, 2014 Author Solution Share Posted November 6, 2014 Thanks orbs! I know that (sorry for not clarifiying it, will do better next time), but I thought I can still close it if there is something nested in the while to close it. My solution now works, but it close the entire program, which isnt reall a problem since it starts with this function. Is this script seems to be okey for you? or is there something I can do better: just because i feel this is a half-legged solution Func FileKivalasztas() $message = "Üzemanyag Kártya Számok" $filter = "Text files (*.txt)" Global $UzemanyagKartyaFile = "a" While ($UzemanyagKartyaFile == "a") $UzemanyagKartyaFile = FileOpenDialog($message, "D:\", $filter, $FD_FILEMUSTEXIST) $FileOpen = FileOpen ($UzemanyagKartyaFile) If $UzemanyagKartyaFile = "" Then Exit ($UzemanyagKartyaFile) EndIf WEnd $SaveDirectory = "a" While ($SaveDirectory == "a") $SaveDirectory = FileSelectFolder("Select a Folder to Save the Datas", "D:\") If $SaveDirectory = "" Then Exit EndIf ; $SaveDirectory = "" Exit WEnd EndFunc Link to comment Share on other sites More sharing options...
orbs Posted November 6, 2014 Share Posted November 6, 2014 (edited) The script actually works but i want to make it so people can escape the program without choosing a file to upload, once they opened the browser. then why do you need a loop at all? just remove the lines of the While (and its corresponding Wend, of course) from your original script. TIP: if you have the full SciTe package installed (and you should), then in the SciTe editor, hit Ctrl+T and see how the editor does wonders to your script format. Edited November 6, 2014 by orbs Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
SorryButImaNewbie Posted November 6, 2014 Author Share Posted November 6, 2014 How else should i run it? I took over from a guy who left the company, he showed me autoIT for a day, and I was choosen since I was the only intern with codeing experience. Thanks for the TIP (I have the full package I really like AU3Info and recorder, Info helps so much with building scripts that works with different programms) Link to comment Share on other sites More sharing options...
orbs Posted November 6, 2014 Share Posted November 6, 2014 like this: Global $UzemanyagKartyaFile = "" Global $SaveDirectory = "" FileKivalasztas() Func FileKivalasztas() $message = "?zemanyag K?rtya Sz?mok" $filter = "Text files (*.txt)" $UzemanyagKartyaFile = FileOpenDialog($message, "D:\", $filter, 1) If $UzemanyagKartyaFile = "" Then Return ; this will return the function back to the calling script if file was not selected. $SaveDirectory = FileSelectFolder("Select a Folder to Save the Datas", "D:\") ; no condition is needed here because anyway the function returns. EndFunc ;==>FileKivalasztas also notice i moved the Global variables declaration to the main script, not inside a function. SorryButImaNewbie 1 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
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