Two Plus Two Newer Archives

Two Plus Two Newer Archives (http://archives1.twoplustwo.com/index.php)
-   Software (http://archives1.twoplustwo.com/forumdisplay.php?f=47)
-   -   prevent focus stealing in Vista? messing up my AHK script (http://archives1.twoplustwo.com/showthread.php?t=548187)

Surf 11-17-2007 05:26 AM

prevent focus stealing in Vista? messing up my AHK script
 
Hey Software forum,

I wrote up a bet-pot AHK script to use with a xbox360 controller, however, I run into problems when a table steals focus when the action gets to me...if i'm about to click "bet pot" on one table, and the new one pops up the second before I input the command it is redirected to the new table. This can get messy quick.

Any thoughts on preventing other windows from stealing focus? I tried tweakUI but it doesn't run on vista, not sure if it would help anyway. Any ideas for workarounds in AHK?

Thanks!

Surf

fozzy71 11-17-2007 05:31 AM

Re: prevent focus stealing in Vista? messing up my AHK script
 
Site?

If Stars - try Keyboard Redirect script. No clue if it might even work. GL

Surf 11-17-2007 05:32 PM

Re: prevent focus stealing in Vista? messing up my AHK script
 
I found a decent workaround in case anyone has the same problem. When I first register a button click on a table i use MouseGetPos,,tableId to retrieve the ID # of the table under the cursor. Then, before I send a command like ControlClick or whatnot, I first use WinActivate, %tableId% to activate the table that was under the mousepointer when the click initially happened.

It's still possible that another table will steal focus in between the time the table is activated and the time the click is sent (in between 2 lines of code) but it is extremely unlikely.

Surf

jukofyork 11-17-2007 07:03 PM

Re: prevent focus stealing in Vista? messing up my AHK script
 
[ QUOTE ]
I found a decent workaround in case anyone has the same problem. When I first register a button click on a table i use MouseGetPos,,tableId to retrieve the ID # of the table under the cursor. Then, before I send a command like ControlClick or whatnot, I first use WinActivate, %tableId% to activate the table that was under the mousepointer when the click initially happened.

It's still possible that another table will steal focus in between the time the table is activated and the time the click is sent (in between 2 lines of code) but it is extremely unlikely.

[/ QUOTE ]
Have you tried to use my PostLeftClick() function. It posts a mouse click into the window's message queue which means it can't mess up and click in the wrong window:

<font class="small">Code:</font><hr /><pre>
PostLeftClick(x, y, table_id, activate=1) {
; ### JUK: Send the down left click, then the mouse-up messages.
; NOTE: This is relative to the top left of the client area and NOT the top left of the
; window (ie: It *doesn't* include the title-bar like AHK's MouseClick does!!!).
If activate
WinActivate, ahk_id%table_id%
PostMessage, 0x201, 0x0001, ((y&lt;&lt;16)^x), , ahk_id%table_id%
PostMessage, 0x202 , 0, ((y&lt;&lt;16)^x), , ahk_id%table_id%
}
</pre><hr />

Juk [img]/images/graemlins/smile.gif[/img]


All times are GMT -4. The time now is 07:45 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.