Pausing one script with an other?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
PepeLapiu
Posts: 324
Joined: 19 Jun 2020, 14:06

Pausing one script with an other?

Post by PepeLapiu » 21 May 2022, 19:46

So I want one.ahk script to pause two.ahk
I figured one.ahk would be like this:

Code: Select all

Send, #b
exitapp
And two.ahk would be like this:

Code: Select all

Loop {
	soundbeep,600,500
	sleep 500
}
#b::Pause
Why doesn't this work? How can I get one.ahk to pause two.ahk?


BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Pausing one script with an other?

Post by BoBo » 22 May 2022, 04:02

"Poor men’s"-option…

Script1

Code: Select all

F12::FileAppend,,pause.ahk
Script2

Code: Select all

MsgBox, Here we go.
if FileExist("pause.ahk") {
   FileDelete, pause.ahk
   ExitApp
   }
Same working directory.

PepeLapiu
Posts: 324
Joined: 19 Jun 2020, 14:06

Re: Pausing one script with an other?

Post by PepeLapiu » 25 May 2022, 14:33

BoBo wrote:
22 May 2022, 04:02
"Poor men’s"-option…

Script1

Code: Select all

F12::FileAppend,,pause.ahk
Script2

Code: Select all

MsgBox, Here we go.
if FileExist("pause.ahk") {
   FileDelete, pause.ahk
   ExitApp
   }
Same working directory.
From where I stand that would only work if the second script is reading that section and the script would only pause if and when it reads that line. No?
Look at it this way. This is second_script.akh:

Code: Select all

Loop (
  SoundBeep, 600,500
  Sleep, 500
}
if FileExist("pause.ahk") {
   FileDelete, pause.ahk
   ExitApp
}
second_script.ahk will only pause if it breaks out of the loop and reads subsequent code.
How do you pause the script while in the loop?

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Pausing one script with an other?

Post by BoBo » 25 May 2022, 15:20

https://www.autohotkey.com/docs/commands/Until.htm :think:
OTOH, @mikeyww's advice to check out AHK's PostMessage-command is Gold. Its 2nd sample code is (AFAICS) doing exactly what you are looking for. Go 4 it :thumbup:

Post Reply

Return to “Ask for Help (v1)”