Sign in to follow this  
Followers 0
SorryButImaNewbie

How to close FileSelectFolder and return to original GUI?

9 posts in this topic

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)
 
 

Share this post


Link to post
Share on other sites



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 Gude
How 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

Share this post


Link to post
Share on other sites

Welcome to the AutoIt forum! :D

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

1 person likes this

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (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   :D ) 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 by SorryButImStupid

Share this post


Link to post
Share on other sites

if you abort FileSelectFolder() or FileOpendialog(), they return empty string, which is why your While loops keep repeating.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by orbs

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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.

1 person likes this

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