Hey People,
I have the following script on UB that buy in automaticcily.
But i want that the script auto rebuys all the time when i
am playing.
Does anybody know what i must change?
Here is mine script
/**
* Rebuy script for Absolute and UltimateBet.
*
* Edit the DESIRED_STACK_SIZE variable to define
* how much to rebuy, in big blinds. The default
* is 100 big blinds.
* If you use the "Top" table view on UB, change the
* VIEW variable to from "CLASSIC" to "TOP.
* Press F1 to rebuy on the table under the mouse.
* The script also has an auto-buyin option (set AUTO_BUY_IN to 1 to enable).
* If you are having problems with this script, set LOGGING
* to 1, do some rebuys, and send me the log file.
*
* USE AT YOUR OWN RISK.
*
* Date: 8:01 PM Friday, November 20, 2009
* AHK Version: 1.0.48.05
* Author: Roland (roland@overcards.com)
* Wiki page:
http://www.overcards.com/wiki/moin.c...oRebuyAbsolute
*
* --- Changelog ---
* @11:29 AM Saturday, November 21, 2009:
* • Adjusted y-coord so it won't click on Replay instead of Options.
* @2:46 PM Monday, November 23, 2009:
* • Fixed bug with recognising amounts over $1000 due to comma
* • Added (optional) logging. Set variable LOGGING to 1 to enable.
* @5:45 PM Monday, November 23, 2009:
* • Added auto-buyin option. Set AUTO_BUY_IN to 1 to enable.
* @8:30 PM Tuesday, November 24, 2009
* • Added auto-closing for the Alert pop-up when sitting down
* @4:18 PM Friday, November 27, 2009:
* • If the Options dialog doesn't appear, the script will click
* again every 250 ms for 1 second.
* @9:16 PM Friday, November 27, 2009:
* • Fixed problem that occured when other table popped up during rebuy.
* @9:43 AM Monday, November 30, 2009:
* • Close the "Additional chips will be available..." popup after rebuying.
* @10:51 AM Tuesday, December 01, 2009:
* • Added logging to record info when table under mouse is not AP/UB table.
* @9:09 PM Tuesday, December 01, 2009
* • Improved logging and made some slight changes to improve reliability.
* @7:32 PM Sunday, December 06, 2009:
* • Added check to ensure script is run as administrator
* @2:25 PM Monday, December 14, 2009:
* • When logging is turned on, the script now displays a tooltip when
* starting a rebuy. This can help detect situations where the hotkey
* has been overridden by another program.
*/
; ##### SETTINGS #####
; edit this:
DESIRED_STACK_SIZE:=100
; change to "TOP" if needed:
VIEW:="CLASSIC"
; change to 1 to auto-buy in:
AUTO_BUY_IN:=1
; change to 1 to enable logging
LOGGING:=0
; ##### /SETTINGS #####
#NoEnv
#SingleInstance force
SetWorkingDir %a_scriptDir%
SendMode Input
CoordMode, Mouse, Screen
SetDefaultMouseSpeed 0
; make sure it's run as administrator
if !A_IsAdmin {
msgbox, 49, AP/UB AutoRebuy,
( LTrim join`n
This script needs to be run as an administrator, otherwise it won't work properly.
Would you like to run it as an administrator now?
)
IfMsgBox, OK
DllCall("shell32\ShellExecuteA", uint, 0, str, "RunAs", str, A_AhkPath
, str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1)
exitApp
}
log("`n`n================== v1.10 ========================`n")
log("DESIRED_STACK_SIZE: " DESIRED_STACK_SIZE "`n")
; window classes (same at Absolute and UB)
TABLE_WINDOW_CLASS:="DxWndClass"
POPUP_WINDOW_CLASS:="DXPopupWnd"
if AUTO_BUY_IN
gosub autoBuyIn
return
; ===================
; change the hotkey to your liking
F12::
; not sure if "Critical" is neccessary, but make sure the
; auto-buy in loop can't interrupt and see the buy-in
; window and think it's an initial buy-in rather than
; a rebuy
Critical
MouseGetPos,,, win
rebuy(win)
return
; ===================
; simply runs in a loop, waiting for
; buy-in dialogs, and buying in when it
; sees one
autoBuyIn:
Loop {
WinWait, Alert ahk_class%POPUP_WINDOW_CLASS%, Security Notice - Do not divulge
loop 10 { ; make 10 attemps at closing the window, to be safe
ControlClick, Button1
WinWaitClose,,, 0.5
ifEqual, ErrorLevel, 0, break ; we closed it
} ifEqual, ErrorLevel, 1, continue ; couldn't close Alert window
WinWait, Buy chips ahk_class%POPUP_WINDOW_CLASS%,, 3 ; wait for the buy in window
ifNotEqual, ErrorLevel, 0, continue ; something went wrong
Sleep 250
buyIn(WinExist())
}
return
; ===================
/**
* Rebuys at Absolute or UltimateBet for
* DESIRED_STACK_SIZE*bigBlind.
*
* @param win <hwnd> The window handle of the
* table to rebuy on.
*/
rebuy(win) {
global DESIRED_STACK_SIZE, VIEW, TABLE_WINDOW_CLASS, POPUP_WINDOW_CLASS, LOGGING
WinExist("ahk_id" win) ; set LFW
WinGetTitle, title
if LOGGING {
Tooltip Starting rebuy...
SetTimer, tooltipOff, -1000
}
log("`nStarting rebuy... [Window title=" title)
WinGetClass, class
; not an absolute/ultimate table:
ifNotEqual, class, % TABLE_WINDOW_CLASS, {
WinGetTitle, title
log("Window not an AP/UB poker table [title=" title ", class=" class "]")
return
}
; determine if it's Absolute or Ultimate (only one can be open):
casino:=WinExist("Absolute Poker - Logged in as") ? "ABSOLUTE" : "UB"
log("Casino: " casino)
; position of "Options" button differs:
x:=casino="ABSOLUTE" ? 329 : ( VIEW="TOP" ? 329 : 749 )
y:=casino="ABSOLUTE" ? 14 : ( VIEW="TOP" ? 14 : 505 )
title:=casino="ABSOLUTE" ? "Options" : "UB Preferences" ; title differs
loop 4 { ; 4 attemps... perhaps solves some problems?
log("Opening options. Attempt " a_index "...")
AbsoluteOrUltimatePokerClick(x, y, win) ; click on options
WinWait %title% ahk_class %POPUP_WINDOW_CLASS%,, 0.25
ifEqual, ErrorLevel, 0, break
}
ifEqual, ErrorLevel, 1, {
log("Options dialog didn't open. Rebuy cancelled.")
return
}
log("Options successfully opened.")
x:=casino="ABSOLUTE" ? 268 : 460 ; x-coord differs
click(x, 40, WinExist()) ; click on Buy More Chips
WinWait Buy chips ahk_class %POPUP_WINDOW_CLASS%,, 2
ifNotEqual, ErrorLevel, 0, {
log("Buy chips dialog didn't open. Rebuy cancelled.")
return
}
log("Buy chips dialog opened.")
WinGetText, text
bigBlind:=bigBlind(text) ; get the big blind
maxStack:=maxStack(text) ; get the max stack size
allowedMaxRebuy:=allowedMaxRebuy(text) ; get the allowed max rebuy
stack:=maxStack-allowedMaxRebuy ; calculate stack size
log("Stack: " stack)
; calculate amount to rebuy:
rebuyAmount:=round((DESIRED_STACK_SIZE*bigBlind)-stack, 2)
log("RebuyAmount: " rebuyAmount)
if ( rebuyAmount<=0 ) { ; no rebuy possible
log("Cancelling rebuy...")
click(338, 382, WinExist()) ; cancel
return
}
if ( rebuyAmount>allowedMaxRebuy )
rebuyAmount:=allowedMaxRebuy
log("Final rebuyAmount: " rebuyAmount "`n`n")
ControlSetText, Edit1, % rebuyAmount
click(73, 379, WinExist()) ; click OK
; wait 2 secs for the "Additional chips will be available..." popup, and close it:
WinWait, Info ahk_class %POPUP_WINDOW_CLASS%, Additional chips will be available once you complete, 2
ifEqual, ErrorLevel, 0, WinClose
return
tooltipOff:
Tooltip
return
}
; ===================
/**
* Performs the initial buy-in. Buys in for
* DESIRED_STACK_SIZE big blinds.
* If DESIRED_STACK_SIZE*bigBlind > maxStack, the
* function will buy in for maxStack.
*
* @param win <hwnd> The hwnd of the buy-in dialog.
*/
buyIn(win) {
global DESIRED_STACK_SIZE
log("`nStarting buy in...")
WinExist("ahk_id" win) ; set LFW
WinGetText, text
bigBlind:=bigBlind(text) ; get the big blind
maxStack:=maxStack(text) ; get the max stack size
buyInAmount:=round(DESIRED_STACK_SIZE*bigBlind, 2) ; calc. amount
log("Buy in amount: " buyInAmount)
if ( buyInAmount>maxStack ) ; make sure we don't try to exceede max
buyInAmount:=maxStack
log("Final buy in amount: " buyInAmount)
SendRaw {%buyInAmount%}
click(73, 379, WinExist()) ; click OK
log("Buy in completed.")
}
; ===================
/**
* Returns the big blind, given the window text
* from the buy-in dialog.
*
* @param text <str> The window text from the buy-in dialog.
* @return <float> the big blind.
*/
bigBlind(text) {
regExMatch(text, "/\$([\d.,]+)", m) ; big blind
StringReplace, bigBlind, m1, `, ; get rid of comma (as in 1,200.00 -> 1200.00)
log("Big blind: " bigBlind)
return bigBlind
}
; ===================
/**
* Returns the allowed maximum stack size,
* given the window text from the buy-in dialog.
*
* @param text <str> The window text from the buy-in dialog.
* @return <float> the allowed max stack size.
*/
maxStack(text) {
regExMatch(text, "Maximum amount allowed : \$([\d.,]+)", m) ; max stack
StringReplace, maxStack, m1, `, ; get rid of comma (as in 1,200.00 -> 1200.00)
log("Max stack: " maxStack)
return maxStack
}
; ===================
/**
* Returns the allowed maximum rebuy amount,
* given the window text from the buy-in dialog.
*
* @param text <str> The window text from the buy-in dialog.
* @return <float> the allowed max rebuy.
*/
allowedMaxRebuy(text) {
regExMatch(text, "m)\$ \R\$ \R([\d.,]+)", m) ; allowed max rebuy
StringReplace, allowedMaxRebuy, m1, `, ; get rid of comma (as in 1,200.00 -> 1200.00)
log("allowedMaxRebuy: " allowedMaxRebuy)
return allowedMaxRebuy
}
; ===================
/**
* Writes a string to a file called "log.txt" in
* the working directory of the script. A linefeed
* is appended to the string.
*
* @param str <str> The string to write to the log file.
*/
log(str) {
global LOGGING
if LOGGING
FileAppend, %str%`n, log.txt
}
; ===================
/**
* Performs a click via the AHK Click command. The window must
* be an Absolute or UB Poker poker table, and coordinates should be
* for the default size of a table (792x556). They will then be
* converted to be relative to the current table size.
* NOTE: CoordMode, Mouse, Screen must be used in the auto-execute
* section of the script.
*
* @param x <int> The x-coord. Relative to client area.
* @param y <int> The y-coord. Relative to client area.
* @param win <hwnd> The handle to the window.
*/
AbsoluteOrUltimatePokerClick(x, y, win) {
getClientRect(cx, cy, cw, ch, win)
WinActivate ahk_id%win%
x:=cx+(cw/792)*x, y:=cy+(ch/556)*y
Click %x% %y%
}
; ===================
/**
* Performs a click via the AHK Click command, where coordinates
* are relative to the client area of a window.
* NOTE: CoordMode, Mouse, Screen must be used in the auto-execute
* section of the script.
*
* @param x <int> The x-coord. Relative to client area.
* @param y <int> The y-coord. Relative to client area.
* @param win <hwnd> The handle to the window.
*/
click(x, y, win) {
getClientRect(cx, cy, cw, ch, win)
x+=cx, y+=cy
Click %x% %y%
}
; ===================
/**
* Finds the "client rectangle" of a window, i.e. the area of
* the window not including borders, titlebar, menus, etc.
*
* @param x <int> Receives the x-coordinate of the window.
* @param y <int> Receives the y-coordinate of the window.
* @param w <int> Receives the width of the window.
* @param h <int> Receives the height of the window.
* @param hwnd <hwnd> Window handle. If blank, the Last Found Window will be used.
* @author Adapted from code by Sean. Modified and updated to use
* NumGet()/NumPut() by Roland.
* @see
http://msdn.microsoft.com/en-us/libr...03(VS.85).aspx
* @see
http://msdn.microsoft.com/en-us/library/aa931003.aspx
*/
getClientRect(byRef x="", byRef y="", byRef w="", byRef h="", hwnd=0) {
hwnd:=hwnd ? hwnd : WinExist() ; use LFW if no hwnd given
VarSetCapacity(rt, 16) ; alloc. mem. for RECT struc.
VarSetCapacity(pt, 8, 0) ; alloc. mem. for POINT struc.
DllCall("GetClientRect" , "uint", hwnd, "uint", &rt)
DllCall("ClientToScreen", "uint", hwnd, "uint", &pt)
x:=NumGet(pt, 0, "int"), y:=NumGet(pt, 4, "int")
w:=NumGet(rt, 8, "int"), h:=NumGet(rt, 12, "int")
}
Hope that somebody can help me.