PDA

View Full Version : AutoHotKey Joystick script for mouseless poker


MrMoo
11-04-2005, 01:31 AM
I've gotten a few PM's regarding this script and I fixed the code up a bit tonight so I figured I'd post it.

This script will allow you to use a joystick to multitable hold 'em. It's mostly for limit but if you want to donk it up and min bet all the time, I suppose you could use it for that too.

See AutoHotKey (http://www.autohotkey.com) for more details if you're not familiar with it.

Even the UBB code doesn't really help display this properly. If anyone wants to host it, please email/PM and I'll send you a properly formatted copy.

Please let me know if you encounter any problems.

<font class="small">Code:</font><hr /><pre>
; 2005-11-02 - Written by MrMoo
;
; Send all problems/questions to ahkscript&lt;AT&gt;ocsnetworks.com
;
; This script was developed using a Saitek wireless joystick in digital mode. Some aspects of this
; code may not work properly with other joysticks. An effort has been made to make this code as
; generic as possible and to work with as many controllers as possible. If it doesn't work with
; your controller, I'd suggest running the Joystick test script found in the AutoHotKey.chm file
; provided with AutoHotKey to figure out what signals your joystick is sending.
;
; This script was designed primarily for use in limit hold 'em tables on PartyPoker. No limit
; features may be added at a later time. This script will work with multiple displays when in
; independent mode. Movement between tables is accomplished using the d-pad on your joystick. The
; x and y coordinates are translated to determine if the mouse should be moved up, down, left, or
; right. It's important to note that movement of the mouse is adjusted by the height or width of
; a single poker window. For example, the width of a standard PartyPoker window is 795 pixels.
; When the d-pad is moved right, the mouse will move right 795 pixels. Also important to note is
; that no movement will be made by the mouse if it can't fully move one screen. So if the cursor
; is currently in a poker window in the top left corner of your display and click up on the d-pad,
; the mouse will not move because you are already in the top window of your display.


; The following inputs are supported:
;
; D-pad up - Move the mouse up the height of one poker screen
; D-pad down - Move the mouse down the height of one poker screen
; D-pad right - Move the mouse right the width of one poker screen
; D-pad left - Move the mouse left the width of one poker screen
; Button 1 - Click the fold button
; Button 2 - Click the call button
; Button 3 - Click the Auto Post Blind button
; Button 4 - Put the mouse cursor in the chat box
; Button 5 - Click the Bet/Raise button
; Button 6 - Put the mouse cursor in the Insert Bet box

; START OF CODE
#SingleInstance

; Variables for the location of the different controls. These can be modified for other poker
; clients
PH = 581 ; This is the height of a PartyPoker window
PW = 795 ; This is the width of a PartyPoker window
Xfold = 245 ; The x coordinate of the fold button in a PartyPoker window
Yfold = 475 ; The y coordinate of the fold button in a PartyPoker window
Xcall = 405 ; The x coordinate of the call button in a PartyPoker window
Ycall = 475 ; The y coordinate of the call button in a PartyPoker window
Xbet = 565 ; The x coordinate of the bet button in a PartyPoker window
ybet = 475 ; The y coordinate of the bet button in a PartyPoker window
Xapb = 15 ; The x coordinate of the "Auto Post Blind" checkbox in a PartyPoker window
Yapb = 535 ; The y coordinate of the "Auto Post Blind" checkbox in a PartyPoker window
Xib = 360 ; The x coordinate of the "Insert Bet" box in a PartyPoker window
Yib = 440 ; The y coordinate of the "Insert Bet" box in a PartyPoker window
Xtalk = 200 ; The x coordinate of the Talk box in a PartyPoker window
Ytalk = 570 ; The y coordinate of the Talk box in a PartyPoker window


; Auto-detect the joystick number if called for:
if JoystickNumber &lt;= 0
{
Loop 32 ; Query each joystick number to find out which ones exist.
{
GetKeyState, JoyName, %A_Index%JoyName
if JoyName &lt;&gt;
{
JoystickNumber = %A_Index%
break
}
}
if JoystickNumber &lt;= 0
{
MsgBox The system does not appear to have any joysticks.
ExitApp
}
}


CoordMode, Mouse
SetFormat, float, 03 ; Omit decimal point from axis position percentages

Hotkey, %JoystickNumber%Joy1, Fold
Hotkey, %JoystickNumber%Joy2, Call
Hotkey, %JoystickNumber%Joy3, AutoPostBlind
Hotkey, %JoystickNumber%Joy4, Talk
Hotkey, %JoystickNumber%Joy5, Bet
Hotkey, %JoystickNumber%Joy6, InsertBet

Loop
{
; Gets the keystate of joysticks X and Y coordinates
GetKeyState, joyx, %JoystickNumber%JoyX
GetKeyState, joyy, %JoystickNumber%JoyY
if joyx &gt; 75 ; Joystick RIGHT
{
; Get the monitors full virtual resolution width
SysGet, VirtualWidth, 78
; Get the current cursor position
MouseGetPos, x, y
; Calculate the x coordinate where the mouse will be moved
newX := x + PW
; Make sure we wouldn't be moving the cursor outside of the monitors resolution range
if newX &lt; %VirtualWidth%
{
; Move the cursor to the new location
MouseMove, %PW%, 0, 2, R
; Get the cursors new position
MouseGetPos, , , WinID,
; Figure out the window properties of the window currently under the cursor
WinGetPos, x, y, w, h, ahk_id %winID%
; Activate the window currently under the mouse
WinActivate, ahk_id %winID%
}
}
if joyx &lt; 25 ; Joystick LEFT
{
MouseGetPos, x, y
if x &gt; %PW%
{
MouseMove, -%PW%, 0, 2, R
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
WinActivate, ahk_id %winID%
}
}
if joyy &gt; 75 ; Joystick DOWN
{
; Get the monitors full virtual resolution height
SysGet, VirtualHeight, 79
MouseGetPos, x, y
newY := y + PH
if newY &lt; %VirtualHeight%
{
MouseMove, 0, %PH%, 2, R
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
WinActivate, ahk_id %winID%
}
}
if joyy &lt; 25 ; Joystick UP
{
MouseGetPos, x, y
if y &gt; %PH%
{
MouseMove, 0, -%PH%, 2, R
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
WinActivate, ahk_id %winID%
}
}
Sleep, 100
}
return

Fold:
; Get the window ID for the window currently under the cursor
MouseGetPos, , , winID,
; Get the pixel coordinate of the window currently under the cursor
WinGetPos, x, y, w, h, ahk_id %winID%
; Calculate the coordinate of the fold button based on the current location of the cursor
newX := x + Xfold
newY := y + Yfold
; Activate the window currently under the cursor
WinActivate, ahk_id %winID%
; Block the mouse from being moved by something else
BlockInput On
; Click the cursor on the desired location
MouseClick, left, %newX%, %newY%
; Unblock the mouse
BlockInput Off
return

Call:
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
newX := x + Xcall
newY := y + Ycall
WinActivate, ahk_id %winID%
BlockInput On
MouseClick, left, newX, newY
BlockInput Off
return

Bet:
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
newX := x + Xbet
newY := y + Ybet
WinActivate, ahk_id %winID%
BlockInput On
MouseClick, left, newX, newY
BlockInput Off
return

AutoPostBlind:
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
newX := x + Xapb
newY := y + Yapb
WinActivate, ahk_id %winID%
BlockInput On
MouseClick, left, newX, newY
BlockInput Off
return

InsertBet:
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
newX := x + Xib
newY := y + Yib
WinActivate, ahk_id %winID%
BlockInput On
MouseClick, left, newX, newY
MouseClick, left, newX, newY
Send, {BS}
Sleep, 100
BlockInput Off
return

Talk:
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
newX := x + Xtalk
newY := y + Ytalk
WinActivate, ahk_id %winID%
BlockInput On
MouseClick, left, newX, newY
MouseClick, left, newX, newY
Send, {BS}
Sleep, 100
BlockInput Off
return
</pre><hr />

SamIAm
11-08-2005, 02:33 AM
This is great, but I have a few questions. (Don't worry; not support issues, just potential improvements. /images/graemlins/smile.gif )

Right now you're using solely mouse locations. For instance, folding = MouseClick, left, X+245, Y+475. The thing is, when I mouse-over a button in Party, the AutoHotkey WindowSpy knows the location AND THE TEXT of that button. For instance, when I mouse-over the "Fold" button, it says[ QUOTE ]
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;[Mouse Position]&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
In Active Window: 245, 475
...
&gt;&gt;&gt;&gt;&gt;&gt;&gt;[Now Under Mouse Cursor]&lt;&lt;&lt;&lt;&lt;&lt;&lt;
Text: Fold

[/ QUOTE ]The problem is, when I mouse over the "Post BB" button, it says[ QUOTE ]
&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;[Mouse Position]&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
In Active Window: 245, 475
...
&gt;&gt;&gt;&gt;&gt;&gt;&gt;[Now Under Mouse Cursor]&lt;&lt;&lt;&lt;&lt;&lt;&lt;
Text: Post BB (200)

[/ QUOTE ]Notice, the mouse coordinates are the same. In your current setup, if I were to push a "post" macro when a bet came to me, I'd fold. If I were multitabling (and confused) that could be a shame. But what if we were to use that "Text:" feature? Wouldn't it be cool if AHK only clicked on the button that read the text we wanted?

I don't know how to do this (yet). Pushing the "fold" button would be hard, because I don't know how to search for a button with given text. However, the "post" button would be even harder. It's text changes with the limit. /images/graemlins/frown.gif We'd have to search for a button THAT CONTAINED the word "post". I expect that's at least a little harder.
-Sam

P.S. I'm gonna figure out how to do this even if nobody gives me a hint. I'm sure I'll quickly pass out of the range of effort where this is efficient (How many hours can I spend to make a button-press more efficient?) but I bet getting better at AHK will prove fruitful in other parts of my computer-life. /images/graemlins/smile.gif

SamIAm
11-08-2005, 02:39 AM
If you don't want to get the mouse position and add it to the window-location every time you want to click, I think you can set the CoordMode (http://www.autohotkey.com/docs/commands/CoordMode.htm) parameter, and do everything in ActiveWindow coords.
-Sam

SamIAm
11-08-2005, 04:14 AM
I got it:[ QUOTE ]

;;Deal out
!d::
WinGetTitle, winTitle, A
SetTitleMatchMode, 3
ControlClick, Deal Me Out, %winTitle%
return

[/ QUOTE ]There are all sorts of issues about which MatchMode you want to use for each command. ("Bet (..." needs mode1, "... Show?" needs mode2, "Fold" needs mode3) I've been playing with that, but it'll depend on which commands you want.

I'll post my script soon.
-Sam

MrMoo
11-08-2005, 12:59 PM
I guess it's a matter of preference. I prefer the behaviour associated with my original script. In my mind I want this to be like a video game. I want the d-pad to navigate to the table and the buttons to do my actions. I also want to minimize the buttons so that I don't accidentally misclick. With your example, you'll need to have seperate buttons for "Fold" and "Wait for BB". This in my mind increases the chance that you accidentally misclick and cause an undesired action. My script uses 3 buttons for the main actions; fold, check/call and bet/raise. These 3 buttons are the top 3 buttons on my gamepad. The associated commands are mapped relative to the button locations displayed on the Party window. So I don't have to be trained to use the gamepad. Fold is the far left button the screen, it's the far left button on my gamepad. Same with check/call and bet/raise. Fold can also be used for waiting for the BB and bet can be used to post immediately. The other minor buttons I have mapped are used for actions which if mistakenly pushed, will not cause an accidental action which will effect the current hand.

Lastly, I wanted to make this script easily modifiable for those who play on sites other than Party. Although I haven't looked into it, I made the assumption that finding, matching and modifying the code to identify different button strings would be more difficult for your average user than identifying pixel locations.

I certainly can't tell you whats best for you. If you prefer the other behaviour, I definitely encourage you to change whatever you need to make you happy.

Good luck.

oreopimp
11-08-2005, 02:08 PM
Any suggestions on a good Gamepad for the comp? And is this easy to modify to say Pokerstars or Absolute (is there an easy way to find the coordinates of where the buttons on those sites are at?)?

uncleshady
11-08-2005, 03:25 PM
I would be interested in a UB , Absolute, or Crypto AHK script if anybody has one. Thank you drive thru.

MrMoo
11-08-2005, 03:54 PM
I personally use a Saitek wireless. Not sure of the model number off hand. I chose this controller because it has 3 buttons across the top (to correspond with fold, check, and bet) and because it's wireless. Other controllers should work pretty easily with this script with little modification.

When you download and install AutoHotKey it will also install a program called I believe window spy. It will be in the same directory if you go to Start-&gt;Program Files-&gt;AutoHotKey. Run that program. Then open a poker window for your client of choice and move it to the very top left of your screen so the window is sitting at the pixel location 0,0. Then move the mouse down to where the call button is. If you look at the Windowspy window it will tell you the X and Y coordinates of where the mouse currently is. Repeat to get the x and y location for all the different buttons. You should then use these values to change the default values in the script under the "; Variables for the location of the different controls" section. You'll also need to get the height and width in pixels of a typical poker client window and change those values in the same section. Once you've done that, it should work with your poker client of choice.

pistolero
11-08-2005, 04:04 PM
[ QUOTE ]
Any suggestions on a good Gamepad for the comp? And is this easy to modify to say Pokerstars or Absolute (is there an easy way to find the coordinates of where the buttons on those sites are at?)?

[/ QUOTE ]

I use this (http://www.newegg.com/Product/Product.asp?Item=N82E16826127204). It's cheap and simple. The buttons on the front change the active table, the buttons on the right are for table action (bet/check/fold), and the analog joystick can be used as a mouse so you don't need to put it down and use the mouse for other things.

It's pretty easy to map someone's script to a new site, but Absolute is a pain in the ass. When a table requires your attention, it steals focus from the active window. (For the record, I tried the TweakUI method of getting around this and it didn't work for me.) So when taking action, if another table steals focus, you can (and I have) bet/raise/fold on the wrong table.

I've been thinking that I can change the script to only act on the table under tha mouse, but I haven't done it yet. Anyone have any other ideas?

MrMoo
11-08-2005, 04:12 PM
[ QUOTE ]

I've been thinking that I can change the script to only act on the table under tha mouse, but I haven't done it yet. Anyone have any other ideas?

[/ QUOTE ]

My script will do this. Just get the current location of the mouse, find the window under the mouse, then use WinActivate to activate that window.

SamIAm
11-08-2005, 04:15 PM
[ QUOTE ]
I guess it's a matter of preference.

[/ QUOTE ]Absolutely. I didn't want to imply that yours was "wrong". Your setup is intuitively about location, mine's about meaning. Let me explain:

My goal is to have 6 buttons. The top 3 are all actual play, the bottom 3 are for red-tape. So, they go
FOLD, CALL, RAISE
LEAVE, STAY, PLAY
So, FOLD is "fold now" if it's available, or "fold soon" otherwise. CALL is "call " if available, or "check" otherwise. And so on. Right now my list is:<ul type="square"> FOLD {fold (now &amp; in turn)}
CALL {call, check (now &amp; in turn)}
RAISE {bet, raise (now &amp; in turn)}
LEAVE {muck now?, sit out, muck uncalled?}
STAY {I'm back, wait for BB?}
PLAY {post, show, autopost?}[/list]I have cool code for "If 'Show Cards' button isn't visible, you must have meant 'Flip Autopost'." The problem is that the text isn't always unique. The "Fold in turn" box has the same text as the "Fold now" button. /images/graemlins/frown.gif Right now I just specify the widget by codename, but that could lead to miscommunication. ("Fold" and "Post+Dead" are both AfxWnd42s14.) Anybody know how to write "Select the SECOND widget with the text 'Fold'."?
-Sam

P.S. I have to admit that, because AHK is a new toy, my script starts by opening PTracker, Party, PAce, and MTH (if they're not open already), logs in to Party, and starts importing hands for PTracker. I can't really pretend it saves me all that much time, but it sure is cool lookin'. /images/graemlins/smile.gif

MrMoo
11-08-2005, 04:44 PM
I see what your saying. I think I was confused before. Great ideas.

I never even thought about having AHK opening poker tracker, poker ace, etc. I'll have to code that up tonight.

SamIAm
11-08-2005, 06:54 PM
[ QUOTE ]
I never even thought about having AHK opening poker tracker, poker ace, etc. I'll have to code that up tonight.

[/ QUOTE ]Here's my version, if you want it. If PTracker's already open, AHK asks if you want to start hand-import. (I couldn't figure-out how to tell whether the timer was already running or not.)
-Sam

[ QUOTE ]
SetTitleMatchMode, 1

;;PARTY;;
Process, Exist, partypoker.exe
if %ErrorLevel% = 0
{
Run, "C:\Program Files\PartyPoker\PartyPoker.exe"
WinWait, Welcome to the PartyPoker.com Lobby
WinWait, Login To PartyPoker.com
WinActivate, Login To PartyPoker.com
Send, {ENTER}
}

;;ALLSNAP;;
Process, Exist, allSnap.exe
if %ErrorLevel% = 0
{
Run, "C:\Program Files\allSnap\allSnap.exe"
}

;;POKERTRACKER;;
runPTImport := 1
Process, Exist, ptrack2.exe
if %ErrorLevel% = 0
{
Run, "C:\Program Files\Poker Tracker V2\ptrack2.exe"
WinWait, Poker Tracker
}
else
{
MsgBox ,4,Import Hands?,PokerTracker already running. Start Party hand-import?
IfMsgBox, No
{
runPTImport := 0
return
}
}
if runPTImport = 1
{
WinMenuSelectItem, Poker Tracker, , File, Auto-Import Party
WinWait, Poker Tracker
;PTracker says !s should start timer. It doesn't. /images/graemlins/frown.gif
Send {TAB}
Send {TAB}
Send {TAB}
Send {TAB}
Send {TAB}
Send {TAB}
Send {TAB}
Send {TAB}
Send {SPACE}
;Ditto on force-import. /images/graemlins/frown.gif
Send {TAB}
Send {SPACE}
}

;;POKERACE;;
Process, Exist, PAHud.exe
if %ErrorLevel% = 0
{
Run, "C:\Program Files\PokerAce Hud\PAHud.exe"
SetTitleMatchMode 3
}

;;MTH;;
Process, Exist, MTH.exe
if %ErrorLevel% = 0
{
Run, "C:\Program Files\MTH\MTH.exe"
}

[/ QUOTE ]

MrMoo
11-09-2005, 12:26 PM
Awesome. Thanks.

DrSavage
11-09-2005, 04:54 PM
To everyone who uses gamepads etc for poker:

One of the techniques poker sites use for bot detection is analyzing mouse clicks to see if they all land on the same spot on the button. PokerStars uses it for sure. It would be a good idea to add a random +/- few pixels off the button center just to save yourself some potential trouble of dealing with customer support.

SamIAm
11-09-2005, 06:13 PM
[ QUOTE ]
One of the techniques poker sites use for bot detection is analyzing mouse clicks

[/ QUOTE ]My script is going to look NOTHING like normal use. Hell, I'm not even sending "clicks" per se; I'm simply activating the correct widget. Even MrMoo's version is moving the mouse hundreds of pixels at a time w/o hitting any of the points in between.

We're not going to look like normal use. Luckily, we have nothing to hide. I know on Party they just pop-up the Bot Turing Test every once in a while. I'm not too worried.
-Sam

MrMoo
11-09-2005, 10:05 PM
Thanks for the heads up. I did actually think about this. Should the time come where Party or Stars complains, I'll change the code to support ranges. Until then, I'll remain the lazy bastard that I am. :-)

SamIAm
11-10-2005, 06:30 AM
Here's my current script for clicking. It assumes you're playing in the activated window and it only has actions I use. Changing either of those is trivial.

This code lets you specify a list of widgets for each hotkey. That key then clicks the first visible button in its list. So, you press alt-6, and it first looks for the "Post Blind" button. Failing to find that, it looks for the "Show Cards" button. Failing that, it looks for the "Autopost" checkbox. The order of the "newButton" commands specifies search-order. As I said, my button arrangement is:<ul type="square"> FOLD {fold (now &amp; in turn)}
CALL {call, check (now &amp; in turn)}
RAISE {bet, raise (now &amp; in turn)}
LEAVE {muck now?, sit out, muck uncalled?}
STAY {I'm back, wait for BB?}
PLAY {post, show, autopost?}[/list]but you can change it if you like.

<font class="small">Code:</font><hr /><pre>;FOLD = 1;
newButton("fold", 1, "AfxWnd42s14") ;(
newButton("checkFoldInTurn", 1, "AfxWnd42s20")
newButton("foldInTurn", 1, "AfxWnd42s19")
;CALL = 2;
newButton("call", 2, "Call (", 1)
newButton("check", 2, "AfxWnd42s15") ;(
newButton("cInTurn", 2, "AfxWnd42s21")
;RAISE = 3;
newButton("bet", 3, "Bet", 1)
newButton("raise", 3, "Raise ", 1)
newButton("r1InTurn", 3, "AfxWnd42s23")
;LEAVE = 4;
newButton("muckNow", 4, "Muck?", 2)
newButton("sitout", 4, "Sit Out")
newButton("muckInTurn", 4, "Muck Losing/Uncalled Hands")
;STAY = 5;
newButton("back", 5, "I am Back")
newButton("waitNow", 5, "AfxWnd42s16") ;(
newButton("waitInTurn", 5, "Wait for Big Blind")
;PLAY = 6;
newButton("post", 6, "Post", 1)
newButton("show", 6, "Show", 2)
newButton("autopost", 6, "Auto Post Blind")

!1::
clickVis(1)
return
!2::
clickVis(2)
return
!3::
clickVis(3)
return
!4::
clickVis(4)
return
!5::
clickVis(5)
return
!6::
clickVis(6)
return
!7::
debug()
return

debug()
{
local but, num, Output
but = 1
Loop
{
if(but &gt; numButtons)
break
num = 1
Loop
{
if(num &gt; numButtons%but%)
break
if(visible(but,num) = 1)
Output = % Output . names%but%x%num% . " is visible.`n"
num += 1
}
but += 1
}
MsgBox %Output%
}

clickVis(button)
{
local output, i, isVis, currString, currMatch
WinGetTitle, winTitle, A
i = 1
Loop
{
if(i &gt; numButtons%button%)
break
if (visible(button,i) = 1)
{
currMatch := matches%button%x%i%
SetTitleMatchMode, %currMatch%
currString := strings%button%x%i%
ControlClick, %currString%, %winTitle%
break
}
i += 1
}
}

visible(but, num)
{
local currentMatch, currentString
local output
currentMatch = % matches%but%x%num%
currentString = % strings%but%x%num%
SetTitleMatchMode % currentMatch
ControlGet, output, Visible, , %currentString%, %winTitle%
if output &lt;&gt; 1
{
output = 0
}
return output
}

newButton(name, button, string, match=3)
{
local buttonCount
numButtons += 1
numButtons%button% += 1
buttonCount := numButtons%button%
names%button%x%buttonCount% := name
matches%button%x%buttonCount% := match
strings%button%x%buttonCount% := string
}</pre><hr />

Right now, the only problem is pairs of widgets with the exact same text. "Fold In Turn" checkbox and "Fold Now" button both read "Fold", and I don't know how to differentiate. Ditto for "Check" and for "Wait for BB". I specify those 3 by their button-name (marked with a ";(" in the code), and it works ok. The only symptom is that AHK now thinks you have a "Fold" button whenever there's a left button, a "Check" whenever there's a middle, and a "Wait" whenever there's a right. This is already the situation with MrMoo's code, so it's clearly not SO bad. /images/graemlins/smile.gif I'd still like to know how to specify "The Second Widget With Text 'Fold'".

Note that there's nothing Party-specific about any of this. I imagine it could be adapted pretty damn easily for other sites, just by changing the "newButton" commands. I included a "debug" command, mapped to alt-7, which displays the list of currently visible buttons. That plus WindowSpy should be enough to script any poker-site.
-Sam

BigBrother
11-15-2005, 05:16 AM
I tried your AHK keyboard script, out-of-box. Pretty cool having the extra '4,5,6' buttons in addition to the 3 that Orca provided with MTH.

A couple things I noticed:

1) With MTH if you have the mouse outside the poker table (IE- browsing internet on side monitor) the hot keys still work at the active poker table.

With the AHK script the hot keys are not recognized since (presumably) the browsing behavior took the cursor outside the poker table. Then the only way to get the HotKey to work is to manually reposition the mouse to the active poker table first.

2) Pushing the '5' key is supposed to toggle back/away, but if action is on you at the active table, pushing '5' makes you 'RAISE' (As in I RAISED T3 from UTG).

SamIAm
11-15-2005, 10:17 AM
[ QUOTE ]
1) With MTH if you have the mouse outside the poker table (IE- browsing internet on side monitor) the hot keys still work at the active poker table.

With the AHK script the hot keys are not recognized since (presumably) the browsing behavior took the cursor outside the poker table. Then the only way to get the HotKey to work is to manually reposition the mouse to the active poker table first.

[/ QUOTE ]
Right. Sorry if this was confusing. I was using MTH to bring the mouse to the active table, so hitting the window under the mouse worked fine. Basically, if my hand was OFF the mouse, then MTH always brought me to the right table. If my hand was ON the mouse, I actually wanted to be able to coast around the screen, queueing action on my other tables. Not having to select them made this much easier.

[ QUOTE ]
2) Pushing the '5' key is supposed to toggle back/away, but if action is on you at the active table, pushing '5' makes you 'RAISE' (As in I RAISED T3 from UTG).

[/ QUOTE ]Yeah, this was the problem I mentioned at the end of my last post. There's no way to differentiate between the check-box that says "Wait for BB" and the push-button that says the same thing. This means I have to specify the push-button by it's internal name "AfxWnd42s16", and this is the same internal name as the raise button. /images/graemlins/frown.gif

That means this functionality is just like hitting via mouse-location, in a way. Because the "Wait for BB" is on the right and "Raise" is on the right, they'll act similar. It's lame. In fact, you could use "Fold", "Check", and "Wait for BB" to push the 3 buttons, since they'll hit whatever's in those locations. /images/graemlins/frown.gif

It seems nobody on this forum knows how to fix this problem, but maybe the AHK forums can help. I'll update this thread if I get any help there. Till then, the only time you'll get a bad hit is if you try to hit the "Wait for BB" button when you aren't away, and in fact have action. Sorry about your T3 utg. It's important to mix-up your play, anyway. /images/graemlins/smile.gif
-Sam

SamIAm
11-15-2005, 11:55 AM
[ QUOTE ]
That means this functionality is just like hitting via mouse-location, in a way. Because the "Wait for BB" is on the right and "Raise" is on the right, they'll act similar. It's lame.

[/ QUOTE ]P.S. I believe this is true of the MTH key setup, as well.

OrcaDK
11-15-2005, 01:39 PM
[ QUOTE ]
[ QUOTE ]
That means this functionality is just like hitting via mouse-location, in a way. Because the "Wait for BB" is on the right and "Raise" is on the right, they'll act similar. It's lame.

[/ QUOTE ]P.S. I believe this is true of the MTH key setup, as well.

[/ QUOTE ]

Nope, MTH doesn't click by mouse location, it doesn't interfere with the mouse at all. MTH locates the wanted button and directly sends system messages to simulate a click.

SamIAm
11-15-2005, 02:13 PM
[ QUOTE ]
Nope, MTH doesn't click by mouse location, it doesn't interfere with the mouse at all. MTH locates the wanted button and directly sends system messages to simulate a click.

[/ QUOTE ]Doh! Sorry, Orca! I didn't mean to malign the MTH script. /images/graemlins/smile.gif
-Sam

OrcaDK
11-15-2005, 02:27 PM
[ QUOTE ]
[ QUOTE ]
Nope, MTH doesn't click by mouse location, it doesn't interfere with the mouse at all. MTH locates the wanted button and directly sends system messages to simulate a click.

[/ QUOTE ]Doh! Sorry, Orca! I didn't mean to malign the MTH script. /images/graemlins/smile.gif
-Sam

[/ QUOTE ]

Np m8, just wanted to prevent any misunderstandings /images/graemlins/smile.gif

Big Limpin
11-15-2005, 03:31 PM
Yo, this thread seems liek the best place to compare scripts...heres what ive been using.

Its a slightly modified version of that "mouseless poker" one.

F1-fold (or checkfold)
F2-call (or preflop check)
F3- bet , midbet, modified by numpad entries, F3 to trigger
F4- push
Esc- clears bet box. rarely used, but sometimes after sitting out and returning, you have to reselect the bet entry box to type in bets...Esc just selects this field
4 arrow keys, move one table in the direction (i.e. NW to N using -&gt; )


;Clear Bet
Esc::
MouseClickDrag, left, 340, 440, 365, 440
Sleep, 50
return

; Fold
F1::
MouseClick, left, 300, 475
Sleep, 10
MouseClick, left, 300, 500
Sleep, 50
return

; Check/Call
F2::
MouseClick, left, 385, 475
Sleep, 50
MouseClick, left, 385, 500
Sleep, 50
return

; Bet/Raise
F3::
MouseClick, left, 550, 475
Sleep, 50
return

; Push
F4::
Send,99999
MouseClick, left, 550, 475
Sleep, 50
return


; WindowLeft
Left::
CoordMode, Mouse, Relative
MouseMove,-5,295
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
return

; WindowDown
Down::
CoordMode, Mouse, Relative
MouseMove,398,598
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
return

; WindowRight
Right::
CoordMode, Mouse, Relative
MouseMove,800,295
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
return

; WindowUp
Up::
CoordMode, Mouse, Relative
MouseMove,398,-17
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
return

boondoggle
11-15-2005, 10:59 PM
Why don't you change your post title to the more aptly named - bot pokerroom interface 101.

cheers
Boon

Nomad84
11-16-2005, 02:30 AM
[ QUOTE ]
Why don't you change your post title to the more aptly named - bot pokerroom interface 101.

cheers
Boon

[/ QUOTE ]

Because there are a lot of people here that play a lot of poker and prefer not to use a mouse to do it?

MrMoo
11-16-2005, 12:36 PM
Hi Boon,

Anyone with any intention of writing a bot would be calling windows API's directly to control the mouse/activate buttons. The only way someone could use an AHK script to aid them in writing a bot would be to have their bot code use the windows API's to call the joystick keys. Since this adds an extra step to the process it's entirely redundant.

The idea behind using AHK and a joystick is to minimalize the risk of developing RSI or to reduce the pain of those who already have it.

But thanks for taking the time to display your ignorance on a public forum.

Cheers,
Jason

jukofyork
01-27-2006, 12:27 AM
[ QUOTE ]
I don't know how to do this (yet). Pushing the "fold" button would be hard, because I don't know how to search for a button with given text. However, the "post" button would be even harder. It's text changes with the limit. We'd have to search for a button THAT CONTAINED the word "post". I expect that's at least a little harder.

[/ QUOTE ]

Sry I see its a fairly old post, but just wondered if you solved the problems u mentioned now?

I use something very similar, but written in C/C++. I then use AHK to do all the real work, and have it setup to work via keyboard, joy-pad and even now via a remote control.

Not sure in AHK, but to search for a 'window', use this win32 function: FindWindowEx() (or similar in AHK). This is what I use in my C/C++ code, but I don't know the equivalent for AHK (but somebody here might hopefully) /images/graemlins/smile.gif

Searching for prefixes like "Posts XXXX.XX", can be done via some recursive search using GetWindowText(), but again AHK may be able to do this.

Both of these used to be quite trivial using something called MacroScheduler, so why they are harder for AHK, I am not sure? /images/graemlins/smile.gif

Juk /images/graemlins/smile.gif

veganmav
02-21-2006, 07:25 AM
Did anyone ever modify this for absolute poker?

kurosh
02-25-2006, 12:26 AM
Is there any way to make the movements quicker? I hate waiting when I'm changing tables.

MrMoo
02-25-2006, 03:07 AM
You could change the "sleep 100" to a smaller number. You might run into some other problems though.

SamIAm
02-26-2006, 01:08 PM
[ QUOTE ]
You could change the "sleep 100" to a smaller number. You might run into some other problems though.

[/ QUOTE ]Isn't "Sleep 100" on tenth of a second? Or is it a whole second?
-Sam

roundhouse
02-26-2006, 04:34 PM
[ QUOTE ]

Right now, the only problem is pairs of widgets with the exact same text. "Fold In Turn" checkbox and "Fold Now" button both read "Fold", and I don't know how to differentiate. Ditto for "Check" and for "Wait for BB". I specify those 3 by their button-name (marked with a ";(" in the code), and it works ok. The only symptom is that AHK now thinks you have a "Fold" button whenever there's a left button, a "Check" whenever there's a middle, and a "Wait" whenever there's a right. This is already the situation with MrMoo's code, so it's clearly not SO bad. /images/graemlins/smile.gif I'd still like to know how to specify "The Second Widget With Text 'Fold'".

Note that there's nothing Party-specific about any of this. I imagine it could be adapted pretty damn easily for other sites, just by changing the "newButton" commands. I included a "debug" command, mapped to alt-7, which displays the list of currently visible buttons. That plus WindowSpy should be enough to script any poker-site.
-Sam

[/ QUOTE ]

Ok, I've just started playing around but my mapping of Party button names to widget (windows control) names goes like this:

Buttons available on your turn
Post SB | Post BB | Fold = AfxWnd4217
Check | Call = AfxWnd4218
Raise = AfxWnd4219

Buttons available out of turn
Fold = AfxWnd4222
Check/Fold = AfxWnd4223
Check | Call = AfxWnd4224
CallAny = AfxWnd4225
Raise = AfxWnd4226
RaiseAny = AfxWnd4227

I'm experimenting with the code along the following lines

<font class="small">Code:</font><hr /><pre>
^Down::
ControlClick, AfxWnd4217, %TableName% ; Ctrl-Down clicks Fold button
Return

^Right::
ControlClick, Afxwnd4218, %TableName% ; Ctrl-Right clicks Check/Call button
Return

^Up::
ControlClick, Afxwnd4218, %TableName% ; Ctrl-Up clicks Raise button
Return
</pre><hr />

Seems to work fine so far, though like I said I've only just started experimenting.

Cheers,
RH