|
Creating Basic AHK Scripts for Pokerz
Props to Rage and Nakamura for the epic post A Beginner's Guide to Multitabling. They used AutoHotKey to program a couple of VERY nice table management scripts, which got me thinking.
I don't like the idea of paying $50 for something like Table Ninja, not because I don't think it's worth - it probably is. I just see all these software updates and messages in their support forums about the software not working after the latest FTP or Starz update. And the sites are always updating their stuff.
What if we can get some bare bones functionality for free in a script we write ourselves? AHK is great at pointing and clicking, so I made some betting scripts to go with Naka's and Rage's scripts which I use every time I play. Which brings me to the whole freakin' point:
Writing your own AHK script is easy
Step 1: Download AHK installer here.
Step 2: Install it.
Step 3: Create a blank text document in TextPad, or whatever plain text editor you'd like.
Step 4: Save the *.txt file as Temp.ahk. Windows will complain about file extension change, but say it's OK.
Step 5: Right click on the Temp file, and select edit. Make a simple script like the screen shot below.
Step 6: Save the file. Then Right click on it, and select "Run Script." A new tab will open in your default web browser and the main FTR forum screen will load.
Congrats, you've written an AHK script!
They call it AutoHOTKEY for a reason
Notice the Square Green "H" Icon in the system tray? That's your signal the script is active. Now change the single line of code to:
__________
^F::Run http://www.flopturnriver.com/phpBB2/forum/
__________
Save it. Right click on the Green "H" try icon and select "Reload this script." Nothing happens, but now press
Ctrl + F
and voila, a new FTR forum tab appears in your browser. By the way, this command also opens your browser if it's not already. Here's the most common hotkey prefixes:
^ [Control] button
+ [Shift] button
! [Alt] button
# [Windows] button
This script would make Ctrl + Shift + F a hotkey:
__________
^+F::Run http://www.flopturnriver.com/phpBB2/forum/
__________
A super basic betting script.
Preflop, mashing the ol' bet pot button produces a 3.5 BB + 1 BB / limper open-raise. The following script makes the middle "mouse wheel" button a hotkey that will auto open on default-sized tables at Full Tilt.
__________
MButton::
Click 750,450
Click 750,550
return
__________
WTF? you say. Well, the Click command simply moves the mouse to the specified coordinates in the active window and left-clicks. The "return" command closes the multiple steps in the script.
So where do the coordinates come from? We have to use WindowSpy. Right click on the Green "H" tray icon, and open the Spy. Then hover your mouse over any open window and the Spy gives you details about all sorts of stuff. We'll look for the coordinates. I opened a Full Tilt 2nl game using FTP's default size, so the script should work for you on Tilt if you resize your windows to default. Two screen shots below show I got the coordinates so you can use any size and table layouts you wish. Just make sure all your tables are the same size.
During game play, FTP activates a table. Hero moves the cursor over the active table and clicks the mouse wheel button. FTP registers a 3.5 BB opening bet, and you're on to your next table.
In this screenshot, my mouse is hovering on the "o" on the [POT] button. You can see the coordinates in the WindowSpy are roughly (750,450).
Here, I'm hovering on the [BET] button. You can see the coordinates in the WindowSpy are roughly (750,550) or about 100 pixels further down.
More betting script tips
For reasons I won't delve into, using the simple click command is clunky. You can see each cursor movement and click. This speeds it up noticeably making for seamless action on your tables.
__________
MButton::
SendInput {Click 750,450}
SendInput {Click 750,550}
return
__________
All right, I don't play default-sized tables since I have a small monitor. From now on, the coordinates I'll use are the ones I use on my tables. I hover over the fold button (been playing lots of full nit recently), so adding this line to my script moves the cursor back over the Fold button for me:
__________
MButton::
SendInput {Click 750,450}
SendInput {Click 750,550}
SendInput {Click 480,480,0}
return
__________
The "0" after the coordinates moves the cursor but does NOT click. Here's the game play action: I'm fold-fold-folding oh wait big slick! I press the mouse wheel button for my standard open and get back to fold-folding without moving the mouse at all since the script repositions the cursor after clicking. The SendInput version is so fast, you'll have to test it a while before you trust it. I suggest 2nl until you're happy with how it works.
Here's a script that changes the auto-open to 3 BB since many of us open for a bit less on the button:
__________
^MButton::
SendInput {Click 660,400}
SendInput {Click 660,420,0}
SendInput {WheelDown}
SendInput {Click 660,480}
SendInput {Click 480,480,0}
return
__________
The two new lines are in bold. The first makes the cursor hover in the betting dialog box so that the mouse wheel can increase or decrease the bet amount. The second new line moves the mouse wheel down one click. (You have to make sure your betting preferences are set in the FTP lobby to increment the bet by 1 BB when you roll the mouse wheel, or this script won't work.)
Replace the word "Down" with the word "Up," choose a new hotkey, and you have a script that will auto-open 4 BB for you. I use this one when I'm in the SB and make the first raise.
Warning! I haven't tested this one, yet, as my kids aren't in bed. But it SHOULD work!! I'll report back later after testing, but this bets a specific amount, in this case, $3. That's a pretty common flop cbet amount for me, so I'm making it's hotkey Ctrl + RightClick:
__________
^RButton::
SendInput {Click 660,400}
SendInput {Click 675,415,2}
SendInput 3.00
SendInput {Click 660,480,0}
return
__________
If you delete the ",0" in the 2nd to last line, this script would actually bet $3 for you. As it's written, it puts $3 in the betting text input box and moves the cursor over the [BET] button. If I'm happy with that amount, I can simply click myself. Otherwise, I can use the mouse wheel to increment the bet up or down.
Managing all the hotkeys
A single script file can set several hotkeys at once. Below is the entire script file that sets the following hot keys:
Mouse Wheel Button => auto-open 3.5
Ctrl + Mouse Wheel Button => auto-open 3.0
Shit + Mouse Wheel Button => auto-open 4.0
Ctrl + Right Click => Bet $3
Shift + Right Click => Bet $5
__________
MButton::
SendInput {Click 660,400}
SendInput {Click 660,480}
SendInput {Click 480,480,0}
return
^MButton::
SendInput {Click 660,400}
SendInput {Click 660,420,0}
SendInput {WheelDown}
SendInput {Click 660,480}
SendInput {Click 480,480,0}
return
+MButton::
SendInput {Click 660,400}
SendInput {Click 660,420,0}
SendInput {WheelUP}
SendInput {Click 660,480}
SendInput {Click 480,480,0}
return
^RButton::
SendInput {Click 660,400}
SendInput {Click 675,415,2}
SendInput 3
SendInput {Click 660,480,0}
return
+RButton::
SendInput {Click 660,400}
SendInput {Click 675,415,2}
SendInput 5
SendInput {Click 660,480,0}
return
__________
I working on some more stuff which I'll post below.
In conclusion, I'll just mention I'm an AHK noobie. Lots of folks on FTR did sick things with AHK before now. I linked to Rage's work above. Spoony uses some scripts for mapping Playstation controller keys to poker actions on Stars, and HalvSame wrote a script Custom Script BigPotGrabber to grab the HH's for "big" pots, which ISF loved.
So I'm not the expert. I just posted this due to a conversation that started in my operation thread. I searched and didn't find a "poker scripting basics" thread on FTR, so I thought I'd make one. If someone else has already done something, I would appreciate the link. Anyone
interested in learning more advanced scripting should practice some of these basics and then check out the tutorials on AutoHotKey.com.
|