Jump to content

code to obtain the tip-url chrome like the attached image


Go to solution Solved by Danyfirex,

Recommended Posts

Hello, dear friends, I would like to ask you about the code to obtain the tip-url chrome like the attached image.

The idea is work with the actual open chrome window

 

When I hover over a section, the tooltip appears, which I left in the attached image.

 

best regards

Captura de pantalla 2024-08-03 192909.jpg

Edited by Netol
error writting
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • Solution

Hello. Here is a sample.

 

#AutoIt3Wrapper_UseX64=n
;~ #RequireAdmin
#include <WinAPISysWin.au3>
#include ".\UIASpy\Includes\UIA_Constants.au3"

HotKeySet("{ESC}", "Quit") ;Press ESC key to quit

_Test()

Func Quit()
    Exit
EndFunc   ;==>Quit

Func _Test()
    ; Create UI Automation object
    Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation)
    If Not IsObj($oUIAutomation) Then Return ConsoleWrite("$oUIAutomation ERR" & @CRLF)
    ConsoleWrite("$oUIAutomation OK" & @CRLF)

    ; Get Desktop element
    Local $pDesktop, $oDesktop
    $oUIAutomation.GetRootElement($pDesktop)
    $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement)
    If Not IsObj($oDesktop) Then Return ConsoleWrite("$oDesktop ERR" & @CRLF)
    ConsoleWrite("$oDesktop OK" & @CRLF)

    While Sleep(30)
        Local $hHandle = WinGetHandle("[ACTIVE]")
        If _WinAPI_GetClassName($hHandle) <> "Chrome_WidgetWin_1" Then ContinueLoop
        ConsoleWrite(WinGetTitle($hHandle) & @CRLF)
        Local $pCondition ; Note that $UIA_ClassNamePropertyId maybe ia a CASE SENSITIVE condition
        $oUIAutomation.CreatePropertyCondition($UIA_NativeWindowHandlePropertyId, Int($hHandle), $pCondition) ;hwnd need to be converted to int
        If Not $pCondition Then ContinueLoop
        ConsoleWrite("$pCondition OK")

        ;When searching for top-level windows on the desktop, be sure to specify TreeScope_Children in the scope parameter, not TreeScope_Descendants.
        ;A search through the entire subtree of the desktop could iterate through thousands of items and lead to a stack overflow.
        Local $pWindow
        $oDesktop.FindFirst($TreeScope_Children, $pCondition, $pWindow)
        Local $oWindow = ObjCreateInterface($pWindow, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement)
        If Not IsObj($oWindow) Then ContinueLoop
        ConsoleWrite("$oWindow OK")

        Local $pCondition0
        $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "Chrome_WidgetWin_1", $pCondition0)
        If Not $pCondition0 Then ContinueLoop
        ConsoleWrite("$pCondition0 OK" & @CRLF)

        Local $pPaneChrome, $oPaneChrome
        $oWindow.FindFirst($TreeScope_Descendants, $pCondition0, $pPaneChrome)
        $oPaneChrome = ObjCreateInterface($pPaneChrome, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement)
        If Not IsObj($oPaneChrome) Then ContinueLoop
        ConsoleWrite("$oPaneChrome OK" & @CRLF)

        Local $pCondition0
        $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_PaneControlTypeId, $pCondition0)
        If Not $pCondition0 Then ContinueLoop
        ConsoleWrite("$pCondition0 OK" & @CRLF)


        Local $pPaneFirst, $oPaneFirst
        $oPaneChrome.FindFirst($TreeScope_Children, $pCondition0, $pPaneFirst)
        $oPaneFirst = ObjCreateInterface($pPaneFirst, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement)
        If Not IsObj($oPaneFirst) Then ContinueLoop
        ConsoleWrite("$oPaneFirst OK" & @CRLF)

        Local $pCondition1
        $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_TextControlTypeId, $pCondition1)
        If Not $pCondition1 Then ContinueLoop
        ConsoleWrite("$pCondition1 OK" & @CRLF)


        Local $pText1, $oText1
        $oPaneFirst.FindFirst($TreeScope_Descendants, $pCondition1, $pText1)
        $oText1 = ObjCreateInterface($pText1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement)
        If Not IsObj($oText1) Then ContinueLoop
        ConsoleWrite("$oText1 OK" & @CRLF)
        Local $sValue = ""
        $oText1.GetCurrentPropertyValue($UIA_NamePropertyId, $sValue)
        ConsoleWrite($sValue & @CRLF)
        ToolTip($sValue,Default,Default,"Link")
    WEnd


EndFunc   ;==>_Test

 

 

Saludos

Link to comment
Share on other sites

6 hours ago, Danyfirex said:

Hello. Here is a sample.

 

#AutoIt3Wrapper_UseX64=n
;~ #RequireAdmin
#include <WinAPISysWin.au3>
#include ".\UIASpy\Includes\UIA_Constants.au3"

HotKeySet("{ESC}", "Quit") ;Press ESC key to quit

_Test()

Func Quit()
    Exit
EndFunc   ;==>Quit

Func _Test()
    ; Create UI Automation object
    Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation)
    If Not IsObj($oUIAutomation) Then Return ConsoleWrite("$oUIAutomation ERR" & @CRLF)
    ConsoleWrite("$oUIAutomation OK" & @CRLF)

    ; Get Desktop element
    Local $pDesktop, $oDesktop
    $oUIAutomation.GetRootElement($pDesktop)
    $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement)
    If Not IsObj($oDesktop) Then Return ConsoleWrite("$oDesktop ERR" & @CRLF)
    ConsoleWrite("$oDesktop OK" & @CRLF)

    While Sleep(30)
        Local $hHandle = WinGetHandle("[ACTIVE]")
        If _WinAPI_GetClassName($hHandle) <> "Chrome_WidgetWin_1" Then ContinueLoop
        ConsoleWrite(WinGetTitle($hHandle) & @CRLF)
        Local $pCondition ; Note that $UIA_ClassNamePropertyId maybe ia a CASE SENSITIVE condition
        $oUIAutomation.CreatePropertyCondition($UIA_NativeWindowHandlePropertyId, Int($hHandle), $pCondition) ;hwnd need to be converted to int
        If Not $pCondition Then ContinueLoop
        ConsoleWrite("$pCondition OK")

        ;When searching for top-level windows on the desktop, be sure to specify TreeScope_Children in the scope parameter, not TreeScope_Descendants.
        ;A search through the entire subtree of the desktop could iterate through thousands of items and lead to a stack overflow.
        Local $pWindow
        $oDesktop.FindFirst($TreeScope_Children, $pCondition, $pWindow)
        Local $oWindow = ObjCreateInterface($pWindow, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement)
        If Not IsObj($oWindow) Then ContinueLoop
        ConsoleWrite("$oWindow OK")

        Local $pCondition0
        $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "Chrome_WidgetWin_1", $pCondition0)
        If Not $pCondition0 Then ContinueLoop
        ConsoleWrite("$pCondition0 OK" & @CRLF)

        Local $pPaneChrome, $oPaneChrome
        $oWindow.FindFirst($TreeScope_Descendants, $pCondition0, $pPaneChrome)
        $oPaneChrome = ObjCreateInterface($pPaneChrome, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement)
        If Not IsObj($oPaneChrome) Then ContinueLoop
        ConsoleWrite("$oPaneChrome OK" & @CRLF)

        Local $pCondition0
        $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_PaneControlTypeId, $pCondition0)
        If Not $pCondition0 Then ContinueLoop
        ConsoleWrite("$pCondition0 OK" & @CRLF)


        Local $pPaneFirst, $oPaneFirst
        $oPaneChrome.FindFirst($TreeScope_Children, $pCondition0, $pPaneFirst)
        $oPaneFirst = ObjCreateInterface($pPaneFirst, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement)
        If Not IsObj($oPaneFirst) Then ContinueLoop
        ConsoleWrite("$oPaneFirst OK" & @CRLF)

        Local $pCondition1
        $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_TextControlTypeId, $pCondition1)
        If Not $pCondition1 Then ContinueLoop
        ConsoleWrite("$pCondition1 OK" & @CRLF)


        Local $pText1, $oText1
        $oPaneFirst.FindFirst($TreeScope_Descendants, $pCondition1, $pText1)
        $oText1 = ObjCreateInterface($pText1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement)
        If Not IsObj($oText1) Then ContinueLoop
        ConsoleWrite("$oText1 OK" & @CRLF)
        Local $sValue = ""
        $oText1.GetCurrentPropertyValue($UIA_NamePropertyId, $sValue)
        ConsoleWrite($sValue & @CRLF)
        ToolTip($sValue,Default,Default,"Link")
    WEnd


EndFunc   ;==>_Test

 

 

Saludos

Thanks a lot, this code work correctly.
Best regards

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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