Sign in to follow this  
Followers 0
GerryKeely

Problem with winlist

3 posts in this topic

I am using winlist to extract a program title from another application.Part of the code is as follows

Opt("WinTitleMatchMode",2)
$app = "CodeVisionAVR"
$w = WinList($app)


if $w[0][0]=0 Then
    MsgBox(0,"",$app & " is not open")
    Exit
    EndIf
$msg = $w[2][0]
ConsoleWrite($msg)

the title returned is "CodeVisionAVR - freq_count.prj - [c:\cvavr\myfiles\freq_count.c]" which is correct.

However sometimes this does not return the correct information and I have to use $w[1][0] instead.Its as if the values returned by $w[1][0] and $w[2][0] are crossed.

Is this a problem with windows(I have windows XP-Home)

Regards

Gerry Keely

Share this post


Link to post
Share on other sites



Try running your app with this

$aWin = _WinGetTitleByExe('notepad.exe')
For $iCC = 1 To $aWin[0]
    MsgBox(64, 'Info', $aWin[$iCC])
Next

Func _WinGetTitleByExe($sExe)
    Local $aPList = ProcessList($sExe)
    Local $sHold, $aWList = WinList()
    For $iCC = 1 To $aWList[0][0]
        For $xCC = 1 To $aPList[0][0]
            If WinGetProcess($aWList[$iCC][1]) = $aPList[$xCC][1] And _
                BitAND(WinGetState($aWList[$iCC][1]), 2) And _
                $aWList[$iCC][0] <> '' Then
                $sHold &= $aWList[$iCC][0] & @LF
            EndIf
        Next
    Next
    If $sHold Then Return StringSplit(StringTrimRight($sHold, 1), @LF);return a 1 based array
    Return SetError(1, 0, 0)
EndFunc
You've preset with yours saying that the 2nd window returned would be the window you wanted, that's not always the case.

With the above code, you can get all the windows names from the actual process that is running.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

To SmOke_N

Thank you very much for your reply. I'll give that a try.

Regards

Gerry

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