removed
Re: #SingleInstance, Force = what is it
From here : https://autohotkey.com/docs/commands/_S ... stance.htm
#SingleInstance : Determines whether a script is allowed to run again when it is already running.
#SingleInstance force|ignore|off
The word FORCE skips the dialog box and replaces the old instance automatically, which is similar in effect to the Reload command.
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Re: #SingleInstance, Force = what is it
The docs are glitched at the moment ._.
But yea like odlanir said it prevents two instances of the same script and force replaces the old instance with the new instance
But yea like odlanir said it prevents two instances of the same script and force replaces the old instance with the new instance
I am your average ahk newbie. Just.. a tat more cute.
Re: #SingleInstance, Force = what is it
Yes. If suppose you have a script running and it sends P every time you click X, and you mistakely open that same script again. When you press P it sends out 2x X. Because there are two scripts.Yaosr wrote:so what is instance in that case? is instance = script ?
So that avoids this from happening.
I am your average ahk newbie. Just.. a tat more cute.
Re: #SingleInstance, Force = what is it
Yeah, I think (duplicate) hotkey definition in different script instances will just compete - and only one will be triggered. That is not a technique that will work.
But if you have auto-execute sections (including loops and timers) they will run at the same time - in parallel.
But if you have auto-execute sections (including loops and timers) they will run at the same time - in parallel.
Re: #SingleInstance, Force = what is it
- You can trigger a hotkey in one script, and get that to trigger other scripts.
- A_ScriptHwnd is the hWnd (window handle) for the script's main window (the one you see when you double-click on the systray icon). Every window/control has a temporary unique number.
- The script demonstrates how you can have multiple scripts all react simultaneously to the same hotkey. Each script does an action (shows a MsgBox), even though only one receives the key press. Since each MsgBox shows a different number, it confirms that each script has been triggered (directly or indirectly) by the hotkey.
- You could also use ~x:: in multiple scripts, they'll all trigger, however, the x key is not suppressed (the active window receives the key press).
Code: Select all
#SingleInstance, off
OnMessage(0x5555, "MsgMonitor")
x:: ;one script to trigger them all
DetectHiddenWindows, On
WinGet, vWinList, List, % A_ScriptFullPath " - AutoHotkey v ahk_class AutoHotkey"
Loop, % vWinList
{
hWnd := vWinList%A_Index%
if !(hWnd = A_ScriptHwnd)
PostMessage, 0x5555,,,, % "ahk_id " hWnd
}
;MsgBox, % A_ScriptHwnd
MsgMonitor("", "", "", "")
return
MsgMonitor(wParam, lParam, uMsg, hWnd)
{
MsgBox, % A_ScriptHwnd
}
- The script demonstrates how you can have multiple scripts all react simultaneously to the same hotkey. Each script does an action (shows a MsgBox), even though only one receives the key press. Since each MsgBox shows a different number, it confirms that each script has been triggered (directly or indirectly) by the hotkey.
- You could also use ~x:: in multiple scripts, they'll all trigger, however, the x key is not suppressed (the active window receives the key press).
Code: Select all
#SingleInstance, off
~x:: ;triggered, not suppressed (open a script multiple times, the key press triggers the subroutine in each instance, however, the key press is not suppressed)
MsgBox, % A_ScriptHwnd
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], moltenchees and 269 guests