removed

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Yaosr
Posts: 53
Joined: 04 Nov 2017, 04:59

removed

25 Feb 2018, 03:56

removed
Last edited by Yaosr on 29 Apr 2018, 16:20, edited 1 time in total.
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: #SingleInstance, Force = what is it

25 Feb 2018, 04:29

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
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: #SingleInstance, Force = what is it

25 Feb 2018, 04:40

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
I am your average ahk newbie. Just.. a tat more cute. ;)
Yaosr
Posts: 53
Joined: 04 Nov 2017, 04:59

solved

25 Feb 2018, 04:42

solved
Last edited by Yaosr on 29 Apr 2018, 16:21, edited 1 time in total.
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: #SingleInstance, Force = what is it

25 Feb 2018, 06:09

Yaosr wrote:so what is instance in that case? is instance = script ?
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.

So that avoids this from happening.
I am your average ahk newbie. Just.. a tat more cute. ;)
Yaosr
Posts: 53
Joined: 04 Nov 2017, 04:59

removed

25 Feb 2018, 06:56

removed
Last edited by Yaosr on 29 Apr 2018, 16:20, edited 1 time in total.
Yaosr
Posts: 53
Joined: 04 Nov 2017, 04:59

solved

25 Feb 2018, 07:06

solved
Last edited by Yaosr on 29 Apr 2018, 16:20, edited 1 time in total.
gregster
Posts: 8999
Joined: 30 Sep 2013, 06:48

Re: #SingleInstance, Force = what is it

25 Feb 2018, 13:10

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.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: #SingleInstance, Force = what is it

25 Feb 2018, 13:32

- You can trigger a hotkey in one script, and get that to trigger other scripts.

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
}
- 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
~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

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], mikeyww and 223 guests