Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Avoid WM_ACTIVATE message


  • Please log in to reply
2 replies to this topic
Kinetik
  • Members
  • 17 posts
  • Last active: Apr 04 2012 06:43 PM
  • Joined: 07 Mar 2009
Hi guys,
I'm trying to make a script that avoid automatic sitting out while playing online poker. This presses "Sit in" button,even on windows not hilighted

Numpaddot::
WinGet, Output, List, ahk_class PTIODEVICE
loop, %output%
{
	SetFormat, Integer, d
	id := output%A_Index%
	WinGetPos,,, w, h, ahk_id %id%

	SetFormat, Integer, hex
		x := Round(xO * w)
		y := Round(yO * h)
		x += 0
		y += 0
	SetFormat, Float, 0.2
	
	x := SubStr(x,3)
	count := 4 - StrLen(x)
	loop, %count%
		x := "0" . x

	y := SubStr(y,3)
	count := 4 - StrLen(y)
	loop, %count%
		y := "0" . y
	hexS := "0x" . y . x

	PostMessage, 0x201, 0x0001, %hexs%, , ahk_id %id%
	PostMessage, 0x202, 0x0001, %hexs%, , ahk_id %id%

}
Return

the problem is that this make the target windows steal focus from the previous one of the group.

Eg: I'm playing on two table while writing a letter to Silvio Berlusconi on notepad. I press the "Sit-in" hotkey. Notepad window remain on foreground,but I see that the other windows steal focus each other

Before:
1.notepad
2.poker A
3.poker B

After:
1.notepad
2.poker B
3.poker A

I need to avoit it! Whit Winspector Spy I can see that "WM_ACTIVATE" message is sent to the window that steal focus. How can I intercept this?

Thanks to anyone will help me!!

OnlyHuman
  • Members
  • 280 posts
  • Last active: Nov 27 2013 11:30 PM
  • Joined: 18 Feb 2011
I found this http://msdn.microsof...4(v=vs.85).aspx

#define WM_ACTIVATE 0x0006

WA_ACTIVE
1 [Activated by some method other than a mouse click (for example, by a call to the SetActiveWindow function or by use of the keyboard interface to select the window).]

WA_CLICKACTIVE
2
Activated by a mouse click.

WA_INACTIVE
0
Deactivated.

Maybe you can use WA_INACTIVE.

Kinetik
  • Members
  • 17 posts
  • Last active: Apr 04 2012 06:43 PM
  • Joined: 07 Mar 2009
I've got no problems switching focus when I need it, I want to PREVENT it when I send this
PostMessage, 0x201, 0x0001, %hexs%, , ahk_id %id%
PostMessage, 0x202, 0x0001, %hexs%, , ahk_id %id%
to the windows (that means LBUTTONDOWN/LBUTTONUP) ;)