'Pause / Restart AutoHotKey text playback
I have a simple AHK script that plays back text into an editor ( see script below ).
I want to be able to Pause / Resume the playback by pressing a sequence of keys.
I reviewed a few solutions here & at various AHK sites w/o success.
The script below should startup when I type Mike XXX ( and then press enter ) and should pause / restart when I use the Ctrl+Alt+P key sequence ...if I uncomment the Pause key sequence the script does not run at all ...any thoughts ?
++++++++++ AHK Script ++++++++++
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; ================ Define PAUSE key sequence ======================
;^!p::Pause ; Press Ctrl+Alt+P to pause. Press it again to resume.
; =================================================================
BAS1 =
(
This is line 1 of some text
)
BAS2 =
(
This is line 2 of some text
)
BAS3 =
(
This is line 3 of some text
)
; ==================================================
; ====================== Start BAS definitions
; ==================================================
::Mike XXX::
send, Mike XXX
send, {enter 2}
SendDelay(BAS1)
send, {enter 2}
SendDelay(BAS2)
send, {enter 2}
SendDelay(BAS3)
send, {enter 2}
return
; ==================================================
; ====================== End BAS definitions
; ==================================================
SendDelay(text) {
Loop, parse, text
{
Random, rdel, 5, 9
Random, rdur, 6, 9
SetKeyDelay, %rdel%, %rdur%
Sendraw % A_LoopField
}
}
; =================================== End Methods
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
