메뉴 여닫기
개인 메뉴 토글
로그인하지 않음
만약 지금 편집한다면 당신의 IP 주소가 공개될 수 있습니다.

Autoit ControlSend()

데브카페

ControlSend()

  • ControlSend()는 백그라운드 컨트롤에 안정적으로 키를 보내기 위해 일부러 느리게 처리되며, Send()보다 체감 속도가 느릴 수 있습니다. 하지만 다음과 같은 방법으로 속도 개선이 가능합니다:

SendKeyDelay, SendKeyDownDelay 설정

  • AutoIt은 기본적으로 키 입력 사이에 **지연(delay)**을 둡니다. 이걸 줄이면 체감 속도가 빨라집니다.
AutoItSetOption("SendKeyDelay", 1)        ; 기본값은 5ms
AutoItSetOption("SendKeyDownDelay", 1)    ; 기본값은 1ms
  • 이 옵션은 ControlSend()에도 영향을 미칩니다.

ControlSend() 반복 대신 전체 문자열로 보내기

  • 가능하면 키를 한 글자씩 보내기보단 한 번에 전체 문자열을 보내는 것이 훨씬 빠릅니다.
ControlSend("창 타이틀", "", "[CLASS:Edit; INSTANCE:1]", "Hello World{ENTER}")

ControlSend() 대신 ControlSetText() + {ENTER} 등 조합 사용

  • 속도가 중요하고 정적인 텍스트 입력이라면 ControlSetText()로 직접 값을 설정하고, 필요한 키만 ControlSend()로 처리하면 더 빠릅니다.

ControlSetText("창 타이틀", "", "[CLASS:Edit; INSTANCE:1]", "Hello World")
ControlSend("창 타이틀", "", "[CLASS:Edit; INSTANCE:1]", "{ENTER}")
  • 이 방법은 특히 긴 텍스트를 입력할 때 매우 빠릅니다.

= WinActivate() + Send()로 처리하는 하이브리드 방식

  • 정말 빠르게 처리하고자 한다면:
WinActivate("창 타이틀")
WinWaitActive("창 타이틀", "", 2)
Send("Hello World{ENTER}")
  • 단, 이 방식은 해당 창이 포커스를 가져야 하므로 백그라운드 처리에는 부적합합니다.

  • 참고
방법 속도 백그라운드 가능 안정성
Send() 빠름 낮음 (포커스 필요)
ControlSend() 보통 보통
ControlSetText() 매우 빠름 매우 안정적 (단, 키 이벤트 아님)


예제: 속도 최적화된 ControlSend()

AutoItSetOption("SendKeyDelay", 1)
AutoItSetOption("SendKeyDownDelay", 1)

Local $title = "메모장"
Run("notepad.exe")
WinWaitActive($title)

ControlSend($title, "", "Edit1", "빠르게 입력됨!{ENTER}")


레퍼런스


ControlSend("[TITLE:Shell]", "", "x", "{F2}{2}{F2}")

ID - The internal control ID. The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls. In addition to the AutoIt Window Info Tool, other applications such as screen readers for the blind and Microsoft tools/APIs may allow you to get this Control ID

   TEXT - The text on a control, for example "&Next" on a button
   CLASS - The internal control classname such as "Edit" or "Button"
   CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1"
   NAME - The internal .NET Framework WinForms name (if available)
   REGEXPCLASS - Control classname using a regular expression
   INSTANCE - The 1-based instance when all given properties match.

Comments