Sign in to follow this  
Followers 0
KurogamineNox

Can someone help me with WinList() Function?

10 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

You can use it like WinList("Title") or WinList(WinGetTitle("Untitled - ")); get full title to list only windows with given title.


edited

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by KurogamineNox

Share this post


Link to post
Share on other sites

#9 ·  Posted (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 by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0