StuckUser Posted August 12, 2019 Share Posted August 12, 2019 (edited) I am having trouble getting new info to override old info in a gui input box. I have tried various methods from my current to setdata ($output, $stuff & @CRLF), to using guictrledit_settext and doing this with and without setstate focus and all combinations of these you could think of. im at a loss. ill post the gui creation and both functions that should be relevant. Quote $hGUI = GUICreate("Stuff", 600, 280) GUICtrlCreateLabel("Area", 10, 5, 100, 15) $hCombo = GUICtrlCreateCombo("", 10, 20, 100, 20) GUICtrlCreateLabel("Value Needed", 115, 5, 140, 15) $InputValue = GUICtrlCreateInput("", 115, 20, 100, 20) $lEmail = GUICtrlCreateLabel("DL Provided", 260, 5, 100, 15) $output = GUICtrlCreateInput("", 220, 20, 370, 20, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) $button = GUICtrlCreateButton("Compose Email", 510, 42, 80, 24) $Email = GUICtrlCreateCombo("", 300, 20, 275, 20) Quote If $sTitleText == "KY" Then $locData = "KY" EmailDL() GUICtrlSetState($output, $GUI_FOCUS) GUICtrlSetData($output, "") GUICtrlSetData($output, GUICtrlRead ($Email,0)) ContinueLoop EndIf ;ContinueLoop is here to exit out of this case in a while switch. Quote Func EmailDL() $sDL="" $iRows = UBound($Input, $UBOUND_ROWS) Local $tempInput MsgBox($MB_SYSTEMMODAL, "Input", $Input[2]) MsgBox($MB_SYSTEMMODAL, "DL", $DL[2]) For $i = 1 To $iRows-1 $tempInput = StringStripWS($Input[$i], 1) $tempInput = StringStripWS($tempInput, 2) If $locData == $tempInput Then $sDL = $DL[$i] EndIf Next GUICtrlSetData($Email, $sDL) _GUICtrlComboBox_SetCurSel($Email, _GUICtrlComboBox_GetCurSel($locData)) Edited August 12, 2019 by StuckUser Link to comment Share on other sites More sharing options...
Seminko Posted August 15, 2019 Share Posted August 15, 2019 (edited) I'm not sure I understand what's wrong. The title implies you have issues removing text from one of the input fields. Is that so? It doesn't seem to be an issue with the GUI, at least from what little code you posted. See here, works fine: #include <EditConstants.au3> #include <ColorConstants.au3> $hGUI = GUICreate("Stuff", 600, 280) GUICtrlCreateLabel("Area", 10, 5, 100, 15) $hCombo = GUICtrlCreateCombo("", 10, 20, 100, 20) GUICtrlCreateLabel("Value Needed", 115, 5, 140, 15) $InputValue = GUICtrlCreateInput("", 115, 20, 100, 20) $lEmail = GUICtrlCreateLabel("DL Provided", 260, 5, 100, 15) $output = GUICtrlCreateInput("", 220, 20, 370, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) $button = GUICtrlCreateButton("Compose Email", 510, 42, 80, 24) GUISetState(@SW_SHOW) Sleep(1000) GUICtrlSetBkColor($output, $COLOR_RED) Sleep(1000) GUICtrlSetData($output, "Sample text") Sleep(1000) GUICtrlSetData($output, "Delete that text") Sleep(1000) GUICtrlSetData($output, "") Sleep(1000) Exit Are you receiving any errors? Do you create the gui inside of a function? It would help if you posted the entirety of your code, if you can. Edited August 15, 2019 by Seminko Link to comment Share on other sites More sharing options...
StuckUser Posted August 17, 2019 Author Share Posted August 17, 2019 The only code left out of this program is the code to retrieve data from an excel file and then code I use to parse an internal website and pull html code that is used for $sTitleText. Sorry if I was a bit unclear. The gui itself is created fine, and the code runs fine one time. When I go to run the code a second time, I get all the correct results, but the GUI isn't updated. Example: My gui has 3 boxes, site, acc, and result. 1st run, choose site and acc, result is entered in the gui. 2nd run, choose site and acc, result is correctly found (i can confirm with msg boxes) but the result in the gui is not updated. As previously stated, I have tried various methods. I know some functions like setData add to the end "result" rather than replace it, but other methods and suggestions to replace "result" have also failed. Hopefully this makes my issue a bit more clear. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted August 17, 2019 Share Posted August 17, 2019 @StuckUser Is very diffcult to make together the little pieces of code which are definitely missing a lot of functions used to populate the various controls. You should post a reproducible script that demostrates the issue you are having Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
StuckUser Posted August 17, 2019 Author Share Posted August 17, 2019 I really can't post the full code as there is company info in it. Additionally, you wouldn't have access to the excel file I am pulling data from. Sorry I put the first code in a Quote rather than Code. I have made a few changes since first posting so I will repost all of the relevant code. Overall function of the code is the same, I just created a new function splitting up some of the previous code for organizational purposes and for later usage. I also added a bit more code, but I can't really add in more than this. I noted some comments of what and where code is missing. Not sure why they didnt actually comment out. expandcollapse popup$hGUI = GUICreate("Field Ops Helper", 600, 280) GUICtrlCreateLabel("Area", 10, 5, 100, 15) $hCombo = GUICtrlCreateCombo("", 10, 20, 100, 20) GUICtrlCreateLabel("Value Needed", 115, 5, 140, 15) $InputValue = GUICtrlCreateInput("", 115, 20, 100, 20) $lEmail = GUICtrlCreateLabel("DL Provided", 260, 5, 100, 15) $output = GUICtrlCreateInput("", 220, 20, 370, 20, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) $button = GUICtrlCreateButton("Compose Email", 510, 42, 80, 24) $Email = GUICtrlCreateCombo("", 300, 20, 275, 20) $Sec1 = GUICtrlCreateLabel("", 10, 65, 575, 15) $idPic = GUICtrlCreatePic("", 10, 80, 575, 85) $Sec2 = GUICtrlCreateLabel("", 10, 175, 575, 15) $idPic2 = GUICtrlCreatePic("", 10, 190, 575, 85) Func EmailDL() $sDL="" $iRows = UBound($Input, $UBOUND_ROWS) Local $tempInput For $i = 1 To $iRows-1 $tempInput = StringStripWS($Input[$i], 1) $tempInput = StringStripWS($tempInput, 2) If $locData == $tempInput Then $sDL = $DL[$i] $sEmailFound = "true" ExitLoop ElseIf $locData == $tempInput Then $sEmailFound = "false" EndIf Next EndFunc Func SetDL() ;sets the DL into GUI GUICtrlSetData($Email, $sDL) _GUICtrlComboBox_SetCurSel($Email, _GUICtrlComboBox_GetCurSel($locData)) MsgBox($MB_SYSTEMMODAL, "EmailChange", $sDL) _GUICtrlComboBox_SetCurSel($output) GUICtrlSetData($output, "") GUICtrlSetData($output, GUICtrlRead ($Email,0)) EndFunc GUICtrlSetState($Email, $GUI_HIDE) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $InputValue If GUICtrlRead ($hCombo,0 )=="some stuff" Then ;bunch of code to pull html and extract specific text If $sTitleText == "KY" Then $locData = "KY" EmailDL() If $sEmailFound == "true" Then SetDL() EndIf ContinueLoop ;I might can get rid of this using an "Else" instead of "ContinueLoop"; however, this should have no impact on my issue. I ;have other similar "If GUICtrlRead ($hCombo,0 )=="some stuff" Then" statements that contain the same could minus a double ;If with a continue loop. EndIf ;more code to extract specific text $locData = "Loc: " & $locData EmailDL() If $sEmailFound == "true" Then SetDL() EndIf EndIf EndSwitch WEnd Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted August 17, 2019 Share Posted August 17, 2019 36 minutes ago, StuckUser said: If $locData == $tempInput Then $sDL = $DL[$i] $sEmailFound = "true" ExitLoop ElseIf $locData == $tempInput Then $sEmailFound = "false" EndIf What is this? By the way, again, we can't run the code you posted, so, can't help you. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
StuckUser Posted August 17, 2019 Author Share Posted August 17, 2019 (edited) @FrancescoDiMuro That is determines whether SetDL() gets called or not. It was part of my reorganizing the code. I needed that because some areas have to go through other checks if the first fails. As for the issue as a whole. Does anyone at least have some general suggestions to help? Again, code runs fine, but when pasting into the GUI Input Box, anytime after the first run through, nothing is pasted in. I have to close the program to clear the box and rerun it. The focus of this post should be on the GUI and only the GUI code. At this point basically the SetDL() function along with a few other tid bits of GUI code here or there. I understand not being able to run it is a problem, but this isn't the first time I've seen posts about this issue. Thanks for any suggestions you all can provide. P.S. If/When I am able to, I will try to post code that allows you to reproduce the error. Edited August 17, 2019 by StuckUser Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted August 17, 2019 Share Posted August 17, 2019 @StuckUser The whole point of that quote was "Which sense has this piece of code, because logically it has not". The issue you're having is that you have a function which populates your Input control, isn't it? So, if we can't see which code is populating the Input control, we can't help you. Is it clear? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
StuckUser Posted August 17, 2019 Author Share Posted August 17, 2019 SetDL() populates the input control. Again, everything related to the GUI has been posted. The only thing missing is the code for the excel file I am using to compare data to and additional If statements to run the exact same code as above, but for different areas based on the excel file. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted August 17, 2019 Share Posted August 17, 2019 @StuckUser When you have something that will reproduce the issue your are having and that we can run, post it. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
StuckUser Posted August 18, 2019 Author Share Posted August 18, 2019 It seems as though I happened across the fix by mistake. Thanks though. 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