Jump to content
Sign in to follow this  
FordsFinest

_GUICtrlTreeView_ClickItem issues

Recommended Posts

I have a macro that works well on 95% of computers. However, I am running into an issue on a couple computers where the _GUICtrlTreeView_ClickItem clicks the wrong item (an item or two below the correct one). Both the ExpandItem and SelectItem command work fine, just the click item is off on these computers (and only their user names). I'm not sure if some temp file somewhere is causing an issue or what. Note, using ONLY selectitem results in inconsistent focusing (item appears focused but the next command won't always work correctly). Hence my need to use the clickitem command.

Any help would be appreciated.

_GUICtrlTreeView_Expand($hWnd, $Array2[$i]) ;Expand $model
    Sleep(250)
    _GUICtrlTreeView_SelectItem($hWnd, $Array2[$i]) ;Select $model
    Sleep(150)
    _GUICtrlTreeView_ClickItem($hWnd, $Array2[$i]) ;Click $model
    Sleep(150)
    EndIf

 

Edited by FordsFinest

Share this post


Link to post
Share on other sites

Are you serious ?  May be giving us a runable script that express the problem would be appropriate.  Not 3 lines of codes with an EndIf taken from nowhere !

Share this post


Link to post
Share on other sites

FordFinest, We have some issues with a few of the commands in the GuiTreeView UDF under Windows 10 64 bit. I had temporarily forgotten that in your previous post about the same subject a month ago. Sorry.

The problem is obvious if you try the example of _GUICtrlTreeView_ClickItem in the help file under Windows 10 64 bit. The _GUICtrlTreeView_ClickItem command (here a double click) simply does not work.

Make a copy of the example. Add the two functions here to the code and replace _GUICtrlTreeView_ClickItem with _GUICtrlTreeView_ClickItem64.

Func _GUICtrlTreeView_ClickItem64($hWnd, $hItem, $sButton = "left", $bMove = False, $iClicks = 1, $iSpeed = 0)
  If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

  Local $tRECT = _GUICtrlTreeView_DisplayRectEx64($hWnd, $hItem, True)
  If @error Then Return SetError(@error, @error, 0)
  ; Always click on the left-most portion of the control, not the center.  A
  ; very wide control may be off-screen which means clicking on it's center
  ; will click outside the window.
  Local $tPoint = _WinAPI_PointFromRect($tRECT, False)
  _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)
  Return 1
EndFunc   ;==>_GUICtrlTreeView_ClickItem

Func _GUICtrlTreeView_DisplayRectEx64($hWnd, $hItem, $bTextOnly = False)
  Local $tRECT = DllStructCreate($tagRECT)
  Local $iRet
  If IsHWnd($hWnd) Then
    ; RECT is expected to point to the item in its first member.
    ;DllStructSetData($tRECT, "Left", $hItem)
    $iRet = @AutoItX64 ? DllStructSetData( DllStructCreate( "ptr", DllStructGetPtr( $tRect ) ), 1, $hItem ) _
                       : DllStructSetData( $tRect, "Left", $hItem )
    If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then
      $iRet = _SendMessage($hWnd, $TVM_GETITEMRECT, $bTextOnly, $tRECT, 0, "wparam", "struct*")
    Else
      Local $iRect = DllStructGetSize($tRECT)
      Local $tMemMap
      Local $pMemory = _MemInit($hWnd, $iRect, $tMemMap)
      _MemWrite($tMemMap, $tRECT)
      $iRet = _SendMessage($hWnd, $TVM_GETITEMRECT, $bTextOnly, $pMemory, 0, "wparam", "ptr")
      _MemRead($tMemMap, $pMemory, $tRECT, $iRect)
      _MemFree($tMemMap)
    EndIf
  Else
    If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
    ; RECT is expected to point to the item in its first member.
    DllStructSetData($tRECT, "Left", $hItem)
    $iRet = GUICtrlSendMsg($hWnd, $TVM_GETITEMRECT, $bTextOnly, DllStructGetPtr($tRECT))
  EndIf

  ; On failure ensure Left is set to 0 and not the item handle.
  If Not $iRet Then DllStructSetData($tRECT, "Left", 0)
  Return SetError($iRet = 0, $iRet, $tRECT)
EndFunc   ;==>_GUICtrlTreeView_DisplayRectEx

You haven't shown much code, but I think the two functions will solve your problem. If the code doesn't help then add a new post. The problem can certainly be solved.

For one reason or another, Microsoft has stopped supporting the focused state of a treeview item. However, the dotted focus rectangle is still displayed. This is not an AutoIt problem.

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.

  • Similar Content

    • By MiKa666
      Hi all,
      I'm developing a tool for exploratively testing another software. For that I wanna cover all the GUI functionality from that software and verify everything works as intended. But now I've a problem which I couldnt solve so far.
      One thing that software I'm testing does, is to load up either a single picture or a series of pictures. Depending on how much pictures got loaded, further actions will be proceeded...
      This loaded pictures are schon within a ToolbarWindow and they're clickable. What I need to know is, how much pictures are in this ToolbarWindow...
      Can anybody provide me a tip on how to achive this?
      Would be amazing!!
      BR,
      Mic
    • By meety
      Hello!
      wingettext function can get the text content of the IE browser page, but the text content of the page cannot be obtained in the chrome browser? What should I do?
    • By DirtyJohny
      Hi everyone.Need rewrite this function how in еxample.
      Original:
      #RequireAdmin #NoTrayIcon Opt("MustDeclareVars",1) Func _a() Local $sls=ObjGet("winmgmts:{impersonationLevel=impersonate," _ &"authenticationLevel=Pkt}!\\"& _ @ComputerName&'\root\wmi'),$lss=$sls.ExecQuery _ ('SELECT * FROM WmiMonitorID'), _ $lll,$sll,$sss="",$lsl,$lls,$i,$z For $z In $lss $lsl=$z.UserFriendlyName For $i=0 To Ubound($lsl)-1 if ($lsl[$i]) Then $lll&=Chr($lsl[$i]) Next $lls=$z.SerialNumberID For $i=0 To Ubound($lls)-1 if ($lls[$i]) Then $sll&=Chr($lls[$i]) Next $sss&="Model"&@TAB&@TAB&": "&$lll&@CR&"Serial Number"&@TAB&": "&$sll&@CR&@CR $lll="" $sll="" Next MsgBox(262144,'Monitors '&$lss.Count,$sss&" "&@CR) $lss=Null $sls=Null EndFunc _a() Example:
      Func _InfoPC() Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2') Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30) If IsObj($ObjService) Then For $objItemMB In $ObjMB $sInfo &= @TAB & 'Motherboard: ...... ' & $objItemMB.Product & @CRLF I'm beginner in this sphere and need  you all speak easy and simply because i'm Russian.Thanks)
    • By Deshanur
      Am trying to automate injecting credential on the login form for all kind of Web application for IE. I know how to identify the form name by viewing the source code and using the method - _IEFormGetObjByName($ie, $form_Name).
      I would like to know how to identify or get the form object for the web app where there is no form name tag for example below, for the is I have used - _IEFormGetCollection($ie, 0) to get the form object.
      My Question is does it work for all kind of application "_IEFormGetCollection($ie, 0)" how to identify Index value? is it always 0? is there any better solution?
      The final solution am looking for is find out form object, get the username, password field and inject credential and submit the form.
      How to find out index value? for the forms which does not have form name field.
      $login_form = _IEFormGetCollection($ie, 0) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}") OR This works fine if the form has form name. $login_form = _IEFormGetObjByName($ie, $form_Name) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}")
    • By JuanFelipe
      Hello guys!
      I have a problem with a script, in the past I made a program and it worked perfect, I recently used it again and it already stands still in one step, the problem is a Javascript event that changed but now I cannot execute it.
       
      <td colspan="2" align="center"><input type="button" id="Buscar" name="Buscar" value="Buscar" onclick="javascript:enviarForma(document.obtenercasosPersonaPorDocumento,'0');" class="boton"></td>  
      Previously I used this code and it worked, but now it does nothing
      $botonconsulta = _IEGetObjByName($oIE,"Buscar") _IEAction($botonconsulta, 'click') _IELoadWait($oIE)  
      Now I have tried the following codes but none works.
       
      ;==================== 1 _IEHeadInsertEventScript($oIE, "document", "onclick", "javascript:enviarForma(document.obtenercasosPersonaPorDocumento,'0');") ControlClick("SUPER CELAC", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") _IELoadWait($oIE) ;==================== 2 $forma = $oIE.document.obtenercasosPersonaPorDocumento $oIE.Navigate("JavaScript:enviarForma("&$forma&",""0"");") _IELoadWait($oIE) ;==================== 3 $boton = _IEGetObjById($oIE, "Buscar") $boton.document.parentwindow.execScript("enviarForma(document.obtenercasosPersonaPorDocumento,'0');", "javascript") I hope you can guide me, because I think the error is in the parameters that the javascript function receives but I don't know how to send it, here I leave the first part of the JavaScript function.
      function enviarForma(frm,tipoForma){ var bExisteDatoConsulta = false; var bError=true; var mensajeError=""; switch (tipoForma) { //--Forma documento case "0": if (validar_campo_no_vacio_no_print(frm.numeroDocumento)) { if (!isNum(frm.numeroDocumento.value)) { bError = false; mensajeError += "El número de documento debe ser un valor numérico\n"; } bExisteDatoConsulta = true; } else { mensajeError += "Debe digitar un número de documento\n"; } break;  Thanks!
×
×
  • Create New...