Jump to content
Sign in to follow this  

Problem with winlist

Recommended Posts

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

$app = "CodeVisionAVR"
$w = WinList($app)

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

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)


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])

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
    If $sHold Then Return StringSplit(StringTrimRight($sHold, 1), @LF);return a 1 based array
    Return SetError(1, 0, 0)
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.

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.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...