Sending and receiving a broadcast message. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Hellbent
Posts: 2114
Joined: 23 Sep 2017, 13:34

Sending and receiving a broadcast message.

10 Sep 2023, 08:31

I have a color picker that I would like to use to broadcast a value to any script that is listening.

For extra context.
.
20230910092312.png
20230910092312.png (40.76 KiB) Viewed 502 times
.

Does anyone have a good method to accomplish this?
I think that there is a message that can be used but I can't recall what it was.
A simple example of script 1 passing script 2 a value of "FF0000" when you press f1 would be perfect.
Thanks for your time.
User avatar
Hellbent
Posts: 2114
Joined: 23 Sep 2017, 13:34

Re: Sending and receiving a broadcast message.  Topic is solved

28 Oct 2023, 16:24

Thanks mikeyww.

In my case though I needed something that would allow any script that is set to "listen" to be able to get the values.

This is what I have found that does the trick (so far).

Code: Select all

;Script 1
;#################

#SingleInstance Force

objShell := ComObjCreate( "WScript.Shell" )
objEnv := objShell.Environment( "Volatile" )
objEnv.Item( "Color" ) := "22262A"


return

F1::
	objEnv.Item( "Color" ) := Random( min := 0 , max := 100 )
	return
	
Random( min := 0 , max := 100 ){
	local outputVar
	Random, outputVar , min , max 
	return outputVar
}

;#################

;Script 2
;#################
#SingleInstance Force

return


F2::
	objShell := ComObjCreate( "WScript.Shell" )
	objEnv := objShell.Environment( "Volatile" )
	MsgBox, % objEnv.Item( "Color" )
	return

;#################

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], moltenchees, niCode and 204 guests