cdjphoenix Posted September 11, 2012 Share Posted September 11, 2012 I have ran into what I think is an odd problem with one of my scripts. I have a script that asks you for a source drive and a target drive along with the target user profile that you want to copy. When I had it setup to use multiple input boxes the script worked without a problem. Here is a example of some code from it: Dim $TargetDrive = InputBox("Target Drive", "Enter Target Drive Letter.", "", " M2") Dim $SourceDrive = InputBox("Source Drive", "Enter Source Drive Letter.", "", " M2") Dim $SourceUser = InputBox("Source User", "Enter Source User Name.", "") ;Win7 > Win7 if FileExists($TargetDrive & "\Users") and FileExists ($SourceDrive & "\Users") Then RunWait(@ComSpec & " /c xcopy " & $SourceDrive & "\Users\" & $SourceUser & "\Desktop\* %userprofile%\Desktop\* /e /c /h") However I merged this script into one of my other programs and gave it it's own tab. To get around the input boxes from popping up at the wrong time i decided to use GUICtrlCreateInput instead. Here is a section of the revised code: $tab3 = GUICtrlCreateTabItem("Data Transfer") GUICtrlCreateLabel("Source", 25, 100, 121, 21) $SourceDrive = GUICtrlCreateInput("", 70, 100, 121, 21) GUICtrlCreateLabel("Target", 25, 130, 121, 21) $TargetDrive = GUICtrlCreateInput("", 70, 130, 121, 21) GUICtrlCreateLabel("User", 25, 160, 121, 21) $SourceUser = GUICtrlCreateInput("", 70, 160, 121, 21) $DataTransferButton = GUICtrlCreateButton("Start", 25, 190, 75) case $msg = $DataTransferButton ;Win7 > Win7 if FileExists($TargetDrive & "\Users") and FileExists ($SourceDrive & "\Users") Then RunWait(@ComSpec & " /c xcopy " & $SourceDrive & "\Users\" & $SourceUser & "\Desktop\* %userprofile%\Desktop\* /e /c /h") Now when ever I try to run it, by hitting start, I just get a bunch of "invalid number of parameter" cmd windows. I have gone back and looked for errors/typos but everything was copy and pasted and is identical. I am completely lost here on why input boxes seem to work but GUICtrlCreateInput does not. Any help would be greatly appreciated. -Thanks- cdjphoenix Link to comment Share on other sites More sharing options...
MrMitchell Posted September 12, 2012 Share Posted September 12, 2012 The GUICtrlCreateInput function returns the controlID of the new control. To get the contents of it you need to use GUICtrlRead. In the Help File look up the GUICtrlCreateInput function and check out the Remarks section. Link to comment Share on other sites More sharing options...
Tripredacus Posted September 12, 2012 Share Posted September 12, 2012 Prior to the RunWait, MsgBox out all your variables to verify that you are constructing a proper command. FYI, you didn't post your OS, but XCOPY is deprecated in Vista and newer Windows OSes. http://blogs.msdn.com/b/jonbox/archive/2007/06/09/xcopy-is-depracated-on-windows-vista.aspx Twitter | MSFN | VGCollect Link to comment Share on other sites More sharing options...
cdjphoenix Posted September 12, 2012 Author Share Posted September 12, 2012 I have made the suggested changes to my script by adding GUIctrlread to retreave the contents of the variables. Here is my new code: $tab3 = GUICtrlCreateTabItem("Data Transfer") GUICtrlCreateLabel("Source", 25, 100, 121, 21) $SourceDriveInput = GUICtrlCreateInput("", 70, 100, 121, 21) $SourceDrive = GUICtrlRead($SourceDriveInput) GUICtrlCreateLabel("Target", 25, 130, 121, 21) $TargetDriveInput = GUICtrlCreateInput("", 70, 130, 121, 21) $TargetDrive = GUICtrlRead($TargetDriveInput) GUICtrlCreateLabel("User", 25, 160, 121, 21) $SourceUserInput = GUICtrlCreateInput("", 70, 160, 121, 21) $SourceUser = GUICtrlRead($SourceUserInput) $DataTransferButton = GUICtrlCreateButton("Start", 25, 190, 75) RunWait(@ComSpec & " /c xcopy " & $SourceDrive & "Users" & $SourceUser & "Desktop* %userprofile%Desktop* /e /c /h") I have a new problem where i get cmd windows saying that "File Not Found - * ". I went with K-Marts suggestion of msboxing out my vairables and got some interesting results. TargetDrive = "Empty" TargetDriveInput= 34 SourceDrive = "Empty" SourceDriveInput = 32 SourceUser = "Empty" SourceUserInput = 36 The data entered for each was: TargetDrive = C: SourceDrive = C: SourceUser = Creed I hope this makes sense to someone because I'm lost. Thanks Again -cdjphoenix- Link to comment Share on other sites More sharing options...
BrewManNH Posted September 12, 2012 Share Posted September 12, 2012 You can't read the contents of the controls until there's something in them, right now, from looking at what you posted, you're reading them right after you created them. 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...
cdjphoenix Posted September 12, 2012 Author Share Posted September 12, 2012 Awesome, I got it working Brewman. I just had a small misunderstanding on how the code was ran. I moved the GUIctrlread sections farther down the script to right before the transfer is exicuted and it works flawlessly. Thanks again everyone -cdjphoenix- Link to comment Share on other sites More sharing options...
Tripredacus Posted September 13, 2012 Share Posted September 13, 2012 I went with K-Marts suggestion of msboxing out my vairables and got some interesting results.Interesting result for me is I haven't been called K-Mart in a long time. Twitter | MSFN | VGCollect 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