zoel Posted May 28, 2019 Share Posted May 28, 2019 Hi people, I want to run a cmd command i.e ipconfig and have the output in the input frame on my GUI. Can somebody give some help. This is my code so far. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= Local $aWndPos Local $hWnd = GUICreate("Form2", 900, 420, -1, -1, Default + $WS_MAXIMIZE) GUISetBkColor(0xE4E4E4) Local $idFilemenu = GUICtrlCreateMenu("&File") Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu) Local $idInput = GUICtrlCreateInput("", 210, 10, 660, 360) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) Local $idButton = GUICtrlCreateButton("Button1", 10, 10, 190, 25) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MAXIMIZE ;~ Uncomment lines below if you wish to have the inputbox take up the entire window ;~ $aWndPos = WinGetPos($hWnd) ;~ GUICtrlSetPos($idInput, 11, 11, $aWndPos[2] - 54, $aWndPos[3] - 99) Case $idExititem Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
BrewManNH Posted May 28, 2019 Share Posted May 28, 2019 Don't use an Input control, use an Edit control, use the Run function and look in the help file for examples using $STDERR_MERGED or $STDOUT_CHILD to get the output of the command you're running. zoel 1 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...
zoel Posted May 28, 2019 Author Share Posted May 28, 2019 Thank you sir Link to comment Share on other sites More sharing options...
zoel Posted May 28, 2019 Author Share Posted May 28, 2019 My script doesn't work us it should, I can't do it #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $iPID = Run("cmd.exe", "ipconfig", @SW_SHOWMAXIMIZED) #Region ### START Koda GUI section ### Form= Local $aWndPos Local $hWnd = GUICreate("Form2", 900, 420, -1, -1, Default + $WS_MAXIMIZE) GUISetBkColor(0xE4E4E4) Local $idFilemenu = GUICtrlCreateMenu("&File") Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu) Local $idInput = GUICtrlCreateInput("", 210, 10, 660, 360) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) Local $idButton = GUICtrlCreateButton("Button1", 10, 10, 190, 25) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MAXIMIZE ;~ Uncomment lines below if you wish to have the inputbox take up the entire window ;~ $aWndPos = WinGetPos($hWnd) ;~ GUICtrlSetPos($idInput, 11, 11, $aWndPos[2] - 54, $aWndPos[3] - 99) Case $idExititem Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 28, 2019 Moderators Share Posted May 28, 2019 @zoel "doesn't work" should be banned from the English language. How about some detail on what isn't working as expected? You mentioned outputting a command to your Edit (now Input) control, but I see no code written to do this. zoel 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
zoel Posted May 28, 2019 Author Share Posted May 28, 2019 Thank you sir, I don't know how to doit! Link to comment Share on other sites More sharing options...
BrewManNH Posted May 28, 2019 Share Posted May 28, 2019 Open the help file, look at STDOutRead, try the example script to see how it's done, and learn something new. Or search the forum here for the 1000's of examples using stdoutread. zoel 1 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...
zoel Posted May 28, 2019 Author Share Posted May 28, 2019 Ok I will try it, thanks! Link to comment Share on other sites More sharing options...
zoel Posted May 28, 2019 Author Share Posted May 28, 2019 What i ever i try i have an error, I'm unable to do this, can somebody give me an example. thanks! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 28, 2019 Moderators Share Posted May 28, 2019 (edited) 10 minutes ago, zoel said: What i ever i try i have an error, I'm unable to do this, can somebody give me an example. thanks! How about posting what you are trying, or the error, rather than asking us to guess?? We cannot assist if you continue forcing us to pull teeth to get info from you. Be aware, this is not a forum where someone is going to spoon feed it to you and do all the work for you. We're more than happy to help, but the "I can't do it, do it for me" attitude will get you nowhere. Edited May 28, 2019 by JLogan3o13 zoel 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
zoel Posted May 28, 2019 Author Share Posted May 28, 2019 Ok sir I'll try it again to see if I can do it by my self! thanks Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 28, 2019 Moderators Share Posted May 28, 2019 Just now, zoel said: Ok sir I'll try it again to see if I can do it by my self! thanks Post the code you're using, and the error you're getting - not difficult zoel 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
zoel Posted May 28, 2019 Author Share Posted May 28, 2019 The error "C:\Users\giorgis\Downloads\autoit-v3\autoit_scripts\ex2.au3"(7,57) : error: syntax error The code Quote expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() Func Example() Local $sFilePath = @ScriptDir ; Search the current script directory. Local $sFilter = "*.*" ; Search for all files in the current directory. For a list of valid wildcards, search for 'Wildcards' in the Help file. ; If the file path isn't a directory then return from the 'Example' function. If Not StringInStr(FileGetAttrib($sFilePath), "D") Then Return SetError(1, 0, 0) EndIf ; Remove trailing backslashes and append a single trailing backslash. $sFilePath = StringRegExpReplace($sFilePath, "[\\/]+\z", "") & "\" #cs Commandline parameters for DIR: /B - Simple output. /A-D - Search for all files, minus folders. /S - Search within subfolders. #ce Local $iPID = Run(@ComSpec & ' /C DIR "' & $sFilePath & $sFilter & '" /B /A-D /S', $sFilePath, @SW_HIDE, $STDOUT_CHILD) ; If you want to search with files that contains unicode characters, then use the /U commandline parameter. ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead. Local $sOutput = StdoutRead($iPID) ; Use StringSplit to split the output of StdoutRead to an array. All carriage returns (@CRLF) are stripped and @CRLF (line feed) is used as the delimiter. Local $aArray = StringSplit(StringTrimRight(StringStripCR($sOutput), StringLen(@CRLF)), @CRLF) If @error Then MsgBox($MB_SYSTEMMODAL, "", "It appears there was an error trying to find all the files in the current script directory.") Else ; Display the results. _ArrayDisplay($aArray) EndIf EndFunc ;==>Example #Region ### START Koda GUI section ### Form= Local $aWndPos Local $hWnd = GUICreate("Form2", 900, 420, -1, -1, Default + $WS_MAXIMIZE) GUISetBkColor(0xE4E4E4) Local $idFilemenu = GUICtrlCreateMenu("&File") Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu) Local $idInput = GUICtrlCreateInput("", 210, 10, 660, 360) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) Local $idButton = GUICtrlCreateButton("Button1", 10, 10, 190, 25) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MAXIMIZE ;~ Uncomment lines below if you wish to have the inputbox take up the entire window ;~ $aWndPos = WinGetPos($hWnd) ;~ GUICtrlSetPos($idInput, 11, 11, $aWndPos[2] - 54, $aWndPos[3] - 99) Case $idExititem Exit EndSwitch WEnd I can't understand the example from the help file. All I want is to run a cmd command like ipconfig when I push the button and have the output in the input form. Thank you! Link to comment Share on other sites More sharing options...
Subz Posted May 28, 2019 Share Posted May 28, 2019 Download and install the full script editor: https://www.autoitscript.com/site/autoit-script-editor/downloads/ When you run your code within Scite it will give you more error information, in this case you are missing udfs at the top of your script, in the examples in the help file remember to note down the includes required for that function/variable: #include <Array.au3> ;~ This is for the _ArrayDisplay() function #include <AutoItConstants.au3> ;~ This declares the $STDOUT_CHILD Variable #include <MsgBoxConstants.au3> ;~ This declares the $MB_SYSTEMMODAL variable NB: There are other functions that would capture a folder paths i.e. _FileListToArrayRec which don't require CMD. zoel 1 Link to comment Share on other sites More sharing options...
zoel Posted May 28, 2019 Author Share Posted May 28, 2019 Thank you Subz 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