Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > Internet Gambling > Software

Reply
 
Thread Tools Display Modes
  #1  
Old 11-17-2007, 05:26 AM
Surf Surf is offline
Senior Member
 
Join Date: Apr 2004
Location: Blogging
Posts: 5,619
Default 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
Reply With Quote
  #2  
Old 11-17-2007, 05:31 AM
fozzy71 fozzy71 is offline
Senior Member
 
Join Date: Mar 2007
Location: Got Themes?
Posts: 2,013
Default 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
Reply With Quote
  #3  
Old 11-17-2007, 05:32 PM
Surf Surf is offline
Senior Member
 
Join Date: Apr 2004
Location: Blogging
Posts: 5,619
Default 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
Reply With Quote
  #4  
Old 11-17-2007, 07:03 PM
jukofyork jukofyork is offline
Senior Member
 
Join Date: Sep 2004
Location: Leeds, UK.
Posts: 2,551
Default 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]
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:30 AM.


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