Jump to content


Photo

Gui OnMessage - Control its execution / disable it once set?


  • Please log in to reply
3 replies to this topic

#1 Cephei1

Cephei1
  • Members
  • 388 posts

Posted 24 May 2012 - 08:57 PM

Hi,

In Ahk_L

1) How can I restrict the OnMessage to act for only a Specific GUI and not others?
2) And How can I disable a OnMessage once it is set?

Thank you

#2 Alpha Bravo

Alpha Bravo
  • Members
  • 844 posts

Posted 25 May 2012 - 01:52 AM

I think it depends on which message you're using but here is an example for you:
Gui, Add, Text,, Click anywhere in this window.

Gui, Add, Edit, w200

Gui, Show ,x200 y100, Gui 1



Gui,2: Add, Text,vtext2, Click anywhere in this window.

Gui,2: Add, Edit, w200

Gui,2: Show, x200 y300, Gui 2



Gui,Three: Add, Text,vtext2, Click anywhere in this window.

Gui,Three: Add, Edit, w200

Gui,Three: Show, x200 y500, Gui three

OnMessage(0x201, "WM_LBUTTONDOWN")

return



!t::toggle:=!toggle



WM_LBUTTONDOWN(wParam, lParam)

{

	global toggle

	if toggle

		TrayTip ,, sorry OnMessage is disabled

	else

	{

		if A_gui = 1

			TrayTip ,, you clicked on Gui 1

		else if A_gui = 2

			TrayTip ,, you clicked on Gui 2

		else if A_gui = three

			TrayTip ,, you clicked on Gui three

	}

}


#3 Cephei1

Cephei1
  • Members
  • 388 posts

Posted 25 May 2012 - 02:27 AM

this is the sort of thing i am using right now. I just wanted to know if there was an easier/prescribed way

#4 just me

just me
  • Members
  • 1173 posts

Posted 25 May 2012 - 05:12 AM

2) And How can I disable a OnMessage once it is set?

OnMessage()
Parameters
FunctionNameSpecify an empty string ("") or an empty variable to turn off the monitoring of MsgNumber.