Jump to content

How to send a click to a SysListView32 Control


Recommended Posts

That was a typo, but it didn't error ... go figure ...

This is the corrected code... which selects the correct item, but no double clicky :P

ControlClick("","",_GuiCtrlListView_SetItemSelected($list, _GUICtrlListView_FindInText($list, $results[$row][1])), "left", 2)

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Link to comment
Share on other sites

That was a typo, but it didn't error ... go figure ...

This is the corrected code... which selects the correct item, but no double clicky :P

ControlClick("","",_GuiCtrlListView_SetItemSelected($list, _GUICtrlListView_FindInText($list, $results[$row][1])), "left", 2)

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I've also discovered that _GuiCtrlListView_SetItemSelected() highlights the listview item, but doesn't actually select it, as if it has been clicked.

You think this should be a bug report ?

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Link to comment
Share on other sites

Your all lost because of 1 function not ported, got news for you it was more complicated than a single function, this is a quick and dirty of the function

; #FUNCTION# ===================================================================================================================
; Name...........: _GUICtrlListView_ClickItem
; Description ...: Clicks an item
; Syntax.........: _GUICtrlListView_ClickItem($hWnd, $iIndex[, $sButton = "left"[, $fMove = False[, $iClicks = 1[, $iSpeed = 1]]]])
; Parameters ....: $hWnd        - Handle to the control
;                  $iIndex      - Zero based index of the item
;                  $sButton     - Button to click
;                  $fMove       - If True, the mouse will be moved. If False, the mouse does not move.
;                  $iClicks     - Number of clicks
;                  $iSpeed      - Delay between clicks
; Return values .:
; Author ........: Paul Campbell (PaulIA)
; Modified.......: Gary Frost
; Remarks .......:
; Related .......:
; Example .......; Yes
; ===============================================================================================================================
Func _GUICtrlListView_ClickItem($hWnd, $iIndex, $sButton = "left", $fMove = False, $iClicks = 1, $iSpeed = 1)
    If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd)
    If not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
    Local $aPos, $tRect, $iX, $iY, $tPoint, $iMode

    _GUICtrlListView_EnsureVisible($hWnd, $iIndex, False)
    $tRect = _GUICtrlListView_GetItemRectEx($hWnd, $iIndex)
    $tPoint = _WinAPI_PointFromRect($tRect, True)
    $tPoint = _WinAPI_ClientToScreen($hWnd, $tPoint)
    _WinAPI_GetXYFromPoint($tPoint, $iX, $iY)
    If Not $fMove Then
        $iMode = Opt("MouseCoordMode", 1)
        $aPos = MouseGetPos()
        Opt("MouseCoordMode", $iMode)
        _WinAPI_ShowCursor(False)
        MouseClick($sButton, $iX, $iY, $iClicks, $iSpeed)
        MouseMove($aPos[0], $aPos[1], 0)
        _WinAPI_ShowCursor(True)
    Else
        MouseClick($sButton, $iX, $iY, $iClicks, $iSpeed)
    EndIf
EndFunc   ;==>_GUICtrlListView_ClickItem


; #FUNCTION# ====================================================================================================================
; Description ...: Returns the top/left coordinates of a tagRECT as a tagPOINT structure
; Parameters ....: $tRect       - tagRECT structure
;                  $fCenter     - If True, the return will be a point at the center of  the  rectangle,  otherwise  the  left/top
;                  +coordinates are returned.
; Return values .: Success      - tagPOINT structure
; Author ........: Paul Campbell (PaulIA)
; Remarks .......: This function is used to get the click position for many of the click functions in the library
; Related .......:
; ===============================================================================================================================
Func _WinAPI_PointFromRect(ByRef $tRect, $fCenter = True)
    Local $iX1, $iY1, $iX2, $iY2, $tPoint

    $iX1 = DllStructGetData($tRect, "Left")
    $iY1 = DllStructGetData($tRect, "Top")
    $iX2 = DllStructGetData($tRect, "Right")
    $iY2 = DllStructGetData($tRect, "Bottom")
    If $fCenter Then
        $iX1 = $iX1 + (($iX2 - $iX1) / 2)
        $iY1 = $iY1 + (($iY2 - $iY1) / 2)
    EndIf
    $tPoint = DllStructCreate($tagPOINT)
    DllStructSetData($tPoint, "X", $iX1)
    DllStructSetData($tPoint, "Y", $iY1)
    Return $tPoint
EndFunc   ;==>_WinAPI_PointFromRect

; #FUNCTION# ====================================================================================================================
; Description ...: Returns the X/Y values from a tagPOINT structure
; Parameters ....: $tPoint      - tagPOINT structure
;                  $iX          - X value
;                  $iY          - Y value
; Return values .:
; Author ........: Paul Campbell (PaulIA)
; Remarks .......: This function extracts the X/Y values from a tagPOINT structure
; Related .......: _Lib_GetPointFromXY, _Lib_GetXYFromRect
; ===============================================================================================================================
Func _WinAPI_GetXYFromPoint(ByRef $tPoint, ByRef $iX, ByRef $iY)
    $iX = DllStructGetData($tPoint, "X")
    $iY = DllStructGetData($tPoint, "Y")
EndFunc   ;==>_WinAPI_GetXYFromPoint

:P Gotta do everything.... ;)

Edit: Figured out how to have the mouse move or not, with-out adding in all the spaghetti code Paul had to do the same, now It might be worth adding in.

Edited by GaryFrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

It dosen't work with _GuiCtrlListView_SetItemSelected() , only the item is selected not like in library from Paul1A

May be ithis function has to be supported in udf but actually not .

Yes, I agree that it doesn't work like the UDF from A3Lib. AutoIt's _GuiCtrlListView_SetItemSelected() only 'select' the item. Whereas A3Lib's _ListView_ClickItem actually performs a mouse click on the ListView item. And in my case, I actually send a right click for a popup menu to appear and select one of the option like this:

_ListView_ClickItem($hList, $Index,"Right",0,1,1,True)

_Menu_ClickPopup(1)

Update: I see that Gary has provide a solution with the _GUICtrlListView_ClickItem function. Thanks a bunch!

Is there a solution to select an option in the popup menu when I send a right click? As seen in my above example, I was able to use A3Lib's _Menu_ClickPopup function.

Edited by RS200Z
Link to comment
Share on other sites

Yes, I agree that it doesn't work like the UDF from A3Lib. AutoIt's _GuiCtrlListView_SetItemSelected() only 'select' the item. Whereas A3Lib's _ListView_ClickItem actually performs a mouse click on the ListView item. And in my case, I actually send a right click for a popup menu to appear and select one of the option like this:

_ListView_ClickItem($hList, $Index,"Right",0,1,1,True)

_Menu_ClickPopup(1)

Did you bother to look at the post before your last one?

Just to clarify, I ported code from the libraries, I didn't port all the code. If I didn't like it, it didn't make it in. Some code that was already in the UDFs was tossed and I wrote all new code also.

Edited by GaryFrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • 2 weeks later...

Yes, I agree that it doesn't work like the UDF from A3Lib. AutoIt's _GuiCtrlListView_SetItemSelected() only 'select' the item. Whereas A3Lib's _ListView_ClickItem actually performs a mouse click on the ListView item. And in my case, I actually send a right click for a popup menu to appear and select one of the option like this:

_ListView_ClickItem($hList, $Index,"Right",0,1,1,True)

_Menu_ClickPopup(1)

Update: I see that Gary has provide a solution with the _GUICtrlListView_ClickItem function. Thanks a bunch!

Is there a solution to select an option in the popup menu when I send a right click? As seen in my above example, I was able to use A3Lib's _Menu_ClickPopup function.

Hi,

I wrote a script to click an external program's context menu in the same way as yours, it is work well in foreground, but when running in background as a schedule, it just holding in _Lib_PopupWait() function, it seemed that could not capture the popup menu in background, any advice? Thanks.

Link to comment
Share on other sites

  • 1 month later...

The way I do is by sending the {DOWN} key N times via SEND function.

And, I forgot to add, you can find directly the letter corrispondent to that item given that usually all Items of a popup menu they have a bindkey associated with them (for example right click on a taskmanager process followd by SEND("t") would kill it with its process tree.
Link to comment
Share on other sites

  • 5 months later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...