richsimple Posted August 29, 2016 Share Posted August 29, 2016 Sorry I'm new to this, and having got hold of some of the basics and played with some examples I still can't figure this one out. What I want to do via a GUI is for the user to select a folder and for that folder to be displayed in an input box so there is a visual on screen of the folder location. Later on in the script, (still writting all of it as solving each section a bit at a time) this input will be used as the Source and Destination folders. I decided on the FileSelectFolder as it was the most straightforward way of solving drive and network locations across multiple machine. Code so far #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> Opt("GUIOnEventMode", 1) ;Global &Source, &Destination Global $Source Global $FileSelectFolder1 Global $FileSelectFolder #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Copy Folder", 615, 438, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") $Copy = GUICtrlCreateButton("Copy", 184, 208, 161, 49) GUICtrlSetOnEvent(-1, "CopyClick") $SourceButton = GUICtrlCreateButton("SourceButton", 48, 40, 137, 41) GUICtrlSetOnEvent(-1, "SourceButtonClick") $DestButton = GUICtrlCreateButton("DestButton", 48, 104, 137, 41) GUICtrlSetOnEvent(-1, "DestButtonClick") $Progress1 = GUICtrlCreateProgress(104, 320, 425, 49) $Source = GUICtrlCreateInput("Source", 240, 48, 321, 21) GUICtrlSetOnEvent(-1, "SourceChange") $Destination = GUICtrlCreateInput("Destination", 240, 120, 305, 21) GUICtrlSetOnEvent(-1, "DestinationChange") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func CopyClick() EndFunc Func DestButtonClick() Local Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Local $sFileSelectFolder1 = FileSelectFolder($sMessage, "") If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") Else ; Display the selected folder. MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder1) EndIf EndFunc Func DestinationChange() EndFunc Func Form1Close() EndFunc Func Form1Maximize() EndFunc Func Form1Minimize() EndFunc Func Form1Restore() EndFunc Func SourceButtonClick() Local Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Local $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") Else ; Display the selected folder. MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder) EndIf EndFunc ;==>Example) Func SourceChange() EndFunc Func Source() EndFunc Link to comment Share on other sites More sharing options...
AutoBert Posted August 29, 2016 Share Posted August 29, 2016 (edited) I think you are searcing for GuiCtrlSetData. Please use the code-tags ("<>") next time: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> Opt("GUIOnEventMode", 1) ;Global &Source, &Destination Global $Source Global $FileSelectFolder1 Global $FileSelectFolder #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Copy Folder", 615, 438, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") $Copy = GUICtrlCreateButton("Copy", 184, 208, 161, 49) GUICtrlSetOnEvent(-1, "CopyClick") $SourceButton = GUICtrlCreateButton("SourceButton", 48, 40, 137, 41) GUICtrlSetOnEvent(-1, "SourceButtonClick") $DestButton = GUICtrlCreateButton("DestButton", 48, 104, 137, 41) GUICtrlSetOnEvent(-1, "DestButtonClick") $Progress1 = GUICtrlCreateProgress(104, 320, 425, 49) $Source = GUICtrlCreateInput("Source", 240, 48, 321, 21) GUICtrlSetOnEvent(-1, "SourceChange") $Destination = GUICtrlCreateInput("Destination", 240, 120, 305, 21) GUICtrlSetOnEvent(-1, "DestinationChange") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func CopyClick() EndFunc ;==>CopyClick Func DestButtonClick() Local Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Local $sFileSelectFolder1 = FileSelectFolder($sMessage, "") If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") Else ; Display the selected folder. MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder1) GUICtrlSetData($Destination,$sFileSelectFolder1) ;<=========== EndIf EndFunc ;==>DestButtonClick Func DestinationChange() EndFunc ;==>DestinationChange Func Form1Close() EndFunc ;==>Form1Close Func Form1Maximize() EndFunc ;==>Form1Maximize Func Form1Minimize() EndFunc ;==>Form1Minimize Func Form1Restore() EndFunc ;==>Form1Restore Func SourceButtonClick() Local Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Local $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") Else ; Display the selected folder. MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder) GUICtrlSetData($Source,$sFileSelectFolder) ;<========= EndIf EndFunc ;==>SourceButtonClick Func SourceChange() EndFunc ;==>SourceChange Func Source() EndFunc ;==>Source Edited August 29, 2016 by AutoBert richsimple 1 Link to comment Share on other sites More sharing options...
richsimple Posted August 29, 2016 Author Share Posted August 29, 2016 Sorry about the lack of tags... but thanks for the GUICtrlSetData I did see this earlier but couldn't workout where to put it. Link to comment Share on other sites More sharing options...
232showtime Posted August 29, 2016 Share Posted August 29, 2016 (edited) try this other way.. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> Opt("GUIOnEventMode", 1) ;Global &Source, &Destination Global $Source Global $FileSelectFolder1 Global $FileSelectFolder #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Copy Folder", 615, 438, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") $Copy = GUICtrlCreateButton("Copy", 184, 208, 161, 49) GUICtrlSetOnEvent(-1, "CopyClick") $SourceButton = GUICtrlCreateButton("SourceButton", 48, 40, 137, 41) GUICtrlSetOnEvent(-1, "SourceButtonClick") $DestButton = GUICtrlCreateButton("DestButton", 48, 104, 137, 41) GUICtrlSetOnEvent(-1, "DestButtonClick") $Progress1 = GUICtrlCreateProgress(104, 320, 425, 49) $Source = GUICtrlCreateInput("Source", 240, 48, 321, 21) GUICtrlSetOnEvent(-1, "SourceChange") $Destination = GUICtrlCreateInput("Destination", 240, 120, 305, 21) GUICtrlSetOnEvent(-1, "DestinationChange") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func CopyClick() EndFunc ;==>CopyClick Func DestButtonClick() Local Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Local $sFileSelectFolder1 = FileSelectFolder($sMessage, "") $_Path = _WinAPI_GetFullPathName($sFileSelectFolder1);-----------------------here If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") Else ; Display the selected folder. GUICtrlSetData($Destination, $_Path);-----------------------here MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder1) EndIf EndFunc ;==>DestButtonClick Func DestinationChange() EndFunc ;==>DestinationChange Func Form1Close() EndFunc ;==>Form1Close Func Form1Maximize() EndFunc ;==>Form1Maximize Func Form1Minimize() EndFunc ;==>Form1Minimize Func Form1Restore() EndFunc ;==>Form1Restore Func SourceButtonClick() Local Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Local $sFileSelectFolder = FileSelectFolder($sMessage, "") $_Path = _WinAPI_GetFullPathName($sFileSelectFolder);-----------------------here If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") Else ; Display the selected folder. GUICtrlSetData($Source, $_Path);-----------------------here MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder) EndIf EndFunc ;==>SourceButtonClick Func SourceChange() EndFunc ;==>SourceChange Func Source() EndFunc ;==>Source Edited August 29, 2016 by 232showtime ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon. Link to comment Share on other sites More sharing options...
richsimple Posted August 29, 2016 Author Share Posted August 29, 2016 Thanks for the help on this, The input box is now doing what I want it to do, so I'm going to move on with the script. Link to comment Share on other sites More sharing options...
AutoBert Posted August 29, 2016 Share Posted August 29, 2016 11 minutes ago, 232showtime said: try this other way.. as i think after a small testing phase, the MsgBox will be removed for success, it's the same way as mine. And also with MsgBox the difference isn't so big to speak from a other way. 232showtime 1 Link to comment Share on other sites More sharing options...
232showtime Posted August 29, 2016 Share Posted August 29, 2016 ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon. 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