Open Side Menu Go to the Top
Register
PokerPad - AHK hotkey script PokerPad - AHK hotkey script

10-16-2007 , 08:16 PM
@Dave

OK, here are the functions for creating a window capture, getting pixels from the window capture and deleting the window capture:

<font class="small">Code:</font><hr /><pre>/* Usage:
* Creates an offscreen capture of a window. The window cannot be minimized but may be invisible.
* Parameters:
* id: The window's id of which to create a capture
* device, context, pixels: Blank variables, see Releasing Memory below.
* Releasing Memory:
* After the capture is no longer needed, it's memory must be freed by calling Display_DeleteWindowCapture(device, context, pixels)
* where the 3 parameters are those that was passed to create the window capture.
*/
Display_CreateWindowCapture(ByRef device, ByRef context, ByRef pixels, ByRef id = "") {
if !id
WinGet, id, ID
device := DllCall("GetDC", UInt, id)
context := DllCall("gdi32.dll\CreateCompatibleDC", UInt, device)
WinGetPos, , , w, h, ahk_id %id%
pixels := DllCall("gdi32.dll\CreateCompatibleBitmap", UInt, device, Int, w, Int, h)
DllCall("gdi32.dll\SelectObject", UInt, context, UInt, pixels)
DllCall("PrintWindow", "UInt", id, UInt, context, UInt, 0)
; TODO: error checking, return true if succeeded
}

Display_DeleteWindowCapture(ByRef device, ByRef context, ByRef pixels) {
DllCall("gdi32.dll\ReleaseDC", UInt, device)
DllCall("gdi32.dll\DeleteDC", UInt, context)
DllCall("gdi32.dll\DeleteObject", UInt, pixels)
}


/* Usage:
* Gets the pixel from a window capture created from Display_CreateWindowCapture
* Parameters:
* context: the device context as given by Display_CreateWindowCapture
* x, y: the coordinate parameters
* Return:
* The pixel in RGB format.
*/
Display_GetPixel(ByRef context, x, y) {
return DllCall("GetPixel", UInt, context, Int, x, Int, y)
}</pre><hr />

They are now in a file called Display.ahk hence the Display_ prefix on each function name.

The only major changes I've made is restricting the size of the buffer to the size of the window (as opposed to the monitor size - it may even be possible to have a window larger than the monitor size and I don't know what kinds of fun that could pop up...) And also the use of ReleaseDC instead of DeleteDC. From what I've read, you are suppose to call ReleaseDC after you are finished with what is returned from the GetDC call (which I believe is the screen display device context hence my calling it "device"). I hope this is correct.

I have converted everything in PokerPad 0.1.5 (not yet released) to use these functions instead of reading from the screen and everything seems to work as before (This usually scares me into thinking I really didn't change anything! Usually something gets screwed up and nothing works anymore LOL).
PokerPad - AHK hotkey script Quote
10-16-2007 , 10:52 PM
This looks much cleaner than the stuff I emailed you Awesome.

Quote:

restricting the size of the buffer to the size of the window

Required - a cheapo hack I just put in there because it was enough for testing at the time

Quote:

also the use of ReleaseDC instead of DeleteDC.

I'll have to read up on this, but I think you are correct. All I know is that without the DeleteDC commands, it stops working after a while (running out of GDI resources imo). What you say rings a bell - but it is &gt;3 years since I did any C++ Win32-GDI coding, so I need to check. I *think* DeleteDC does enough to free the resources - but it certainly can't hurt to ReleaseDC too.

Another thisn - not mentioned above, but in your email - about the PrintWindow options:

Either the documentation or the function is backwards

0 provides ClientOnly, 1 adds AFAICT borders (but not caption) to the captured DC.

Quote:

I have converted everything in PokerPad 0.1.5 (not yet released) to use these functions instead of reading from the screen and everything seems to work as before (This usually scares me into thinking I really didn't change anything!

Fantastic

You can be sur using these functions it is using the PrintWindow method - so if it all continues to work without noticable difference - sweet

I am halfway thru converting BetPot to use these (with ImageMatch also) ... about to fall asleep


You don't use ity in the above functions, but there MUST be a better way of adding a +/- for "Shades of variation" than my crapola method of SetFormat -&gt; StringMid -&gt; add/subtract -&gt;recombine Hex - SetFormat, which I'm sure is horrific but works.

I guess The Binary / BitShift operators, but hose confuse me no end

dave.
PokerPad - AHK hotkey script Quote
10-17-2007 , 09:14 AM
Quote:
I'll have to read up on this, but I think you are correct. All I know is that without the DeleteDC commands, it stops working after a while (running out of GDI resources imo). What you say rings a bell - but it is &gt;3 years since I did any C++ Win32-GDI coding, so I need to check. I *think* DeleteDC does enough to free the resources - but it certainly can't hurt to ReleaseDC too.
I don't use DeleteDC on the device handle at all (That returned from the GetDC call). It is my understanding that you only delete things you create, therefore you are not suppose to delete 'device', but as the 'context' and 'pixels' are created, those must be deleted.

Quote:
Another thisn - not mentioned above, but in your email - about the PrintWindow options:

Either the documentation or the function is backwards
The documentation never specified what the values are, but 0 works whereas 1 doesn't so I use 0

Quote:
You can be sur using these functions it is using the PrintWindow method - so if it all continues to work without noticable difference - sweet
Only noticeable difference was after benchmarking the two OCR methods (screen reading and print window), the print window method was 5x faster There seems to be quite a bottleneck somewhere in getting each pixel from the screen.

Quote:
You don't use ity in the above functions, but there MUST be a better way of adding a +/- for "Shades of variation" than my crapola method of SetFormat -&gt; StringMid -&gt; add/subtract -&gt;recombine Hex - SetFormat, which I'm sure is horrific but works.

I guess The Binary / BitShift operators, but hose confuse me no end
You are correct. Here is the function I use:

<font class="small">Code:</font><hr /><pre>Display_CompareColors(ByRef bgr1, ByRef bgr2, ByRef variation) {
c1 := bgr1 &amp; 0xff
c2 := bgr2 &amp; 0xff
if (abs(c1 - c2) &gt; variation)
return false
c1 := (bgr1 &gt;&gt; 8) &amp; 0xff
c2 := (bgr2 &gt;&gt; 8) &amp; 0xff
if (abs(c1 - c2) &gt; variation)
return false
c1 := (bgr1 &gt;&gt; 16) &amp; 0xff
c2 := (bgr2 &gt;&gt; 16) &amp; 0xff
if (abs(c1 - c2) &gt; variation)
return false
return true
}</pre><hr />

Just ignore the fact that the parameters say bgr1 and bgr2, as RGB format works just as well. The bgr names are just an artifact from screen reading which returns the values in BGR format.

Also, besides the Display_ReadArea function, I also made the following pixel search function:

<font class="small">Code:</font><hr /><pre>/* Usage:
* Searches for the specifed color in the given rectangle of a window capture created from Display_CreateWindowCapture
* Parameters:
* id: either a window id or the letter c followed by the device context handle as given by Display_CreateWindowCapture
* x, y, w, h: the rectangle parameters
* color: the color in RGB format
* variation: the allowed variation from the specified color
* Return:
* Returns true if the specified color/variation is found within the given area, false otherwise.
*/
Display_PixelSearch(x, y, w, h, color, variation, ByRef id = "") {
if !id
Display_CreateWindowCapture(device, context, pixels)
else if (SubStr(id, 1, 1) = "c")
context := SubStr(id, 2)
else
Display_CreateWindowCapture(device, context, pixels, id)
Loop, %w% {
j := y
Loop, %h% {
rgb := Display_GetPixel(context, x, j++)
if Display_CompareColors(rgb, color, variation) {
if device
Display_DeleteWindowCapture(device, context, pixels)
return true
}
}
x++
}
if device
Display_DeleteWindowCapture(device, context, pixels)
return false
}</pre><hr />
PokerPad - AHK hotkey script Quote
10-17-2007 , 07:16 PM
Version 0.1.5 is now available.

For the most part, screen reading has been removed (except for situations where just 1 pixel needs to be checked on the active table). The new methods contributed by _dave_ are used which allow accurate reading even if the window is partially covered by another window.

The other major change is that checkboxes are now handled correctly. Use the same hotkey as fold/call/raise to click the top checkbox and use Ctrl + {hotkey} to click the bottom checkbox. If Ctrl is not used and the top checkbox is not present but the bottom checkbox is, then the bottom checkbox will be clicked in that scenario without use of the Ctrl key.

Also, the old Timers.ahk add-on will not work with PokerPad 0.1.5 or higher, however, the latest Timers.ahk (version 0.2) has been updated which uses the new methods mentioned above and will only work with PokerPad 0.1.5 or higher.

As always download is available here:
http://www.autohotkey.net/~Xander/PokerPad/
PokerPad - AHK hotkey script Quote
10-20-2007 , 12:55 AM
Version 0.1.6 has been updated with a total overhaul of the pot bet calculations. They should now be accurate for all window sizes. The only time they won't be accurate is when you have placed a bet and the pot has been reraised two times before action comes back to you. The script can't tell if it was a single raise or multiple raises...

Also fixed the colors changed in 0.1.5 which rendered some hotkeys useless.
PokerPad - AHK hotkey script Quote
10-20-2007 , 03:39 AM
Can you please consider Everest for this, there are no Auto hotkeys that work there and the betting setup is a nightmare for multi tabling.
PokerPad - AHK hotkey script Quote
10-20-2007 , 11:21 AM
OK, I will have a crack at it and see what I can come up with.
PokerPad - AHK hotkey script Quote
10-20-2007 , 07:59 PM
I tried this out today. Great work and thanks.

I use an external USB keypad with my laptop and the fold/call/raise buttons work fine as does the direct write to the bet amount window if numlock is pressed. But none of the x pot bets work at all. My numpad works fine in a text window (i,e, numpadhome, etc do what you would expect).

Do you have any ideas on what I need to do to fix this?

p.s. I didn't see this mentioned here in the thread, but pokerpad seems to work flawlessly with TableNavigator (and I disabled TableNav to double check that wasn't what was screwing up the pot bet commands)
PokerPad - AHK hotkey script Quote
10-20-2007 , 10:27 PM
Quote:
I use an external USB keypad with my laptop and the fold/call/raise buttons work fine as does the direct write to the bet amount window if numlock is pressed. But none of the x pot bets work at all. My numpad works fine in a text window (i,e, numpadhome, etc do what you would expect).

Do you have any ideas on what I need to do to fix this?
What site does it not work for? Some possible problems could arise if:

1) On Full Tilt, if the button images have been changed.
2) On Poker Stars, if the theme isn't Classic (other themes can be supported by editing the PokerPad.ini file)
3) On iPoker, if the theme isn't Titan (again, other sites can be supported by editing the PokerPad.ini file)

Also, it is possible that some window sizes may not be read properly. You can try resizing the table to the smallest size (this size should always work) and see if you still have problems. If this fixes your problem, just tell me which table size is not working (and for which site) and I'll fix it.

Quote:
p.s. I didn't see this mentioned here in the thread, but pokerpad seems to work flawlessly with TableNavigator (and I disabled TableNav to double check that wasn't what was screwing up the pot bet commands)
Good to know it works with TableNavigator. I added support for it awhile back but couldn't test if it really did work as I don't have TableNavigator configured to even work
PokerPad - AHK hotkey script Quote
10-20-2007 , 11:54 PM
I tihnk what might be happening is that the script thinks the external keypad buttons are the same as the regular keyboard buttons for pageup and pagedown for example.

When I switched to the PS default theme (was using hypersimple) I was able to move the slider using "3" and "9" on the keyppad for example. Before I was able to type numbers in the betting window, but this didn't seem to work anymore.

I noticed a couple times I would get an auto-rebuy to using my keypad.

Maybe this is dumb, but is it possible that there is a setting for laptop vs desktop keyboard? Or should I just be thinking about editing the hotkeys onto my laptop keyboard instead of the external keypad?

I'll try deleting the commands for the slider and rebuy and see if the pot bets work. Seems like that might be a possibility.

Another question I have is whether I can enter gamepad commands for my hotkeys. Is there a way to specify button 1, etc, for the various betting actions?
PokerPad - AHK hotkey script Quote
10-21-2007 , 12:17 AM
Quote:
Maybe this is dumb, but is it possible that there is a setting for laptop vs desktop keyboard?
This has been requested before. Unfortunately no one has specified which keys should correspond to which actions for a laptop keyboard...

Quote:
Or should I just be thinking about editing the hotkeys onto my laptop keyboard instead of the external keypad?
You can edit the hotkeys by right clicking the tray icon and selecting Hotkeys...

Quote:
I'll try deleting the commands for the slider and rebuy and see if the pot bets work. Seems like that might be a possibility.
Should have no effect as the keys that map to the pot bets are Numpad specific. You'd be better off changing the hotkeys manually by following the directions above.

Quote:
Another question I have is whether I can enter gamepad commands for my hotkeys. Is there a way to specify button 1, etc, for the various betting actions?
Yes, you can find the appropriate names here: http://www.autohotkey.com/docs/KeyList.htm. I believe gamepads would use the Joystick names listed on that page. In the Hotkeys window where you edit the hotkeys, you would put in the text field Joy1 for example.
PokerPad - AHK hotkey script Quote
10-21-2007 , 12:19 AM
Thanks again. It looks like I have a little experimenting to do.
PokerPad - AHK hotkey script Quote
10-21-2007 , 02:08 AM
Quote:
OK, I will have a crack at it and see what I can come up with.
Great thanks, I have plenty of HH's, 6 max and FR if you want some.
PokerPad - AHK hotkey script Quote
10-21-2007 , 07:23 AM
HH's shouldn't be necessary. For the most part, I just need to borrow from functions already written for Poker Stars and to some extent iPoker. The only real new function is calculating the small blind from the big blind as only the big blind is displayed in the window title. I believe 0.15/0.25 is the only one that you can't just divide the big blind by 2, correct?
PokerPad - AHK hotkey script Quote
10-21-2007 , 08:17 AM
Quote:
HH's shouldn't be necessary. For the most part, I just need to borrow from functions already written for Poker Stars and to some extent iPoker. The only real new function is calculating the small blind from the big blind as only the big blind is displayed in the window title. I believe 0.15/0.25 is the only one that you can't just divide the big blind by 2, correct?
Yes, only 25nl is like that.
PokerPad - AHK hotkey script Quote
10-22-2007 , 08:37 AM
The Full Tilt timer function is pressed when the time button appears. When I play HU this means that I press the time button almost every time it's my turn to act. (At least post flop). Would it be possible for the script to wait until the normal time is nearly up, and then pressing the time button ?

I think in some cases the way it works now causes me to "use up" some of the timebank seconds when I don't have to.

Thanks again for a great script Xanderz
PokerPad - AHK hotkey script Quote
10-22-2007 , 04:40 PM
The new timer script (version 0.2) checks the timers every 5 seconds which could occationally click the timer right when it appears, but usually will delay about 3 seconds. The old script checked every second. If you want to still use the old script, you can edit the SetTimer delay to have the timers check at a different interval. (1000 is 1 second as it is measured in milliseconds).

Either way, no time should be taken off just for clicking the timer. The timer doesn't start until all your remaining time has expired.
PokerPad - AHK hotkey script Quote
10-24-2007 , 12:16 PM
Xanderz,
I have been trying your script out on Party but I can't get it to bet pot preflop. It bets .75 at 25NL, so I tested at 10NL figuring it might be the blind size but I get .30 there. I tried the 1.5x button and that gave me .50. How does the Random Bet button work, am I able to create a 1 1/4 key to see what figure that creates?
PokerPad - AHK hotkey script Quote
10-24-2007 , 01:45 PM
Quote:
Xanderz,
I have been trying your script out on Party but I can't get it to bet pot preflop. It bets .75 at 25NL, so I tested at 10NL figuring it might be the blind size but I get .30 there. I tried the 1.5x button and that gave me .50.
Couple things, I don't know if the first is a result of the update or not but it wasn't reading the raise button correctly. Also, the calculation wasn't correct if you are first to act postflop or if you were on the big blind preflop.

I have fixed both, but haven't tested that the fix actually works yet.

These fixes as well as support for Everest should be up today or tomorrow.

Quote:
How does the Random Bet button work, am I able to create a 1 1/4 key to see what figure that creates?
Random Bet gets a factor between 0.25 and 1 to multiply the pot by...

You could edit the script to use your own factors. But there isn't just one place to edit it. You'd have to edit for each site. I'll add in the options window the ability to set your own factors in the future.
PokerPad - AHK hotkey script Quote
10-24-2007 , 08:44 PM
Quote:


These fixes as well as support for Everest should be up today or tomorrow.
Wow, this is going to be popular on Everest, I've made some pretty crazy bets there in the past trying to type my bet in, the hardest part at times seems to be clearing the text from the box, never seems to want to let you erase what is automatically there.


Quote:
How does the Random Bet button work, am I able to create a 1 1/4 key to see what figure that creates?
Random Bet gets a factor between 0.25 and 1 to multiply the pot by...

You could edit the script to use your own factors. But there isn't just one place to edit it. You'd have to edit for each site. I'll add in the options window the ability to set your own factors in the future.

[/quote]

Sounds great. Thanks so much for adding the Everest support
PokerPad - AHK hotkey script Quote
10-25-2007 , 08:41 PM
Version 0.1.7 is now available.

There are many updates/improvements from 0.1.6, see the change log for a list of all of them.

The major updates are support for Everest Poker and an internal improvment of how text is read from windows.

Download here: http://www.autohotkey.net/~Xander/PokerPad/

Also, I may need volunteers with real money on Poker Stars, iPoker or Everest Poker if the $ sign is not being read correctly (for instance it is read as an 8 thereby completely throwing off pot bets...
PokerPad - AHK hotkey script Quote
10-25-2007 , 09:48 PM
Xanderz,
Had a go at Empire/Party but they went down for maintenance. The preflop betting(tried 10nl and 25nl) seemed to be a lot better (.80 first in 25nl .35 10nl- $1.10 behind a limper at 25nl) but betting on all streets after was usually about 4 times the bet eg wanted to bet $2.25, got around $10- this was using bet rounding set to small blind and big blind, these postflop bets were working fine for me before the upgrade set on relative bet rounding at this site- didn't get to play long enough to try relative bet rounding however. Will go back later.

Plenty of things working on Everest- sit out, post, reload to max buy and clear bet box and they are the worst things about the site so that was great. Betting buttons at 25nl giving bets like $115 and $415.25 etc. Didn't get any normal bet amounts. Increase/decrease bet using wheel up/ wheel down working great.

I am using the black background on Everest if that is of any consequence.
PokerPad - AHK hotkey script Quote
10-25-2007 , 10:16 PM
Quote:
Xanderz,
Had a go at Empire/Party but they went down for maintenance. The preflop betting(tried 10nl and 25nl) seemed to be a lot better (.80 first in 25nl .35 10nl- $1.10 behind a limper at 25nl) but betting on all streets after was usually about 4 times the bet eg wanted to bet $2.25, got around $10- this was using bet rounding set to small blind and big blind, these postflop bets were working fine for me before the upgrade set on relative bet rounding at this site- didn't get to play long enough to try relative bet rounding however. Will go back later.
I didn't get time to do much testing on Party and now I can't seem to stay connected to their server :/ I'll take a look at what is going on as soon as I can play there.

Quote:
Betting buttons at 25nl giving bets like $115 and $415.25 etc. Didn't get any normal bet amounts. Increase/decrease bet using wheel up/ wheel down working great.
I was afraid of this. I don't have real money on there so I can't test if the $ signs are being read correctly. If you are willing, I will send an alternate version that will determine the correct mappings for the $ sign. The amount of work on your part should be minimal. Essentially, there is just an extra hotkey that sets the bet amount to some random amount and then reads the raise button and if the amounts don't match, they will be saved to a file. It keeps doing this until you press another hotkey that stops it. That is pretty much how I get the mappings except I will have to write the saving to file part (so that you can just send the file via email).

Quote:
I am using the black background on Everest if that is of any consequence.
That is the background I set it to. Any background should be ok as long as it doesn't have green or yellow in it near the buttons.
PokerPad - AHK hotkey script Quote
10-25-2007 , 10:33 PM
Sent pm.
PokerPad - AHK hotkey script Quote
10-25-2007 , 11:13 PM
Xanderz,

Ok, having a bit more luck, Party/ Empire seems to be going fine, I reset my keys and used relative- I'm not sure why but I was changing the keys and the changes weren't saving. On Evereset I think the only problem might be that the decimal point is not there, but the amount might be right if there were a decimal point there, I'm on 10nl waiting for a hand I'm will to shove with to test it out.
PokerPad - AHK hotkey script Quote

      
m