Sign in to follow this  
Followers 0
KVasya

Problems with selecting in CtrlListView

5 posts in this topic

#1 ·  Posted (edited)

Hello.

Have question.

Why

#Include <GuiListView.au3>

    For $i=1 To $iIterationNumber
        $RightTopFrameHandle = ControlGetHandle("Код Безопасности: Инвентаризация", "", 57045)
        $iIndex = _GUICtrlListView_FindText($RightTopFrameHandle, "rule" & $i)
        _GUICtrlListView_SetItemSelected($RightTopFrameHandle, $iIndex)
    ;_GUICtrlListView_SetItemState($RightTopFrameHandle, $iIndex,$LVIS_SELECTED, $LVIS_SELECTED)
    Next

    Send("{DELETE}")
    Send("{ENTER}")

has different result with

#Include <GuiListView.au3>

    For $i=1 To $iIterationNumber
        $RightTopFrameHandle = ControlGetHandle("Код Безопасности: Инвентаризация", "", 57045)
        $iIndex = _GUICtrlListView_FindText($RightTopFrameHandle, "rule" & $i)
        ;_GUICtrlListView_SetItemSelected($RightTopFrameHandle, $iIndex)
    _GUICtrlListView_SetItemState($RightTopFrameHandle, $iIndex,$LVIS_SELECTED, $LVIS_SELECTED)
    Next

    Send("{DELETE}")
    Send("{ENTER}")
Edited by KVasya

Share this post


Link to post
Share on other sites



In first case all rules were deleted, but in second case only one...

Share this post


Link to post
Share on other sites

Russian! Yay!

R u sure that the two functions _GUICtrlListView_SetItemState() and the other one perform the same task/functions? I would guess they call different WINAPI functions.


ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

Share this post


Link to post
Share on other sites

Well, _GUICtrlListView_SetItemSelected returns:

_SendMessage($hWnd, $LVM_SETITEMSTATE, $iIndex, $pMemory)

when _GUICtrlListView_SetItemState returns:

_SendMessage($hWnd, $LVM_SETITEMA, 0, $pMemory, 0, "wparam", "ptr")

I just started to learn the programming and sometimes behavior of my code is absolutely unpredictable for me.

Second function seems much more universal, but I can't pick up keys for it.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

by keys you mean params?

you can use this script (script requires "dssubcls.dll" file which you can download from here - once you get params you can use them for _SendMessage() function):

p.s. script is example for hooking messages from winamp - for example:

wParam = 40046 and lParam = 0 is PAUSE in winamp,

and when you use:

_SendMessage(WinGetHandle("[CLASS:Winamp v1.x]"), $WM_COMMAND, 40046, 0)
it will send PAUSE to the script - I'm guessing you can do the same for delete/enter in your window, just get the right params, also change $CLASS to match window you want to hook)

#include <WindowsConstants.au3>
#include <GuiListbox.au3>
Global $hList, $last_msg
_Main()
Exit
Func _Main()
    If NOT FileExists('dssubcls.dll') then
        If MsgBox(3+32, 'Error', 'You don''t have "dssubcls.dll" file, please download from:' & @CRLF & _
                            'http://allapi.mentalis.org/vbexamples/vbexample.php?vbexample=DSSUBCLS' & @CRLF & _
                            'would you like me to go there?') = 6 Then ShellExecute('http://allapi.mentalis.org/php/redirect/redirect.php?action=download&id=374')
        Exit
    EndIf
    Local $hGUI = GUICreate("Subclass", 400, 400)
    Local $cList = GUICtrlCreateList("", 8, 8, 384, 384, BitOR($WS_BORDER, $WS_VSCROLL))
    GUISetState()
    $hList = GUICtrlGetHandle($cList)
    Local $hDSSUBCLS = DllOpen("dssubcls.dll")
    Local $CLASS = "[CLASS:Winamp v1.x]"
    Local $hNotepad = WinGetHandle($CLASS)
    Local $hCallback = DllCallbackRegister("_MyCallback", "long", "long;long;long")
    Local $aRet = DllCall($hDSSUBCLS, "long", "SubClass", "hwnd", $hNotepad, "ptr", DllCallbackGetPtr($hCallback), "long", 0, "long", 0, "long", 0, "long", 1)
    $aRet = DllCall($hDSSUBCLS, "long", "UseSendMessage", "long", 0)
    While GUIGetMsg() <> -3
        Sleep(10)
    WEnd
    DllCallbackFree($hCallback)
    DllClose($hDSSUBCLS)
    GUIDelete()
EndFunc   ;==>_Main
Func _MyCallback($uiMsg, $wParam, $lParam)
    Switch $uiMsg
        Case $WM_COMMAND
            If $lParam = 0 Then ;main commands in winamp uses 0 lParam (like many other applications)
                _GUICtrlListBox_AddString($hList, "WM_COMMAND(" & $wParam & "," & $lParam & ")")
            EndIf
    EndSwitch
    Return 0
EndFunc   ;==>_MyCallback
Edited by dragan

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