KurogamineNox Posted September 16, 2010 Share Posted September 16, 2010 AS the title says, I'm asking for some help with the WinList() Function. I was looking at the help file for it and its example $var = WinList() For $i = 1 to $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1]) EndIf Next Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc I have no clue how to change the coding and reduce its size to only check windows with "- Chat Window" In its name. Its only "- Chat Window" because of Opt("WinTitleMatchMode", 2) in my program. I want it to like, check every window with the name in it and get the text either WinGetText() Or ControlGetText() My original coding uses this ControlGetText("- Chat Window", "", "RichEdit20W1") and depending on what it gets(after everything has like been done) I would have something similar to this ControlSetText("- Chat Window", "", "RichEdit20W2", "some random text") ControlSend("- Chat Window", "", "RichEdit20W2", "{ENTER}") What I am trying to achieve is it reads a text from a specific window, if it has a valid command it does what ever I set, then sends text to that specific window then checks the next window(hence a repeated process) Ive tried already to try to get WinList() Work but I have little knowledge of it so I kind of failed so far in my efforts to get what I want. Could someone help me achieve this? Link to comment Share on other sites More sharing options...
seandisanti Posted September 16, 2010 Share Posted September 16, 2010 (edited) just modify the line that checks to make sure the title is not blank... If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then to see if it contains your string... If StringInstr($var[$i][0],"your string") AND IsVisible($var[$i][1]) ***edit*** didn't need to quote everything, sorry about that Edited September 16, 2010 by cameronsdad Link to comment Share on other sites More sharing options...
E1M1 Posted September 16, 2010 Share Posted September 16, 2010 You can use it like WinList("Title") or WinList(WinGetTitle("Untitled - ")); get full title to list only windows with given title. edited Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 16, 2010 Author Share Posted September 16, 2010 I tried WinList("- Chat Window") which failed which is kind of why I started this topic lol. cameronsdad, Ill try what you typed. I hope this works. Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 16, 2010 Author Share Posted September 16, 2010 Okay, this part worked Opt("WinTitleMatchMode", 2) $var = WinList("- Chat Window") 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]) EndIf Next Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc It only looked at windows with "- Chat Window" in its name. Now all that is left is to check the text in that window at the same time I am not sure if this will work for what I need If StringInstr($var[$i][0],"your string") AND IsVisible($var[$i][1]) as though I am not checking to see if it contains my string. I just need it to get all the text from the window it checks as I already have my other coding ready to do the command depending on the string. Hence that I have an array to split the String of what it read from the window to give me only the last line and activate commands depending on that last line. Select case StringInStr($LastLine, $Nickname);You activate a command _DoSomething($LastLine) case Not StringInStr($LastLine, $Nickname);Client sends you a command _DoSomething2($LastLine) EndSelect So basically all I am looking for is getting all the text in a specific window from a handle, which I originally used this. ControlGetText("- Chat Window", "", "RichEdit20W1") Maybe I can modify what you said into using this? Ill experiment until someone tells me if I can or not. you know, lolz. Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 16, 2010 Author Share Posted September 16, 2010 Waddya know, it worked, doing this though. MsgBox(0, "Details", ControlGetText($var[$i][0], "", "RichEdit20W1")) I cant believe it actually worked. Thank you guys for helping me understand this and wakillon(if he reads this topic)for telling me about WinList() All that is left is to implement it. Link to comment Share on other sites More sharing options...
seandisanti Posted September 16, 2010 Share Posted September 16, 2010 Waddya know, it worked, doing this though. MsgBox(0, "Details", ControlGetText($var[$i][0], "", "RichEdit20W1")) I cant believe it actually worked. Thank you guys for helping me understand this and wakillon(if he reads this topic)for telling me about WinList() All that is left is to implement it. The reason that the other way WinList("Title") is because you're looking for a substring that's not at the start of the title. If you play with WinTitleMatchMode, you can look for a substring, but i figured just modifying the code you'd posted would be easier than explaining that part too. Now WinList gives you handle for each of the windows that it identifies too, so you can just use WinGetText($list[$i][1]) i believe to check the text, or if you're looking for only text with a certain substring you could even do... If StringInStr($winlist[$i][0],"Your Substring") then ;your code here Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 16, 2010 Author Share Posted September 16, 2010 (edited) Okay, new problem... Aparently If a new window is made while the program is still running, it wont check that new window's text. If you guys still check this, Some help please? Maybe I need to make it refresh the list of windows that it is checking to see if new windows have been opened? Edited September 16, 2010 by KurogamineNox Link to comment Share on other sites More sharing options...
seandisanti Posted September 16, 2010 Share Posted September 16, 2010 (edited) Okay, new problem...Aparently If a new window is made while the program is still running, it wont check that new window's text. If you guys still check this, Some help please?Maybe I need to make it refresh the list of windows that it is checking to see if new windows have been opened?if you're looping a winlist, it will check all new windows, yes. sooooo, just make sure that the substring you're looking for in the title is not in the title of the new window, problem solved***edit***i misunderstood because i read over it too quickly; just loop your winlist etc and it will watch for new windows Edited September 16, 2010 by cameronsdad Link to comment Share on other sites More sharing options...
KurogamineNox Posted September 16, 2010 Author Share Posted September 16, 2010 Thanks, I moved the $var = WinList("- Chat Window") into my While 1 section as it will loop just as if I used a loop function anyways. 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