zoel Posted May 29, 2019 Share Posted May 29, 2019 Hi people, when I run my script it just flashes the Gui and it closes, I can't understand why this happening, can you check my code and tell me what is wrong. expandcollapse popup#include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <ScrollBarsConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> Local $aWndPos Local $idFilemenu = GUICtrlCreateMenu("&File") Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu) Local $idButton = GUICtrlCreateButton("IPConfig", 10, 10, 190, 25) GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) $NetAs = GUICreate("NetAs-Network Assistant", 1096, 497, 182, 135) Local $idInput = GUICtrlCreateEdit("", 168, 24, 921, 465) Local $Button1 = GUICtrlCreateButton("IPconfig", 16, 32, 75, 25) Local $Button2 = GUICtrlCreateButton("?", 96, 32, 19, 25) Local $Button3 = GUICtrlCreateButton("Button3", 16, 72, 75, 25) Local $Button4 = GUICtrlCreateButton("?", 96, 72, 19, 25) Local $Button5 = GUICtrlCreateButton("Button5", 16, 112, 75, 25) Local $Button6 = GUICtrlCreateButton("?", 96, 112, 19, 25) Local $Button7 = GUICtrlCreateButton("Button7", 16, 152, 75, 25) Local $Button8 = GUICtrlCreateButton("?", 96, 152, 19, 25) Local $Button9 = GUICtrlCreateButton("Button9", 16, 192, 75, 25) Local $Button10 = GUICtrlCreateButton("?", 96, 192, 19, 25) Local $Button11 = GUICtrlCreateButton("Button11", 16, 232, 75, 25) Local $Button12 = GUICtrlCreateButton("?", 96, 232, 19, 25) Local $Button13 = GUICtrlCreateButton("Button13", 16, 272, 75, 25) Local $Button14 = GUICtrlCreateButton("?", 96, 272, 19, 25) Local $Button15 = GUICtrlCreateButton("Button15", 16, 312, 75, 25) Local $Button16 = GUICtrlCreateButton("?", 96, 312, 19, 25) Local $Button17 = GUICtrlCreateButton("Button17", 16, 352, 75, 25) Local $Button18 = GUICtrlCreateButton("?", 96, 352, 19, 25) Local $Button19 = GUICtrlCreateButton("Button19", 16, 392, 75, 25) Local $Button20 = GUICtrlCreateButton("?", 96, 392, 19, 25) Local $Button21 = GUICtrlCreateButton("Button21", 16, 432, 75, 25) Local $Button22 = GUICtrlCreateButton("?", 96, 432, 19, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idExititem Exit Case $Button1 GUICtrlSetData($idInput, _CmdInfo() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) EndSwitch WEnd Func _CmdInfo($_sCmdInfo = "ipconfig /all") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; 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 = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 29, 2019 Moderators Share Posted May 29, 2019 @zoel you need to start at least trying things for yourself rather than asking forum members to do everything for you. Your While statement has 3 Case clauses that could potentially close your GUI. Start commenting them out one at a time to find the culprit. 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 29, 2019 Author Share Posted May 29, 2019 Thank you! Link to comment Share on other sites More sharing options...
zoel Posted May 29, 2019 Author Share Posted May 29, 2019 When I comment Case $idExititem my script works and I can see the Gui, but I lose the file menu. How I can keep my file menu? Link to comment Share on other sites More sharing options...
BrewManNH Posted May 29, 2019 Share Posted May 29, 2019 Your menu is created before the gui it belongs in, try putting those three after the GUICreate. 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 29, 2019 Author Share Posted May 29, 2019 Thank you sir!! Link to comment Share on other sites More sharing options...
Zedna Posted May 29, 2019 Share Posted May 29, 2019 According to help for GUICtrlCreateMenu https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateMenu.htm here is your code fixed to be working expandcollapse popup#include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <ScrollBarsConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> Local $aWndPos $NetAs = GUICreate("NetAs-Network Assistant", 1096, 497, 182, 135) Local $idFilemenu = GUICtrlCreateMenu("&File") Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu) ;~ Local $idButton = GUICtrlCreateButton("IPConfig", 10, 10, 190, 25) ;~ GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKWIDTH, $GUI_DOCKHEIGHT)) Local $idInput = GUICtrlCreateEdit("", 168, 24, 921, 465) Local $Button1 = GUICtrlCreateButton("IPconfig", 16, 32, 75, 25) Local $Button2 = GUICtrlCreateButton("?", 96, 32, 19, 25) Local $Button3 = GUICtrlCreateButton("Button3", 16, 72, 75, 25) Local $Button4 = GUICtrlCreateButton("?", 96, 72, 19, 25) Local $Button5 = GUICtrlCreateButton("Button5", 16, 112, 75, 25) Local $Button6 = GUICtrlCreateButton("?", 96, 112, 19, 25) Local $Button7 = GUICtrlCreateButton("Button7", 16, 152, 75, 25) Local $Button8 = GUICtrlCreateButton("?", 96, 152, 19, 25) Local $Button9 = GUICtrlCreateButton("Button9", 16, 192, 75, 25) Local $Button10 = GUICtrlCreateButton("?", 96, 192, 19, 25) Local $Button11 = GUICtrlCreateButton("Button11", 16, 232, 75, 25) Local $Button12 = GUICtrlCreateButton("?", 96, 232, 19, 25) Local $Button13 = GUICtrlCreateButton("Button13", 16, 272, 75, 25) Local $Button14 = GUICtrlCreateButton("?", 96, 272, 19, 25) Local $Button15 = GUICtrlCreateButton("Button15", 16, 312, 75, 25) Local $Button16 = GUICtrlCreateButton("?", 96, 312, 19, 25) Local $Button17 = GUICtrlCreateButton("Button17", 16, 352, 75, 25) Local $Button18 = GUICtrlCreateButton("?", 96, 352, 19, 25) Local $Button19 = GUICtrlCreateButton("Button19", 16, 392, 75, 25) Local $Button20 = GUICtrlCreateButton("?", 96, 392, 19, 25) Local $Button21 = GUICtrlCreateButton("Button21", 16, 432, 75, 25) Local $Button22 = GUICtrlCreateButton("?", 96, 432, 19, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idExititem Exit Case $Button1 GUICtrlSetData($idInput, _CmdInfo() & @CRLF) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) EndSwitch WEnd Func _CmdInfo($_sCmdInfo = "ipconfig /all") Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ; 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 = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF) Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF) Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr Return $sReult EndFunc zoel 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
zoel Posted May 30, 2019 Author Share Posted May 30, 2019 Thank you Zedna 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