쓰레드

현재 쓰레드는 최근의 이벤트가 요청한 실행 흐름으로 정의됩니다; 예로는 핫키, SetTimer 서브루틴, 맞춤 메뉴 항목, 그리고 GUI 이벤트가 포함됩니다. 현재 쓰레드는 자신의 서브루틴 안 또는 그 서브루틴을 호출한 다른 서브루틴 안에서 명령어를 실행할 수 있습니다.

오토핫키는 실제로 다중 스레드를 사용하지 않지만, 그 몇 가지 행위는 흉내를 냅니다: 두 번째 쓰레드가 시작되면 -- 예를 들어 이전의 핫키가 여전히 실행 중인 동안 또다른 핫키를 눌러서 -- 현재 쓰레드가 인터럽트 되어 (임시로 정지되어) 새 쓰레드가 현재 쓰레드가 됩니다. 두 번째 쓰레드가 실행 중인 동안 세 번째 쓰레드가 시작되면, 첫 번째와 두 번째 쓰레드 모두 동면 상태로 들어갑니다. 등등.

현재 쓰레드가 끝나면, 가장 최근에 인터럽트된 쓰레드가 재개됩니다. 등등. 모든 쓰레드가 결국 다 끝날 때까지 계속됩니다. 재개되면, ErrorLevelSendMode에 대한 쓰레드의 설정이 자동으로 인터럽트 전과 똑 같은 상태로 복구됩니다; 다른 말로, 쓰레드는 인터럽트 되어도 부작용을 경험하지 않습니다 (단, 활성 창에 가한 변경은 예외입니다).

주의: KeyHistory 명령어/메뉴-항목은 얼마나 많은 쓰레드가 인터럽드된 상태에 있는지를 보여줍니다. ListHotkeys 명령어/메뉴-항목은 어느 핫키가 쓰레드를 가졌는지 보여줍니다.

스크립트 하나가 동시에 MsgBox, InputBox, FileSelectFile, 그리고 FileSelectFolder 대화상자를 여러 개 가질 수 있습니다. 이전 쓰레드가 이미 대화상자를 보여주고 있는 동안에 (핫키, 시간제한 서브루틴, 맞춤 메뉴 항목, 등등을 통하여.). 새 쓰레드를 또 기동하면 됩니다

기본값으로, 주어진 핫키핫스트링 서브루틴은 이미 실행 중이면 두 번째로 시작할 수 없습니다. 이 행위를 바꾸려면 #MaxThreadsPerHotkey를 사용하십시오.

Related: The Thread command sets the priority or interruptibility of threads.

쓰레드 우선 순위

어떤 쓰레드이든 (핫키, 시간제한 서브루틴, 맞춤 메뉴 항목, 등등.) 현재 쓰레드보다 우선 순위보다 낮으면 인터럽트 할 수 없습니다. 그 시간 동안, 타이머는 실행되지 않으며, 사용자가 (핫키GUI 버튼을 눌러서) 새로운 쓰레드를 만들려는 시도도 아무 효과가 없습니다. 버퍼 처리조차 되지 않습니다. 이 때문에, 보통 최고 우선순위의 쓰레드를 빨리 끝내도록 설계하는 것이 가장 좋습니다. 아니면 최고 우선 순위를 주지 말고 Critical을 사용하십시오.

우선 순위 기본값은 0입니다. 모든 쓰레드는 기본 우선 순위를 사용합니다. 단, 다음 방식 중 하나 때문에 바뀌는 경우는 예외입니다:

The OnExit thread (if any) will always run when called for, regardless of the current thread's priority.

Thread Interruptibility

For most types of events, new threads are permitted to launch only if the current thread is interruptible. A thread can be uninterruptible for a number of reasons, including:

Behavior of Uninterruptible Threads

Unlike high-priority threads, events that occur while the thread is uninterruptible are not discarded. For example, if the user presses a hotkey while the current thread is uninterruptible, the hotkey is buffered indefinitely until the current thread finishes or becomes interruptible, at which time the hotkey is launched as a new thread.

Any thread may be interrupted in emergencies. 비상 시란 다음과 같이 구성됩니다: 1) an OnExit callback; 2) any OnMessage function that monitors a message number less than 0x0312 (or a callback triggered by such a message); and 3) any callback indirectly triggered by the thread itself (e.g. via SendMessage or DllCall). 이런 인터럽트를 피하려면, 임시로 그런 함수들을 비활성화 시키십시오.

임계 쓰레드는 MsgBox나 기타 대화상자가 화면에 나타나면 인터럽트될 수 있습니다. However, unlike Thread Interrupt, the thread becomes critical (and therefore uninterruptible) again after the user dismisses the dialog.