Notify another script when I suspend a script using the tray icon Topic is solved
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Notify another script when I suspend a script using the tray icon
Is there a way to send a message to another script when I suspend a script using the trey icon?
I know from the documentation that I could use one script to suspend another, however, in my case, I need to see at all times on the gui of another script if another script is suspended or not.
Any ideas?
I know from the documentation that I could use one script to suspend another, however, in my case, I need to see at all times on the gui of another script if another script is suspended or not.
Any ideas?
Re: Notify another script when I suspend a script using the tray icon Topic is solved
Hi,
You can replace the standard menu with a customized menu that suspends and notifies, or just notifies.
You can replace the standard menu with a customized menu that suspends and notifies, or just notifies.
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: Notify another script when I suspend a script using the tray icon
thanksmikeyww wrote: ↑27 Sep 2022, 16:47Hi,
You can replace the standard menu with a customized menu that suspends and notifies, or just notifies.
-
- Posts: 4309
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Notify another script when I suspend a script using the tray icon
Also you can intercept the command from the standard tray menu:
Code: Select all
OnMessage(0x111, "WM_COMMAND")
WM_COMMAND(wp, lp) {
static ID_SUSPEND := 65305, timer := Func("WM_COMMAND").Bind("timer", "")
if (wp = "timer")
MsgBox, % "A_IsSuspended: " . A_IsSuspended ; send message here instead of MsgBox
else if (lp = 0 && wp = ID_SUSPEND)
SetTimer, % timer, -10
}
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: Notify another script when I suspend a script using the tray icon
Great, thanks, this help me not having to modify the menu. Can you see if this is coded correctly? I am getting the messages correctly to my other script (22 and 23), however, is this the correct way to code this?teadrinker wrote: ↑27 Sep 2022, 18:40Also you can intercept the command from the standard tray menu:Code: Select all
OnMessage(0x111, "WM_COMMAND") WM_COMMAND(wp, lp) { static ID_SUSPEND := 65305, timer := Func("WM_COMMAND").Bind("timer", "") if (wp = "timer") MsgBox, % "A_IsSuspended: " . A_IsSuspended ; send message here instead of MsgBox else if (lp = 0 && wp = ID_SUSPEND) SetTimer, % timer, -10 }
Thank you
Code: Select all
OnMessage(0x111, "WM_COMMAND")
WM_COMMAND(wp, lp)
{
static ID_SUSPEND := 65305, timer := Func("WM_COMMAND").Bind("timer", "")
if (wp = "timer") {
;MsgBox, % "A_IsSuspended: " . A_IsSuspended ; send message here instead of MsgBox
SetTitleMatchMode 2
DetectHiddenWindows On
if WinExist("scriptinventory.ahk ahk_class AutoHotkey")
if A_IsSuspended
PostMessage, 0x5555, 11, 22 ; The message is sent to the "last found window" due to WinExist() above.
else
PostMessage, 0x5555, 11, 23
}
else if (lp = 0 && wp = ID_SUSPEND) {
SetTimer, % timer, -10
}
}
return
-
- Posts: 4309
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Notify another script when I suspend a script using the tray icon
The code is correct. It can be simplified like this:AHKStudent wrote: ↑is this the correct way to code this?
Code: Select all
OnMessage(0x111, "WM_COMMAND")
WM_COMMAND(wp, lp)
{
static ID_SUSPEND := 65305, timer := Func("WM_COMMAND").Bind("timer", "")
if (lp = 0 && wp = ID_SUSPEND)
SetTimer, % timer, -10
else if (wp = "timer") {
SetTitleMatchMode 2
DetectHiddenWindows On
if WinExist("scriptinventory.ahk ahk_class AutoHotkey")
PostMessage, 0x5555, 11, A_IsSuspended ? 22 : 23
}
}
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: Notify another script when I suspend a script using the tray icon
thank youteadrinker wrote: ↑27 Sep 2022, 23:30The code is correct. It can be simplified like this:AHKStudent wrote: ↑is this the correct way to code this?Code: Select all
OnMessage(0x111, "WM_COMMAND") WM_COMMAND(wp, lp) { static ID_SUSPEND := 65305, timer := Func("WM_COMMAND").Bind("timer", "") if (lp = 0 && wp = ID_SUSPEND) SetTimer, % timer, -10 else if (wp = "timer") { SetTitleMatchMode 2 DetectHiddenWindows On if WinExist("scriptinventory.ahk ahk_class AutoHotkey") PostMessage, 0x5555, 11, A_IsSuspended ? 22 : 23 } }
Re: Notify another script when I suspend a script using the tray icon
In case anyone is looking for a way to do this that also works with suspend states changed via hotkeys, not just through the tray menu, I have set up a timer to give me notification:
Code: Select all
global SuspendState := 0
SetTimer, T_SuspendNotify, 250
T_SuspendNotify:
if (A_IsSuspended and !SuspendState)
{
SuspendState := 1
msgbox, Hotkeys suspended.
return
}
if (!A_IsSuspended and SuspendState)
{
SuspendState := 0
return
}
return