오토핫키로 크롬을 제어하는 방법을 맛보기로 간단히 살펴보겠습니다.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
global page
Gui, Add, text, section, 1.Routine-A 2.Exit app
Gui, show
Winset, AlwaysOnTop, on, sam1.ahk ;항상 위로
url := "https://www.google.com"
initChrome(url)
return
^1::
url := "https://www.naver.com"
page.get(url)
return
^2::
ExitApp
initChrome(url)
{
page := ComObjCreate("Selenium.CHROMEDriver") ;크롬 인스턴스 생성
;'Chrome이 자동화된 테스트 소프트웨어에 의해 제어되고 있습니다.' 메시지 끄기, 최초 윈도우 크기 설정
page.SetCapability("goog:chromeOptions", "{""excludeSwitches"":[""enable-automation""], ""args"":[""--window-size=800,1200""]}")
page.get(url) ;웹사이트 이동
}
GuiClose:
ExitApp