#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
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 |
#3
|
|||
|
|||
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 |
#4
|
|||
|
|||
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<<16)^x), , ahk_id%table_id% PostMessage, 0x202 , 0, ((y<<16)^x), , ahk_id%table_id% } </pre><hr /> Juk [img]/images/graemlins/smile.gif[/img] |
|
|