KurogamineNox Posted September 19, 2010 Share Posted September 19, 2010 What can I add to this to make it that if no windows exist of "- Chat Window" then do a specific event. ;Only reads visible windows that have "- Chat Window" in its name If $var[$i][0] <> "- Chat Window" AND IsVisible($var[$i][1]) Then $Text = ControlGetText($var[$i][0], "", "RichEdit20W1") $array = StringSplit($text,@lf) EndIf Link to comment Share on other sites More sharing options...
seandisanti Posted September 19, 2010 Share Posted September 19, 2010 What can I add to this to make it that if no windows exist of "- Chat Window" then do a specific event. ;Only reads visible windows that have "- Chat Window" in its name If $var[$i][0] <> "- Chat Window" AND IsVisible($var[$i][1]) Then $Text = ControlGetText($var[$i][0], "", "RichEdit20W1") $array = StringSplit($text,@lf) EndIf Check your @error after the call to WinList() that's not in the segment you've provided Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 19, 2010 Author Share Posted September 19, 2010 My WinList() is $var = WinList("- Chat Window") How would I set the @error? I am looking at the help file though am I to use SetError or something? I really have no clue right now. Link to comment Share on other sites More sharing options...
seandisanti Posted September 19, 2010 Share Posted September 19, 2010 (edited) My WinList() is $var = WinList("- Chat Window") How would I set the @error? I am looking at the help file though am I to use SetError or something? I really have no clue right now. oops, winlist doesn't set error... just check if ubound($var) = 1 ;no results ***edit*** changed my variable name to match yours Edited September 19, 2010 by cameronsdad Link to comment Share on other sites More sharing options...
Varian Posted September 19, 2010 Share Posted September 19, 2010 If I understand you correctly, this would work...I am not familiar with IsVisible. Is this your own function?Opt('WinTitleMatchMode', 4) $Var = WinList("[REGEXPTITLE:(?i)- Chat Window]") If $Var[0][0] = 0 Then ;No Windows with "- Chat Window" exists...Do Your Stuff Here Else For $i = 1 To $Var[0] If Not BitAND(WinGetState($Var[$i][1]), 2) Then ContinueLoop ;If Not Visible, go to Next Window Occurence $Text = ControlGetText($Var[$i][0], "", "RichEdit20W1") $Array = StringSplit($Text, @LF) Next EndIf Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 19, 2010 Author Share Posted September 19, 2010 IsVisible was from the help file I think. Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 19, 2010 Author Share Posted September 19, 2010 IsVisible was from the help file I think. Okay, after frustraighting through all this work to figure out what is going on with the no window stuff. Aparently if there is no windows everything inside For $i = 1 To $var[0][0] Does not activate. After experimenting again. Its kind of wierd but I had to move everything to the bottom of the While 1 section. For it to work properly of reading text and executing them they had to be inside that for command, but it would glitch if there was no windows. I moved the for down to the bottom of the While 1 section and added the ones that would read text from windows into the for section, Which made it work For $i = 1 To $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "- Chat Window" And IsVisible($var[$i][1]) Then ;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1]) $Text = ControlGetText($var[$i][0], "", "RichEdit20W1") $array = StringSplit($Text, @LF) EndIf If $array[0] > 1 Then $lastline = $array[$array[0]] Else $lastline = $array[1] EndIf Select Case StringInStr($lastline, $Nickname);You activate a command _DoSomething($lastline) Case Not StringInStr($lastline, $Nickname);Client sends you a command _DoSomething2($lastline) EndSelect Next And of course if there are no windows everything in that for loop does nothing so in the While 1 this still exists since I still have to set the variables. Cant set variables if the for isnt called so this stays in the While 1 above the For section. $lastline = "" $Text = "" $array = StringSplit($Text, @LF) Any thoughts on why(if what I typed was not confusing) This happened? Link to comment Share on other sites More sharing options...
seandisanti Posted September 19, 2010 Share Posted September 19, 2010 did you see my last post about checking Ubound($var) = 1? Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 19, 2010 Author Share Posted September 19, 2010 (edited) did you see my last post about checking Ubound($var) = 1?Yes, it did not work because of the For Statement. When ever there was no window everything with in the For next statement got disabled. Its fixed now that I set everything in the right places but I dont know why everything in the for next statement got disabled when no windows were there. Both codings could have probably worked if I had my For Next statement in the right places(which I just noticed) but I already have it fixed in my way. I just still dont know about why it disabled everything in the for next statement. Edited September 19, 2010 by KurogamineNox Link to comment Share on other sites More sharing options...
seandisanti Posted September 19, 2010 Share Posted September 19, 2010 Yes, it did not work because of the For Statement. When ever there was no window everything with in the For next statement got disabled. Its fixed now that I set everything in the right places but I dont know why everything in the for next statement got disabled when no windows were there. Both codings could have probably worked if I had my For Next statement in the right places(which I just noticed) but I already have it fixed in my way. I just still dont know about why it disabled everything in the for next statement. ok... i meant... If Ubound($var) <> 1 Then ;your loop Else ;not found do something else Endif Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 19, 2010 Author Share Posted September 19, 2010 I think that would work but i still had to fix my For Next Statement because that was what was ruining everything. Link to comment Share on other sites More sharing options...
seandisanti Posted September 19, 2010 Share Posted September 19, 2010 I think that would work but i still had to fix my For Next Statement because that was what was ruining everything.your For loop would not run if no matching windows were found, so it wouldn't ruin anything... Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 19, 2010 Author Share Posted September 19, 2010 your For loop would not run if no matching windows were found, so it wouldn't ruin anything...It ruined my coding because I had everything basically inside it, which kept causing my program to not function properly when there where no windows. All the coding had to be moved and put the for next statement under it and only have the code needed for that statement inside it. Link to comment Share on other sites More sharing options...
seandisanti Posted September 19, 2010 Share Posted September 19, 2010 It ruined my coding because I had everything basically inside it, which kept causing my program to not function properly when there where no windows. All the coding had to be moved and put the for next statement under it and only have the code needed for that statement inside it.Only loop what needs to be looped, and only run the loop when the conditions are right, everything else can be outside of the if, but within the while... Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 20, 2010 Author Share Posted September 20, 2010 Only loop what needs to be looped, and only run the loop when the conditions are right, everything else can be outside of the if, but within the while...Yeah, I learned that the hard way. Link to comment Share on other sites More sharing options...
seandisanti Posted September 20, 2010 Share Posted September 20, 2010 Yeah, I learned that the hard way.We never learn from things we do correctly the first time. 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