現在のスレッドを一時停止、または基礎となるスレッドの停止状態を設定します。
Pause UnderlyingThreadState
Type: Integer
省略されたときは、現在のスレッドが一時停止されます。そうでないときは、次のいずれかの値を指定します:
1またはTrue: 基礎となるスレッドを一時停止としてマークします。現在のスレッドは一時停止されず、実行し続けます。When the current thread finishes, the underlying thread resumes any interrupted function the underlying thread was running. Once the underlying thread finishes the function (if any), it enters a paused state. If there is no thread underneath the current thread, the script itself is paused, which prevents timers from running (this effect is the same as having used the menu item "Pause Script" while the script has no threads).
0 または False:基礎となるスレッドの一時停止を解除します。
-1:基礎となるスレッドの一時停止状態を切り替えます。
デフォルトでは、トレイアイコンまたはメインウィンドウからスクリプトを一時停止することも可能です。
Unlike Suspend -- which disables hotkeys and hotstrings -- turning on pause will freeze the thread (the current thread if UnderlyingThreadState was omitted, otherwise the underlying thread). As a side-effect, any interrupted threads underneath it will lie dormant until the current thread is unpaused and finishes.
Whenever any thread or the script itself is paused, timers will not run. 一方、ホットキーや メニュー項目など、明示的に起動されたスレッドはまだ起動可能ですが、それらのスレッドが終了すると、その下にあるスレッドはまだ一時停止しています。つまり、各スレッドは他のスレッドとは独立して一時停止することができるのです。
スクリプトの現在のスレッドが一時停止状態にあるとき、トレイアイコンは
に変わります。(またはスクリプトがsuspendedされたときは
に変わります)。このアイコンの変更は、TraySetIcon(,, true)を使ってアイコンをフリーズさせることで回避できます。
スクリプトを一時停止せずにタイマーを無効にするには、Thread NoTimersを使用します。
スクリプトが何らかのメニュー(トレイメニュー、メニューバー、GUIコンテキストメニューなど)を表示している間は、常に中断されます(正式には一時停止ではありません)。
組み込み変数A_IsPausedは、現在のスレッドの直下にあるスレッドが一時停止しているときは1を、そうでないときは0を格納します。
Suspend、Menuオブジェクト、ExitApp、スレッド、SetTimer
変数を検査するなど、スクリプトを停止させたいときはPause関数を使用します。
ListVars Pause ExitApp ; この行はユーザーがスクリプトの一時停止を解除しない限り実行されません。
ホットキーを1回押すと、スクリプトを一時停止することができます。もう一度押すと、一時停止が解除されます。
Pause::Pause -1 ; Pause/Break キー #p::Pause -1 ; Windowsキー+P
DetectHiddenWindows True WM_COMMAND := 0x0111 ID_FILE_PAUSE := 65403 PostMessage WM_COMMAND, ID_FILE_PAUSE,,, "C:\YourScript.ahk ahk_class AutoHotkey"