Skip to content
AutoHotKey
2011.02.21 23:55

COM 사용

조회 수 19065 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

ahk_l COM  사용



com_CreateObject 는 새롭게 만드는 것이고,

그후에 com_invoke로 세부 명령을 주는 방식으로 사용되는데...


현재 띄워져 있는 익스플로러의 InternetExplorer.Application 을 invoke 해서 
document의 body를 만진다... 라고 할때

InternetExplorer.Application의정보는


http://www.autohotkey.com/forum/topic34972.html 




;네이버가 타이틀에 포함된 익스플로러 창이 존재하면, google 창으로 이동시킵니다. 

COM_Init() 
pageSearched:="네이버" 
Loop, % COM_Invoke(psw := COM_Invoke(psh:=COM_CreateObject("Shell.Application"), "Windows"), "Count") 

LocationName:=COM_Invoke(pwb:=COM_Invoke(psw, "Item", A_Index-1), "LocationName") 
IfInString,LocationName,%pageSearched% 

url:="http://www.google.com" 
COM_Invoke(pwb, "Navigate", url) 
Break 


COM_Release(pwb) ;didnt break so release the one we didnt use 


return




#include, com.ahk 
COM_Init() 
pageSearched:="네이버" 
psh:=COM_CreateObject("Shell.Application") 
psw:=COM_Invoke(psh, "Windows") 
LCt:=COM_Invoke(psw, "Count")                                        ;Shell.Windows.Count (LoopCount) 
  Loop, % lct 
  { 
  pwb:=COM_Invoke(psw, "Item", A_Index-1)                    ;Shell.Windows.Item 
;pwb:=Shell.Windows.Item 의 값이 0이면(Shell.Windows.Item가 아니면) Continue(LocationName 에서 에러발생) 
      if pwb=0 
      Continue 
  LocationName:=COM_Invoke(pwb, "LocationName")          ;창이름을 갖는 변수 (InternetExplorer Object) 
      IfInString,LocationName,%pageSearched% 
      { 
      url:="http://www.google.com" 
      COM_Invoke(pwb, "Navigate", url) 
      Break 
      } 
  COM_Release(pwb) 
  } 

약간의 주석과 초보자가 보기쉽게 수정해봤어요.. 주석이 맞으려나 모르겠네요; 
;pwb:=Shell.Windows.Item 의 값이 0이면(Shell.Windows.Item가 아니면) Continue(LocationName 에서 에러발생) 
      if pwb=0 
      Continue 
이부분은 써놓고도 뭔지 모르겠어요;





    Basic understanding of COM Pointer 
    Understanding of COM_CreateObject MSDN 
      MSDN does a fine job explaining this i wont re hash it just remember creates a parent object for use with our invoke calls

    Understanding of COM_AtlAxGetControl MSDN 
    Understanding of COM_AtlAxCreateContainer MSDN 
      we will be using COM_AtlAxCreateContainer and COM_AtlAxGetControl in our examples just remember this is a way of getting a control pointer from a window control that we are in our case creating

    Understanding of COM_Invoke MSDN 
      Sean gives us a Basic Example. Basically this is an execution function. if you need to get or set a value execute a method of move from a parent object to a member object you can do so from COM_Invoke

    Understanding of COM_Release MSDN 
      In the interest of trying to dumb this down here goes. 
      everytime you create a pointer to an object or interface you should release it for each time you create it you do not release strings just object and interface pointers. Its a way of freeing memory and its good for your program but well if you dont do it the worst that can happen on most beginner scripts is some semi slow performance

    Understanding of COM_QueryService MSDN 
      In our examples we will use this function to get one object pointer from another using CLSID. there are instances when getting pwin can bypass some security zone settings which can cause scripts to fail at times

    Understanding of COM_QueryInterface MSDN 
      Returns a pointer to a specified interface on an object to which a client currently holds an interface pointer.

    Understanding of COM_ConnectObject MSDN 
      Just remember this is how we can setup ahk access to events. Gonna be a much later before I cover events but be patient


It is also imperitive that we have an understanding of the following 

    Basic Understanding of IE architecture MSDN 
    Basic understanding of the webrowser object for Gui MSDN [url=http://msdn.microsoft.com/en-us/library/aa741312(VS.85).aspx]MSDN[/url]


For our automation tasks we will be aquireing and interface pointer to iWebrowser2 through out my examples you will see this reflected as pwb 
    First I want to remind all please have COM in the standard libraries such as c:\program files\autohotkey\lib 

    Always initialize COM once per script 
    If you will not be using a GUI object





로그인 후 댓글쓰기가 가능합니다.

?

List of Articles
번호 분류 제목 날짜 조회 수
837 컴퓨터잡담 [JavaScript] 자바스크립트 함수 총정리!! 3 2010.03.27 12514
836 컴퓨터잡담 ajax의 XMLHttpRequest 객체 1 2010.03.27 7463
835 컴퓨터잡담 Prototype.js를 제대로 사용하는 방법 2010.03.27 10299
834 컴퓨터잡담 50 개 이상의 Ajax 예제들 2 2010.03.29 18950
833 컴퓨터잡담 50 개 이상의 Ajax 예제들 2010.03.29 18179
832 컴퓨터잡담 php에서 script로 변수 전달 후 html에 div로 내용 출력하기 1 3 2010.04.01 15903
831 컴퓨터잡담 부팅시 에러 메시지 PRESS F1 to REsume 2 2010.04.03 16106
830 컴퓨터잡담 로그인 아이디 쿠키로 기억하기 2010.04.05 10966
829 컴퓨터잡담 MySQL을 위한 하드웨어 최적화(What one can and should optimize) 2 2010.04.06 13123
828 컴퓨터잡담 MYSQL my.cnf 최적화 15 2010.04.07 22600
827 컴퓨터잡담 삼성, 프로그래머들에게 스마트폰 콘텐츠 개발하고 싶게 만들어라. 2 2010.04.09 10989
826 컴퓨터잡담 쓸데없는 시작 프로그램을 없애자 2010.04.10 6107
825 컴퓨터잡담 MYSQL Qcache 값 조정~~~ 1 2010.04.13 19554
824 컴퓨터잡담 mysql threads_created 뭐냥? 4 2010.04.13 12244
823 컴퓨터잡담 svchost.exe 프로세스로 내컴퓨터 최적화 시키기 2010.04.14 7366
822 컴퓨터잡담 MySQL 조율(튜닝)에 대해 2 2010.04.14 15827
821 컴퓨터잡담 MySQL FEDERATED / InnoDB is disabled, myint64.dll 오류 어찌하오리 4 2010.04.19 27707
820 컴퓨터잡담 서버에 SSD 교체 작업을 해야되나? 2010.04.20 6522
819 컴퓨터잡담 DB MyISAM, InnoDB 입출력 처리방식 3 2010.04.20 13812
818 컴퓨터잡담 블로그/사이트의 키워드 훔쳐보기^^;; 2010.04.21 9207
Board Pagination Prev 1 ... 3 4 5 6 7 ... 46 Next
/ 46

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소