열려있는 IE 다루기

Controling Existing IE

IEGet( name="" )
{
   ;IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame ; Get active window if no parameter
   ;Name := ( Name="New Tab - Windows Internet Explorer" ) ? "about:Tabs" : RegExReplace( Name, " - (Windows|Microsoft) Internet Explorer" )
   For pwb in ComObjCreate( "Shell.Application" ).Windows
	{
      ;If ( pwb.LocationName = Name ) && InStr( pwb.FullName, "iexplore.exe" )
	  If InStr( pwb.FullName, "iexplore.exe" )
         Return pwb
	}
}



pwb := IEGet()
;pwb.Visible := True ; Make the IE object visible
Sleep, 2000
test:=pwb.LocationName ;ok
test:=pwb.document.getElementById("u_skip").innerText ; ok
test:=pwb.document.getElementById("sform").innerText ; ok
test:=pwb.document.getElementsByName("pkid")[0].type ;ok
test:=pwb.document.getElementsByName("query")[0].type ;ok
test:=pwb.document.getElementsByName("query")[0].title
pwb.document.getElementsByName("query")[0].innerText="test" ; no


pwb.document.getElementById("query").innerText="best" ;no

;x:=pwb.document.getElementById("query") ;ok
;x.innerText:="great"
MsgBox,% x.innerText


e:=pwb.document.getElementsByTagName("input")
loop,% e.length {
  i:=A_Index-1
  x:=e[i]	
  if (x.id="query") {
	MsgBox,% x.id
	x.innerText:="test"
	break
}
}


MsgBox, %test%

ExitApp
ESC::ExitApp

IEGet함수

원래 받았던 함수[1]에서 일부를 지웠더니 된다.

단, IEGet함수에 입력인수가 없으니, 처음 만나는 IE를 되돌려 줄 것이다.

 

요소 속성에 값 넣기

"pwb.document.getElementById("query").innerText="best"" 이렇게 한 번에 넣으니 안되고

(그 아래에 comment out된 2줄 처럼) 두 줄에 나누어 넣었더니 된다.

 

[1] https://autohotkey.com/board/topic/66099-access-an-existing-ie-object/

'[PA] 업무자동화 > [AH]Autohotkey' 카테고리의 다른 글

AH 이미지 크기 알아내기  (0) 2020.06.21
AH 윈도우 요소, HTML 요소 알아내기  (0) 2020.06.21
AH HTML 다루기 2  (0) 2020.06.05
AH Scite에서 한글 깨짐  (0) 2020.06.05
AH 도움말,한글판  (0) 2020.06.05
Posted by Weneedu
,


출처: https://privatedevelopnote.tistory.com/81 [개인노트]