jozizo Posted September 9, 2014 Share Posted September 9, 2014 I think everything is working as designed, I'm just not understanding...well...I'm not sure what I'm not understanding. I'm a bit new, so please forgive if this is an easy one. I have the following function: Func WrapCheck() Local $sText = WinGetText("Direction") $iWrap = StringRegExp($sText, "UP") If $iWrap == 1 Then $iWrapMsg = "It's Up!" ElseIf $iWrap == 0 Then $iWrapMsg = "" EndIf Return $iWrapMsg EndFunc And when I need the results, I use: $iWrapLabel = GUICtrlCreateLabel(WrapCheck(), 10, 140, 225, 60) The window "Direction" has a bit of text. Either Up....or something else all together. I'm checking for "Up" explicitly. That's all I want to look for. If it's not there, I don't need anything returned really. The problem is, this only works once I run the script. I have the Label within my main loop (the 'While 1' part). When I run the script, manually changing the text from my source window, it works. It returns exactly what I want it to. But, if the text in the window changes to "Up", my label doesn't update with it. If at all possible, I would really like to learn HOW to fish. So a direction in a concept or perhaps I'm not seeing the logic or something I would really appreciate that. But if I'm way off base I'll totally just take the fish for now. Any help is greatly appreciated. Link to comment Share on other sites More sharing options...
MikahS Posted September 9, 2014 Share Posted September 9, 2014 (edited) Change the call to StringRegExp to StringReplace and instead of checking the variable, check @extended for the number of time it's been replaced. Like so: (optional, you can keep doing it the way you have been) If @extended > 0 Then $iWrapsMsg = "It's Up!" Else $iWrapMsg = "" EndIf ;I wouldn't try remaking the label control everytime, but use: ;If you don't use the above conditional, at least try GUICtlSetData intead of creating it everytime in your while loop GUICtrlSetData($iWrapLabel, $iWrapMsg) ; this will update the label with the value you have gotten from doing your conditional statement Also, storing the creation of the Label control in the while loop is not a good practice, I would keep it where you create the GUI, and update it everytime the function is ran. Please let me know if you have questions or comments Edited September 9, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
wisem2540 Posted September 9, 2014 Share Posted September 9, 2014 Jozizo, Look up AdlibRegister It will run that function by default every 250ms Link to comment Share on other sites More sharing options...
MikahS Posted September 9, 2014 Share Posted September 9, 2014 Posting your whole script will also help us help you 232showtime 1 Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Kovacic Posted September 10, 2014 Share Posted September 10, 2014 Jozizo, Look up AdlibRegister It will run that function by default every 250ms this is your best bet. You can also call it with a button, and even turn it off with AdlibUnRegister, its a very handy and simple func and I use it often for watchdog functions. C0d3 is P0etry( ͡° ͜ʖ ͡°) 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