jbsoccerbrit Posted May 21, 2010 Share Posted May 21, 2010 (edited) Sorry for the very newbie like question but I was wondering how you get the value of a text box and assign it as a variable value. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=icons\images\settings.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstants.au3> #include <IE.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;Title and GUI display for tool $CopyPaste = GUICreate("Convert Tool", 240, 80, 180, 124) GUISetState(@SW_SHOW) ;Primary Files Label $Label1 = GUICtrlCreateLabel("Options:", 10, 4, 151, 20) ;Creates a button(S) $assigns var name $TEXTBOX1 = GUICtrlCreateInput("", 10, 20, 45, 20, 1) $TEXTBOX2 = GUICtrlCreateInput("", 10, 40, 45, 20, 1) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ;closes when red x is pressed Exit Case $TEXTBOX1 ;does stuff FileCopy( "C:\folder1\TEXTBOX1 VALUE HERE", "C:\folder2\TEXTBOX2 VALUE HERE", 1) EndSwitch WEnd ;Displays the GUI until told to close While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited May 21, 2010 by jbsoccerbrit Link to comment Share on other sites More sharing options...
evilertoaster Posted May 21, 2010 Share Posted May 21, 2010 Look at the doc's for GUICtrlRead () Link to comment Share on other sites More sharing options...
jbsoccerbrit Posted May 21, 2010 Author Share Posted May 21, 2010 Will do thank you Link to comment Share on other sites More sharing options...
jbsoccerbrit Posted May 21, 2010 Author Share Posted May 21, 2010 Still at a loss I guess... I understand the Read, Reads in the value but not sure how to place the value where it needs to be. Link to comment Share on other sites More sharing options...
Makaule Posted May 21, 2010 Share Posted May 21, 2010 Tip for the future:*If you would use Help and search for GuiCtrlRead you would notice, that abit down, there is Related section, you could find function called GUICtrlSetData there. Link to comment Share on other sites More sharing options...
jbsoccerbrit Posted May 21, 2010 Author Share Posted May 21, 2010 Just read the area and all it appears to do for me is explain how to make a drop down menu with selections. I am looking to pass a value from a text box as a variable, so I don't see how the two relate. I guess I am looking more for some coding examples or direction... Thanks for the suggestion Makaule Link to comment Share on other sites More sharing options...
evilertoaster Posted May 21, 2010 Share Posted May 21, 2010 (edited) Sounds like you may need more of an intro to programming in general than specific AutoIt instruction. There are several good compilations catered to new programmers using AutoIt, see the wiki: http://www.autoitscript.com/wiki/Tutorials . The simple explanation for what you seem to be saying is a simple variable assignment... $someControl = GUICtrlCreateInput ("test text",0,0) $someText = GUICtrlRead($someControl) MsgBox(0,"",$someText) Edited May 21, 2010 by evilertoaster Link to comment Share on other sites More sharing options...
jbsoccerbrit Posted May 21, 2010 Author Share Posted May 21, 2010 Maybe I can explained better... I understand the GUICtrlRead reads the information from where I ask it to, like the example above. However my problem is getting that read information to be a variable in this line of code below. FileCopy( "C:\folder\filename.ext", "new folder", 1) I want one box to be a variable for the extension on the end of the file name ("C:\folder\filename.VARIABLE 1 GOES HERE FROM INPUT IN TEXT BOX 1") and then the "New Folder" section would be read in from a second text box. Box 1 [] = Where you type in ext Box 2 [] = Destination folder If that makes better sense. Link to comment Share on other sites More sharing options...
evilertoaster Posted May 21, 2010 Share Posted May 21, 2010 One you use GUICtrlRead to assign the values to a variable (say $fileName, and $fileExt), you can append them to your FileCopy arguments like so: FileCopy( "C:\folder\"&$fileName&"."&$fileExt, "new folder", 1) Link to comment Share on other sites More sharing options...
jbsoccerbrit Posted May 21, 2010 Author Share Posted May 21, 2010 Awesome exactly what I was looking for. Thank you for helping me out with this, greatly appreciated Link to comment Share on other sites More sharing options...
jbsoccerbrit Posted May 21, 2010 Author Share Posted May 21, 2010 (edited) I guess I just dont know enough AUTOIT syntax because I cant figure out how to set the destination folder based on the same method. Maybe FileCopy( "C:\folder\name."&$fileExt, ""&$TEXT2&", 1) Edited May 21, 2010 by jbsoccerbrit Link to comment Share on other sites More sharing options...
evilertoaster Posted May 21, 2010 Share Posted May 21, 2010 AutoIt's syntax is nothing special, which is why I speculate it might be worth your time to read a good tutorial. Quotes designate a string. so when you write "some text here" you start and end with quotes. 2 quotes back to back (such as "") is an empty string (nothing). Quotes must always be used in pairs though, unlike your code below: FileCopy( "C:\folder\name." & $fileExt, "" & $TEXT2 & ", 1) which should be: FileCopy( "C:\folder\name." & $fileExt, $TEXT2, 1) This assumes $TEXT2 is the full path to the directory you're wanting to copy to. Link to comment Share on other sites More sharing options...
jbsoccerbrit Posted May 21, 2010 Author Share Posted May 21, 2010 (edited) Here is the code I have I don't understand why it doesnt work expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=icons\images\settings.ico #AutoIt3Wrapper_outfile=S:\folder\test.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstants.au3> #include <IE.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;Title and GUI display for tool $CopyPaste = GUICreate("Var Grab", 240, 120, 180, 124) GUISetState(@SW_SHOW) ;Primary Files Label $Label1 = GUICtrlCreateLabel("Options:", 10, 4, 151, 20) $Label2 = GUICtrlCreateLabel("Source Folder", 60, 20, 151, 20) $Label3 = GUICtrlCreateLabel("File Extension Type", 60, 45, 151, 20) $Label4 = GUICtrlCreateLabel("Destination Folder", 65, 70, 151, 20) ;Creates a button(S) $assigns var name $TEXT1 = GUICtrlCreateInput("", 10, 20, 45, 20, 1) $TEXT2 = GUICtrlCreateInput("", 10, 45, 45, 20, 1) $TEXT3 = GUICtrlCreateInput("", 10, 70, 55, 20, 1) $ACTION = GUICtrlCreateButton("Convert", 10, 95, 45, 20, 1) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ;closes when red x is pressed Exit Case $ACTION FileCopy( "C:\"&$TEXT1&"\Filename" & $TEXT2, $TEXT3, 1) EndSwitch WEnd ;Displays the GUI until told to close While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd For TEXT1 I enter the folder names and as long as it exists on c:\ it should work for TEXT2 I enter .ext - so as long as the file filename with the extension i type in it should find it for TEXT3 I enter the new folder location and as long as it exists it should move it Edited May 21, 2010 by jbsoccerbrit Link to comment Share on other sites More sharing options...
Developers Jos Posted May 21, 2010 Developers Share Posted May 21, 2010 You forgot already about post #7 which showed GuiCtrlRead() and you have 2 While...Wend loops? 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 More sharing options...
jbsoccerbrit Posted May 21, 2010 Author Share Posted May 21, 2010 Forgetting the GUICtrlRead... so it seems 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