Could not close the previous instance of this script. Keep waiting? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
LAPIII
Posts: 667
Joined: 01 Aug 2021, 06:01

Could not close the previous instance of this script. Keep waiting?

Post by LAPIII » 20 Jan 2022, 16:43

Why do I get this and how do I avoid it?

User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: Could not close the previous instance of this script. Keep waiting?  Topic is solved

Post by mikeyww » 20 Jan 2022, 18:31

If you run a script that is already running, it might occur. You could try #SingleInstance Force.

LAPIII
Posts: 667
Joined: 01 Aug 2021, 06:01

Re: Could not close the previous instance of this script. Keep waiting?

Post by LAPIII » 20 Jan 2022, 19:24

I use that in every script. I get this after I have edited a script for the second time or more and then reload it. From what I've read, people have implemented into their scripts:
  1. Process, Close, % varThread
  2. WinClose, % "ahk_pid " . varThread
  3. WinWaitClose, % "ahk_pid " . varThread,, 2 ; Waits up to 2 seconds
  4. onexit,exiting
  5. SetWinDelay, 0 ; executes a Sleep(0), which yields the remainder of the script's timeslice to any other process that may need it.
I wonder if I should try any of these. Has anyone fixed this issue with any of these or anything else?

Post Reply

Return to “Ask for Help (v1)”