bjzq888 Posted November 5, 2018 Share Posted November 5, 2018 I have a script that I'd like to use to click on a subitem in a ListView. So far I have this: _GUICtrlListView_ClickItem($chnd,0,"left",False,1) ...which happily clicks on the entire Item, highlighting the row, which has 3 subitems: In this case I would like to click on the middle one of the three. I can use _GUICtrlListView_SetItem as such: _GUICtrlListView_SetItem($chnd, 500,0,1) ...which sends 500 to the top row, subitem 1, which is the middle box. But ClickItem doesn't appear to allow me to select a subitem. Is there a way around this? This is an engine control application, not a game, btw. Thank you as always for any help that you might have. Link to comment Share on other sites More sharing options...
bjzq888 Posted November 5, 2018 Author Share Posted November 5, 2018 I have a script that I'd like to use to click on a subitem in a ListView. So far I have this: _GUICtrlListView_ClickItem($chnd,0,"left",False,1) ...which happily clicks on the entire Item, highlighting the row, which has 3 subitems: In this case I would like to click on the middle one of the three. I can use _GUICtrlListView_SetItem as such: _GUICtrlListView_SetItem($chnd, 500,0,1) ...which sends 500 to the top row, subitem 1, which is the middle box. But ClickItem doesn't appear to allow me to select a subitem. Is there a way around this? This is an engine control application, not a game, btw. Thank you as always for any help that you might have. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 5, 2018 Moderators Share Posted November 5, 2018 Merged duplicate "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Zedna Posted November 6, 2018 Share Posted November 6, 2018 (edited) In AutoIt is implemented only click on (whole) Item not subitem as you can see in sources of related UDFs: expandcollapse popup; GUIListView.au3 Func _GUICtrlListView_ClickItem($hWnd, $iIndex, $sButton = "left", $bMove = False, $iClicks = 1, $iSpeed = 1) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) _GUICtrlListView_EnsureVisible($hWnd, $iIndex, False) Local $tRECT = _GUICtrlListView_GetItemRectEx($hWnd, $iIndex, $LVIR_LABEL) Local $tPoint = _WinAPI_PointFromRect($tRECT, True) $tPoint = _WinAPI_ClientToScreen($hWnd, $tPoint) Local $iX, $iY _WinAPI_GetXYFromPoint($tPoint, $iX, $iY) Local $iMode = Opt("MouseCoordMode", 1) If Not $bMove Then Local $aPos = MouseGetPos() _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 Opt("MouseCoordMode", $iMode) EndFunc ;==>_GUICtrlListView_ClickItem Func _GUICtrlListView_GetItemRect($hWnd, $iIndex, $iPart = 3) Local $tRECT = _GUICtrlListView_GetItemRectEx($hWnd, $iIndex, $iPart) Local $aRect[4] $aRect[0] = DllStructGetData($tRECT, "Left") $aRect[1] = DllStructGetData($tRECT, "Top") $aRect[2] = DllStructGetData($tRECT, "Right") $aRect[3] = DllStructGetData($tRECT, "Bottom") Return $aRect EndFunc ;==>_GUICtrlListView_GetItemRect Func _GUICtrlListView_GetItemRectEx($hWnd, $iIndex, $iPart = 3) Local $tRECT = DllStructCreate($tagRECT) DllStructSetData($tRECT, "Left", $iPart) If IsHWnd($hWnd) Then If _WinAPI_InProcess($hWnd, $__g_hLVLastWnd) Then _SendMessage($hWnd, $LVM_GETITEMRECT, $iIndex, $tRECT, 0, "wparam", "struct*") Else Local $iRect = DllStructGetSize($tRECT) Local $tMemMap Local $pMemory = _MemInit($hWnd, $iRect, $tMemMap) _MemWrite($tMemMap, $tRECT, $pMemory, $iRect) _SendMessage($hWnd, $LVM_GETITEMRECT, $iIndex, $pMemory, 0, "wparam", "ptr") _MemRead($tMemMap, $pMemory, $tRECT, $iRect) _MemFree($tMemMap) EndIf Else GUICtrlSendMsg($hWnd, $LVM_GETITEMRECT, $iIndex, DllStructGetPtr($tRECT)) EndIf Return $tRECT EndFunc ;==>_GUICtrlListView_GetItemRectEx LVM_GETITEMRECT https://msdn.microsoft.com/en-us/windows/desktop/bb761049 But in Win32 API for ListView control there is also possibility to get subitem's rectangle so you can quite simply accomodate current UDFs to achieve subitem clicking so you have to create new function _GUICtrlListView_ClickSubItem() as accomodated copy of _GUICtrlListView_ClickItem() using existing UDF _GUICtrlListView_GetSubItemRect() ... LVM_GETSUBITEMRECT https://msdn.microsoft.com/en-us/windows/desktop/bb761075 ; GUIListView.au3 Func _GUICtrlListView_GetSubItemRect($hWnd, $iIndex, $iSubItem, $iPart = 0) Local $aPart[2] = [$LVIR_BOUNDS, $LVIR_ICON] Local $tRECT = DllStructCreate($tagRECT) DllStructSetData($tRECT, "Top", $iSubItem) DllStructSetData($tRECT, "Left", $aPart[$iPart]) If IsHWnd($hWnd) Then If _WinAPI_InProcess($hWnd, $__g_hLVLastWnd) Then _SendMessage($hWnd, $LVM_GETSUBITEMRECT, $iIndex, $tRECT, 0, "wparam", "struct*") Else Local $iRect = DllStructGetSize($tRECT) Local $tMemMap Local $pMemory = _MemInit($hWnd, $iRect, $tMemMap) _MemWrite($tMemMap, $tRECT, $pMemory, $iRect) _SendMessage($hWnd, $LVM_GETSUBITEMRECT, $iIndex, $pMemory, 0, "wparam", "ptr") _MemRead($tMemMap, $pMemory, $tRECT, $iRect) _MemFree($tMemMap) EndIf Else GUICtrlSendMsg($hWnd, $LVM_GETSUBITEMRECT, $iIndex, DllStructGetPtr($tRECT)) EndIf Local $aRect[4] $aRect[0] = DllStructGetData($tRECT, "Left") $aRect[1] = DllStructGetData($tRECT, "Top") $aRect[2] = DllStructGetData($tRECT, "Right") $aRect[3] = DllStructGetData($tRECT, "Bottom") Return $aRect EndFunc ;==>_GUICtrlListView_GetSubItemRect EDIT: You also have to handle possible horizontal scrolling to get desired column visible if it's not visible due to other columns before that one. Edited November 6, 2018 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now