Sign in to follow this  
Followers 0
RGong

Cannot read Listview items in Autoruns in Windows XP

1 post in this topic

I am working on a script to get the Image Path from a program called Autoruns by pressing shortcut "Alt+C". At first, the script did not work right in Windows Vista until I added 2 WinActive() statements in the script. Then I tested the script in Windows XP. It did not work in Windows XP no matter if the 2 WinActive() statements were added or not. It looks like the ListView control in Autoruns is different from regular one. Can anybody here help me figure out what the problem is?

To test the script, please run download Autoruns.exe and run it first. Thanks.

#include <GuiListView.au3>
#include <Array.au3>
HotKeySet("!c","GetImagePathFromAutoruns")
HotKeySet("{ESC}","QuitApp")

While True
    Sleep(500)
WEnd


Func CW($f_String)
    ConsoleWrite("Debug : "&$f_String&@CRLF)
EndFunc

Func QuitApp()
    Exit
EndFunc



Func GetImagePathFromAutoruns()

    Local $hAutoruns=WinGetHandle("Autoruns [","List2")
    If @error Then Return ""

    Local $hListView=ControlGetHandle($hAutoruns,"","[CLASS:SysListView32; INSTANCE:1]")
    Local $arrSelectedItems=_GUICtrlListView_GetSelectedIndices($hListView,True)
    If @error Then Return ""
    WinActivate(WinGetHandle("[CLASS:Shell_TrayWnd]"))

    CW("Index="&$arrSelectedItems[1])
    ;_ArrayDisplay ($arrSelectedItems)

    Local $ColumnCount=_GUICtrlListView_GetColumnCount($hListView)
    For $iColumn=0 To $ColumnCount-1
        $arrThisCol=_GUICtrlListView_GetColumn($hListView,$iColumn)
        CW("Col "&$iColumn&" = "&$arrThisCol[5])
        If $arrThisCol[5]="Image Path" Then
            CW("$iColumn="&$iColumn)
            ExitLoop
        EndIf
    Next

    $hListView=ControlGetHandle($hAutoruns,"","[CLASS:SysListView32; INSTANCE:1]")
    CW("$hListView="&$hListView)


    Local $strReturn=_GUICtrlListView_GetItemText($hListView,$arrSelectedItems[1],$iColumn)
    $arrListView=_GUICtrlListView_GetItemTextArray($hListView)
    ;_ArrayDisplay($arrListView)

    WinActivate($hAutoruns)


    If $strReturn="" Then
        CW("Failed to get the Image Path")
    Else
        CW('The Image Path is "'&$strReturn)
    EndIf

    Return $strReturn
    ;Return _GUICtrlListView_GetItemText($hListView,$arrSelectedItems[1])
EndFunc

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