마음의 안정을 찾기 위하여 - [Delphi] How get current url address on mains browsers using UIAutomation?
2401852
369
500
관리자새글쓰기
태그위치로그방명록
별일없다의 생각
dawnsea's me2day/2010
색상(RGB)코드 추출기(Color...
Connection Generator/2010
최승호PD, '4대강 거짓말 검...
Green Monkey**/2010
Syng의 생각
syng's me2DAY/2010
천재 작곡가 윤일상이 기획,...
엘븐킹's Digital Factory/2010
[Delphi] How get current url address on mains browsers using UIAutomation?
Delphi/OLE Automation | 2023/04/26 10:52
출처 : https://stackoverflow.com/questions/25437652/how-get-current-url-address-on-mains-browsers-using-uiautomation


uses

UIAutomationClient_TLB, activeX;



var

Firefox_quebrou: boolean;



function GetURL(hTargetWnd: HWND): string;

  function Enumerar(pParent: IUIAutomationElement; Scope: TreeScope; pCondition: IUIAutomationCondition): String;

  var

    found    : IUIAutomationElementArray;

    ALen     : Integer;

    i        : Integer;

    iElement : IUIAutomationElement;



    retorno: integer;

    value : WideString;

    iInter: IInterface;

    ValPattern  : IUIAutomationValuePattern;

  begin

    Result := '';

    Firefox_quebrou := false;

    if pParent = nil then

      Exit;

    pParent.FindAll(Scope, pCondition, found);

    found.Get_Length(ALen);

    for i := 1 to ALen - 1 do

    begin

      found.GetElement(i, iElement);

      iElement.Get_CurrentControlType(retorno);

      if (

          (retorno = UIA_EditControlTypeId) or

          (retorno = UIA_GroupControlTypeId)

         ) then //UIA_DocumentControlTypeId

      begin

        iElement.GetCurrentPattern(UIA_ValuePatternId, iInter);

        if Assigned(iInter) then

        begin

          if iInter.QueryInterface(IID_IUIAutomationValuePattern, ValPattern) = S_OK then

          begin

            ValPattern.Get_CurrentValue(value);

            Result := trim(value);

            Firefox_quebrou := true;

            Break;

          end;

        end;

      end;

      if not Firefox_quebrou then

      begin

        Result := Enumerar(iElement, Scope, pCondition);

      end;

    end;



  end;

var

  UIAuto      : IUIAutomation;

  Ret         : Integer;

  RootElement : IUIAutomationElement;

  Scope       : TreeScope;

  varProp     : OleVariant;

  pCondition  : IUIAutomationCondition;

begin

  Result := '';

  try

    UIAuto := CoCUIAutomation.Create;

    if Succeeded(UIAuto.ElementFromHandle(hTargetWnd, RootElement)) then

    begin

      TVariantArg(varProp).vt    := VT_BOOL;

      TVariantArg(varProp).vbool := True;

      UIAuto.CreatePropertyCondition(UIA_IsControlElementPropertyId,

                                     varProp,

                                     pCondition);

      Scope := TreeScope_Element or TreeScope_Children;

      Result := Enumerar(RootElement, Scope, pCondition);

    end;

  except

    Result := '';

  end;

end;





2023/04/26 10:52 2023/04/26 10:52
Article tag list Go to top
View Comment 0
Trackback URL :: 이 글에는 트랙백을 보낼 수 없습니다
 
 
 
 
: [1] ... [16][17][18][19][20][21][22][23][24] ... [1323] :
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
전체 (1323)
출판 준비 (0)
My-Pro... (41)
사는 ... (933)
블로그... (22)
My Lib... (32)
게임 ... (23)
개발관... (3)
Smart ... (1)
Delphi (93)
C Builder (0)
Object... (0)
VC, MF... (10)
Window... (1)
Open API (3)
Visual... (0)
Java, JSP (2)
ASP.NET (0)
PHP (6)
Database (12)
리눅스 (29)
Windows (25)
Device... (1)
Embedded (1)
게임 ... (0)
Web Se... (2)
Web, S... (21)
잡다한... (7)
프로젝트 (0)
Personal (0)
대통령... (13)
Link (2)