Hey guys,
'#SingleInstance Force' does not work all the time. I have some scripts where it is within the main loop, so it should definitely be working I would think.
Is there any way to get it to work flawlessly?
#SingleInstance Force - does not work 100% of time
Re: #SingleInstance Force - does not work 100% of time
Add #SingleInstance Force to the top of your script, not inside a loop.
Re: #SingleInstance Force - does not work 100% of time
It makes no difference where you put it.
There are two ways it can fail:
I wouldn't call it a failure, but having #SingleInstance Off after it in the script would stop it from working. For instance,In this case, the setting is unconditionally OFF, because as I said, it makes no difference where you put the directive. It takes effect immediately upon loading the script, before the script starts executing (so before if-statements etc. can be evaluated).
There are two ways it can fail:
- It fails to find the previous instance's main window (which is usually hidden). This will happen if you changed the window's title (WinSetTitle) or parent (DllCall to SetParent). It can also happen if you launch the script using a different path; for instance, if you launch the script from a mapped network drive and then from a UNC or local path, they won't be considered the same script.
- It fails to close the other window because the window is not responding to messages, or the script specifically discards the WM_COMMNOTIFY message. If closing the script fails, you get an error message to that effect.
I wouldn't call it a failure, but having #SingleInstance Off after it in the script would stop it from working. For instance,
Code: Select all
if something
{
#SingleInstance Force
}
else
{
#SingleInstance Off
}
Re: #SingleInstance Force - does not work 100% of time
; thats the plan:
; SingleInstance,Force ... but its sometimes not work. See reasons above.
; set NoTrayIcon to make it hidden.
; Search it. hopefully dont find it. if its found, then dont start it again as a second instance.
good luck
; SingleInstance,Force ... but its sometimes not work. See reasons above.
; set NoTrayIcon to make it hidden.
; Search it. hopefully dont find it. if its found, then dont start it again as a second instance.
good luck
github>g_IntelliSense + next improvements + forum
ahk..org>onlineAHKprettyfy, ahk..com>Refactoring
ahk..com>newposts Unanswrd myposts, Donations are appreciated if I could help you
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
ahk..org>onlineAHKprettyfy, ahk..com>Refactoring
ahk..com>newposts Unanswrd myposts, Donations are appreciated if I could help you
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Who is online
Users browsing this forum: Google [Bot], LeafyWater and 172 guests