Moin,
ich hab mir mal die Mühe gemacht und das Reload Skript für Stars von _dave_ 'n bissl umgeschrieben.
Es funktioniert jetzt für NL Bigstack und für Shortstack!!! Ihr könnt also die gewünschte Stackgröße einstellen.
Außerdem hab ich noch ne Funktion integriert, die den jeweils aktuellen Stack anhand der HandHistory ermittelt, damit der Rebuy gleich nach der Hand erfolgt und nicht verzögert, wie beim Original.
Das solltet ihr einstellen:
- Rebuy Grenze und Stackgröße (SSS oder BSS)
- Pfad zu den HandHistories (ohne Screenname aber mit "\" am Ende)
- in der Stars-Software sollte der Auto-Rebuy eingestellt sein!! (das Skript rebuyt nicht bei Stack = 0)
- eure Systemzeit sollte halbwegs stimmen (GMT+2)
- Stars und die HandHistories müssen auf Englisch eingestellt sein!!!
- aktuelle Autohotkey-Version (mit 1.0.47.06 getestet) http://www.autohotkey.com/download/
Das Skript wurde mit der SSS (ca.40k Hände NL25) und BSS (ca.5k Hände NL10) getestet und für gut befunden.
Dennoch kann ich nicht garantieren, dass alles so funtioniert, wie es soll, bin mir aber relativ sicher, dass es das tut.
Bekannte Probleme und Bugs:
- manchmal wird kein Rebuy ausgeführt (k.A. warum), dann könnt ihr manuell rebuyen, ansonsten solltet ihr keinen manuellen Rebuy machen (besonders als SSSS) und alles dem Skript überlassen
VISTA USER: falls das Skript bei euch nicht funktioniert, versucht folgendes:
- Autohotkey als Admin ausführen (autohotkey.exe -> Eigenschaften)
- pokerstars.exe bzw. pokerstarsupdate.exe Eigenschaften: Haken bei "Desktopgestaltung deaktivieren" setzen
- generell solltet ihr bei Vista Administratorrechte haben (evtl. Vergabe von Benutzerrechten abschalten)
Fragen/Anregungen/Probleme einfach hier posten oder per mail (archie203@gmx.de)
; PokerStars NL / Limit (Auto)Reloader, by _dave_at twoplustwo.com forums
; Important contributions by Roland.
; modified by Archie203
; Automatically reloads chips on NL tables once they drop
; below a user defined amount.
; TEST ON LOW STAKES!!! NO GUARANTEES !!! USE AT YOUR OWN RISK!!!
; SETTINGS ##################################################################
stack_bbs := 20 ;Stack nach Rebuy in BB
min_nl_bbs := 14.76 ;Rebuy Grenze in BB, < stack_bbs!
filepath := "C:\Programme\PokerStars\HandHistory\"
; END OF SETTINGS ###########################################################
#NoEnv
#SingleInstance, Force
SendMode Input
nltables := ""
SetTitleMatchMode 2
GroupAdd, StarsTables, Logged In as ,,, PokerStars Lobby
SetTimer, UpdateTables, 1000
timezone_difference_EST := "-6"
SetTimer, KillPopUps, 200
;SetTimer, KillPopUps, Off
getTables()
{
global nltables
global screenname
global hero
nltables := ""
SetTitleMatchMode 2
WinGet, id, id, PokerStars Lobby
WinGetTitle, hero, ahk_id%id%
StringTrimLeft, hero, hero, InStr(hero, "Logged in as ", true, 0)+12
screenname := hero
StringReplace, hero, hero,%A_SPACE%,, All
StringReplace, hero, hero,|,, All
;Msgbox, %hero%
WinGet, pid, PID, ahk_id%id%
WinGet, list, list, Logged In as ahk_pid%pid%
Loop %list%
{
this_id := list%a_index%
WinGetTitle, title, ahk_id%this_id%
If (this_id != id)
{
if (InStr(title, "Tournament"))
{
continue
}
if(InStr(title, "No Limit") || InStr(title, "Pot Limit"))
{
;Msgbox, got nl table`n`n%title%
nltables = %nltables%,%this_id%
}
else if(InStr(title, "Limit"))
{
continue
}
}
}
StringTrimLeft, nltables, nltables, 1
}
UpdateTables:
getTables()
Loop, Parse, nltables, `,
{
DetectHiddenWindows, On
WinGet, alreadyopen, id, _StarsAutoRebuy_%A_LoopField%.ahk
if (alreadyopen)
{
;WinGetTitle, title, ahk_id%alreadyopen%
continue
}
else
{
str := "#NoTrayIcon`n"
str := str . "table_id := """ . A_LoopField . """`n"
str := str . "justdone := 0`n"
str := str . "screenname := """ . screenname . """`n"
str := str . "Loop`n"
str := str . "{`n"
str := str . " IfWinNotExist, ahk_id%table_id%`n"
str := str . " {`n"
str := str . " ExitApp`n"
str := str . " }`n"
str := str . " WinGetTitle, title, ahk_id%table_id%`n"
str := str . " StringMid, bb, title, InStr(title, ""/"") + 1, InStr(title, a_space,"""", InStr(title, ""/"")) - InStr(title, ""/"") - 1`n"
str := str . " bb := StrRep(bb, ""$"")`n"
;str := str . " MsgBox, BigBlind1:%bb%`n"
str := str . " desired_chips := bb * " . min_nl_bbs . "`n"
;str := str . " MsgBox, %desired_chips%`n"
str := str . " StringTrimRight, title, title, (StrLen(title) - InStr(title, "" - "", true, 0))+1`n"
str := str . " est := A_Now`n"
;str := str . " MsgBox, %est%`n"
str := str . " est += " . timezone_difference_EST . ", hours`n"
str := str . " FormatTime, est, %est%, yyyyMMdd`n"
str := str . " filename := """ . filepath . hero . "\HH"" . est . "" "" . title . "".txt""`n"
str := str . " StringReplace, filename, filename, /, -`n"
;str := str . " MsgBox, %filename%`n"
str := str . " FileGetSize, fsize, %filename%`n"
str := str . " if (fsize)`n"
str := str . " {`n"
str := str . " FileGetTime, ftime, %filename%`n"
str := str . " if (ftime > oldftime)`n"
str := str . " {`n"
str := str . " Sleep, 40`n"
str := str . " oldftime := ftime`n"
str := str . " FileRead, hh, %filename%`n"
str := str . " StringTrimLeft, hh, hh, Instr(hh, ""PokerStars Game #"", true, 0)-1`n"
str := str . " chips := currStackStars(hh, screenname)`n"
str := str . " if chips = 0`n"
str := str . " {`n"
;str := str . " msgbox, broke!`n"
str := str . " break`n"
str := str . " }`n"
;str := str . " MsgBox, chips:%chips%`n"
str := str . " if (justdone)`n"
str := str . " {`n"
str := str . " justdone := 0`n"
str := str . " continue`n"
str := str . " }`n"
str := str . " if (chips < desired_chips)`n"
str := str . " {`n"
str := str . " Sleep, 2000`n"
str := str . " rebuy_nl_bbs := (" . stack_bbs . " - (chips/bb))`n"
;str := str . " MsgBox, %rebuy_nl_bbs%`n"
str := str . " RebuyStars(table_id, rebuy_nl_bbs, bb)`n"
str := str . " justdone := 1`n"
str := str . " }`n"
str := str . " }`n"
str := str . " }`n"
str := str . "Sleep, 40`n"
str := str . "}`n"
FileRead, fns, %A_ScriptFullPath%
StringTrimLeft, fns, fns, InStr(fns, ";-------------- CHOP --------------;", true, 0)
StringTrimLeft, fns, fns, InStr(fns, "`n")
str := str . "`n`n" . fns
filename := "_StarsAutoRebuy_" . A_LoopField . ".ahk"
FileDelete, %filename%
FileAppend, %str%, %filename%
Run "AutoHotkey.exe" "/f" %filename%, , , ahkpid
WinWait, ahk_pid%ahkpid%
FileDelete, %filename%
}
}
return
getid()
{
global act_only_on_active_table
id := ""
If (act_only_on_active_table = 1)
{
;MsgBox, Active Table Mode
WinGet,id,,A
}
Else
{
;MsgBox, Table Under Cursor Mode
MouseGetPos, , , id
}
return id
}
KillPopUps:
SetTitleMatchMode, 2
WinGet, id, id, PokerStars Lobby
WinGet, ps_pid, PID, ahk_id%id%
IfWinExist, PokerStars ahk_class #32770 ahk_pid%ps_pid%
{
WinGet, idlist, list, PokerStars ahk_class #32770 ahk_pid%ps_pid%, , Lobby
Loop, %idlist%
{
id := idlist%A_Index%
WinGet, clist, ControlList, ahk_id%id%
if (InStr(clist, "Button2"))
{
continue
}
else
{
;WinGetText, wintxt, ahk_id%id%
;MsgBox, %wintxt%
Loop, 20
{
;MsgBox, hhdjsak
;WinActivate, ahk_id%id%
ControlFocus, Button1, ahk_id%id%
ControlSend, Button1, {SPACE}, ahk_id%id%
Sleep, 100
IfWinNotExist, ahk_id%id%
{
;ControlClick, Button1, ahk_id%id%
break
}
}
Sleep, 20
}
}
}
return
;-------------- CHOP --------------;
RebuyStars(win, bbs, bb)
{
;bb := 0.25
;msgbox, BigBlind2:%bb%
PostStarsClick(400, 52, win)
WinWait, % "Options ahk_class #32770",, 5
If (errorLevel)
{
return
}
WinGet, id, id
Sleep, 250
SetTitleMatchMode 2
If ( IsDisabledCtrl("Button4", id) )
{
WinClose, ahk_id%id%
return
}
Loop, 5
{
ControlFocus, Button4, ahk_id%id%
ControlSend, Button4, {SPACE} ahk_id%id%
}
Loop, 50
{
IfWinExist, Buy-in ahk_class #32770
{
WinGet, id2, id, Buy-in ahk_class #32770
break
}
If WinExist("PokerStars", "Your rebuy cannot be processed")
{
WinClose
return
}
Sleep, 100
}
If (!id2)
{
;Msgbox, no id2
return
}
WinGetTitle, title, ahk_id%win%
StringMid, bb, title, InStr(title, "/") + 1, InStr(title, a_space,"", InStr(title, "/")) - InStr(title, "/") - 1
bb := StrRep(bb, "$")
amount := bbs * bb
; msgbox, amount: %amount%
ControlSetText, Edit1, %amount%
Loop, 10
{
;ControlFocus, Button4, ahk_id%id2%
ControlSend, Button3, {SPACE}, ahk_id%id2%
Sleep, 20
}
}
;######## current stack ########
; current stack of the hero
;SetTitleMatchMode 2
currStackStars(hh, hero) {
names:=namesStars(hh)
seat:=listGetPos(names, hero)
stacks:=stacksStars(hh)
chips:=listGet(stacks, seat)
chips:= chips-$lostStars(hh, hero)
;msgbox, endstack: %chips%
return chips
}
; return 6max, 8max, 9max or 10max
xmaxStars(hh) {
regExMatch(hh, " (\d{1,2})-max", m)
return m1
}
; returns a comma-sep. list of heros
; if a seat is empty, the item in the list
; is blank
; if all is false, heros that left the table
; during the hand are removed from the list
; and heros that took a seat are added to
; the list
namesStars(hh) {
Loop % xmaxStars(hh) {
npos := regExMatch(hh, "U)Seat " a_index ": (.*) \(", m)
if (npos = 0)
{
names.=",§empty"
}
else
{
names.=",§" m1
}
} StringTrimLeft, names, names, 2
ifEqual, all, 1, return names
hh_:=hh
Loop {
if !p:=regExMatch(hh_, "\R(.*) leaves the table\R", m)
break
StringTrimLeft, hh_, hh_, % p+1
;names:=strRep(names, m1)
StringReplace, names, names, %m1%, empty
} Loop {
if !p:=regExMatch(hh, "\R(.*) joins the table at seat #(\d{1,2})", m)
break
StringTrimLeft, hh, hh, % p+1
listDel(names, m2)
listAdd@pos(names, m1, m2)
}
;msgbox,%names%
return names
}
; returns a comma-sep. list of stack-sizes
; if a seat is empty, the item in the list
; is blank
stacksStars(hh) {
Loop % xmaxStars(hh) {
regExMatch(hh, "Seat " a_index ": (.*) \(\$?([\d\.]+) ", m)
if (m2 = "")
{
stacks.=",§na"
}
else
{
stacks.=",§" m2
}
} StringTrimLeft, stacks, stacks, 2
;msgbox, %stacks%
return stacks
}
; returns the amount of chips the hero lost
; on the hand
; if he won money, the value is NEGATIVE
$lostStars(hh, hero) {
post := 0
call := 0
bet := 0
raise := 0
collect := 0
summe := 0
;###Bereiche der HandyHistory finden###
start := 1
Loop % 7
{
pos:= regExMatch(hh, "\*{3}\ [A-Z ]+\*{3}", m, start)
cutpos.=",§" pos ;positionen zum trennen finden " xxxx "
start := pos+10
}
poszero := regExMatch(cutpos, ",§0" , m) ;cutpos kürzen falls 0 vorhanden
StringTrimLeft, cutpos, cutpos, 2
StringLen, lcutpos, cutpos
lcut := lcutpos - poszero + 3
StringTrimRight, cutpos, cutpos, lcut
;msgbox, %cutpos%
i=0
;###Zuschneiden der HandHistory###
Loop
{
if i=0
leftcut := 0 ;erster Bereich beginnt am Anfang
else leftcut := listGet(cutpos, i, ",§") ;linker Schnittpunkt
if ErrorLevel = 1
break
StringLen, hhlength, hh
rightcut := listGet(cutpos, i+1, ",§") ;rechter Schnittpunkt
if ErrorLevel = 1
rightcut := hhlength ;letzter Bereich bis zum Ende
StringTrimRight, hhbereich, hh, (hhlength-rightcut)
StringTrimLeft, hhbereich, hhbereich, leftcut
;msgbox, %leftcut%, %rightcut%
;msgbox, %hhbereich%
;###Auslesen der Werte###
;###post###
regExMatch(hhbereich, hero ": posts[a-z ]+\$?([\d\.]+)" , m)
blind += m1 ? m1 : 0
;msgbox, blind: %blind%, m: %m%
;###raises###
raiseh := 0
raiseandblind := 0
raisepos := Instr(hhbereich, hero ": raises", false, 0)
if raisepos !=0
{
StringTrimLeft, hhbereich, hhbereich, raisepos-1 ;Bereich vor letztem Raise abschneiden
if i=1
blind :=0 ;Blind abziehen falls Preflop-Raise vorhanden
}
Loop, Parse, hhbereich, `n
{ if !regExMatch(a_loopfield, hero ": raises \$?([\d\.]+) to \$?([\d\.]+)", m)
continue
raiseh := m2 ? m2 : 0
}
raise+=raiseh
;msgbox, raise %raise%
;###call###
Loop, Parse, hhbereich, `n
{ if !regExMatch(a_loopfield, hero ": calls[a-z ]+\$?([\d\.]+)", m)
continue
call+=m1 ? m1 : 0
}
;msgbox, call %call%
;###bet###
Loop, Parse, hhbereich, `n
{ if !regExMatch(a_loopfield, hero ": bets[a-z ]+\$?([\d\.]+)", m)
continue
bet+=m1 ? m1 : 0
}
;msgbox, bet %bet%
;###uncalled bet + collected###
regExMatch(hhbereich, "Seat \d{1,2}: " hero "(.*) (collected|won) \(\$?([\d\.]+)", m)
collect-=m3 ? m3 : 0
regExMatch(hhbereich, "Uncalled bet \(\$?([\d\.]+)(.*)" hero, m)
collect-=m1 ? m1 : 0
;msgbox, collect= %collect%
i+=1
if i=7
break
}
summe:=blind+call+bet+raise+collect
;msgbox, Summe: %summe%
return summe
}
;###################################
; some necessary funktions by roland
IsDisabledCtrl(ctrl,win,matchMode=1) {
mm = %a_titleMatchMode%
SetTitleMatchMode %matchMode%
ControlGet, enabled, Enabled,, %ctrl%, ahk_id%win%
SetTitleMatchMode %mm%
return !enabled
}
CtrlGetTxt(ctrl,win,matchMode=1) {
mm = %a_titleMatchMode%
SetTitleMatchMode %matchMode%
ControlGetText, text, %ctrl%, ahk_id%win%
SetTitleMatchMode %mm%
return text
}
StrRep(str,char,rep_char="",all=1) {
StringReplace,str,str,%char%,%rep_char%,% all ? "useErrorLevel" : 0
return str
}
PostStarsClick(x, y, win) {
static border,caption
If ! border {
SysGet, border, 32
SysGet, caption, 4
caption := border + caption
}
WinGetPos,,,w,h,ahk_id%win%
x := x/792*(w-border*2)
y := y/546*(h-(caption+border))
PostLeftClick(x, y, win)
}
;Juks rocks
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<<16)^x), , ahk_id%table_id%
PostMessage, 0x202 , 0, ((y<<16)^x), , ahk_id%table_id%
}
; Del item from list at pos, < 0 from end
; ErrorLevel = 1 if not found. No ByRef as in ListCut
listDel( byRef list, pos=1, del=",§" ) { ; by Laszlo
_list_=%del%%list%%del%
Transform p1, ABS, pos
p2:=p1+1
ifGreater pos,-1, { ; pos > 0 counted from left, pos = 0: empty
StringGetPos, ch1, _list_, %del%, L%p1%
StringGetPos, ch2, _list_, %del%, L%p2%
} else ifLess pos, 0, { ; pos < 0 counted from right
StringGetPos, ch2, _list_, %del%, R%p1%
StringGetPos, ch1, _list_, %del%, R%p2%
} ifGreater, ErrorLevel, 0, Return ; nothing found
StringLeft, lst1, list, ch1-2
StringTrimLeft, lst2, list, ch2
ifEqual, lst2,, SetEnv list, %lst1%
else ifEqual, lst1,, SetEnv list, %lst2%
else SetEnv list, %lst1%,§%lst2%
return list
}
; Add item to the list at pos, < 0 counted from the end
; ErrorLevel = 1 if pos was truncated, = 0 otherwise
; enclose in commas for search
; pos = -1,-2... counted from right
listAdd@pos( byRef list, item, pos, del=",§" ) { ; by Laszlo
_list_=%del%%list%%del%
ifLess pos, 0, {
_pos:=-pos
StringGetPos chpos, _list_, %del%, R%_pos%
} else ifGreater pos, 1, { ; pos = 2,3... counted from left
StringGetPos, chpos, _list_, %del%, L%pos%
ifEqual, chpos, -1, StringLen chpos, _list_
} StringLeft, lst1, list, chpos - 2
StringTrimLeft, lst2, list, chpos
ifNotEqual, lst2,, SetEnv item, %item%%del%
ifNotEqual, lst1,, SetEnv item, %del%%item%
ifEqual, pos, 0, SetEnv ErrorLevel, 1
list:=lst1 item lst2
return list
}
; return position of 1st copy of item, 0 if not found
listGetPos(list, item, del=",§") { ; by Laszlo
_list_=%del%%list%%del%
StringGetPos, ch, _list_, %del%%item%%del%
StringLeft list, _list_, ch+2
StringReplace list, list, %del%, %del%, useErrorLevel
return %errorLevel%
}
; return item at pos, < 0 from the end
; ErrorLevel = 1 if pos is outside of list
listGet(list, pos=1, del=",§") { ; by Laszlo
ifEqual, pos, 0, {
errorLevel:=1
return
} _list_:=del . list . del
Transform p1, ABS, pos
p2:=p1+1
ifGreater, pos, 0, { ; pos > 0 counted from left
StringGetPos ch1, _list_, %del%, L%p1%
StringGetPos ch2, _list_, %del%, L%p2%
} else { ; pos < 0 counted from right
StringGetPos ch2, _list_, %del%, R%p1%
StringGetPos ch1, _list_, %del%, R%p2%
} ifGreater, errorLevel, 0, return ; nothing found
StringMid, item, list, ch1+1, ch2-ch1-2
return %item%
}
error(error, function="") {
global debug
msg:=function ? "Error in function " function "(): " error : error
ifEqual, debug, 1
msgbox(msg, "iconX w200 bold -owner +alwaysOnTop -toolwindow", "ERROR", "Comic Sans MS")
log(msg)
}
msgbox(msg="", options="", title="", font="", iPaths="") { ;by Roland
global mb_Icon,mb_Text,mb_Button1
,mb_Button2,mb_Button3,mb_ButtonName1
,mb_ButtonName2,mb_Checkbox,mb_Button1W
,mb_Button2W,mb_Button3W,mb_ButtonDefaultButton
,mb_Caption,mb_BorderL,mb_BorderR,mb_BorderB
,mb_Theme1,mb_Theme2,mb_Theme3,mb_Theme4,mb_Theme5
,mb_Theme6,mb_Theme7,mb_Theme8,mb_Theme9,mb_Theme10
theme:=strEnd(options, "theme")
if ( theme ) {
StringSplit, param, mb_Theme%theme%, `;
msg:=msg ? msg : param1
options:=StrRep(options, "theme" theme, param2)
title:=title ? title : param3, font:=font ? font : param4
iPaths:=iPaths ? iPaths : param5, gui:=gui ? gui : param6
} msg:=msg!="" ? msg : "Click OK to continue"
buttons:=StrRep(strEnd(options, "buttons"), "_", a_space)
buttons :=buttons=1 ? "Oka&y" : buttons=2 ? "Oka&y|&Cancel"
: buttons=3 ? "&Yes|&No|&Cancel" : buttons!="" ? buttons : "Okay"
StringSplit, button, buttons, |
bgColor:=regExMatch(options, " (background|bg)(\w+) ", m), bgColor:=m2
color:=strEnd(options, "c"), bold:=inStr(options, " bold ") ? "bold" : ""
italic:=inStr(options, " italic ") ? "italic" : "", size:=strEnd(options, "s"), size:=size ? size : 8
icon:=strEnd(options, "icon"), icon:=icon="!" ? 2 : icon="?" ? 3 : icon="x" ? 4 : icon="i" ? 5 : icon
width:=strEnd(options, "w"), buttonH:=strEnd(options, "h"), buttonH:=buttonH ? buttonH : "20"
checkboxTxt := StrRep(StrEnd(options, "checkbox"), "_", a_space)
defButton:=strEnd(options, "default"), defButton:=defButton ? defButton : strEnd(options, "def")
defButton:=defButton ? defButton : button0
guiTheme.=" " ( inStr(options, "-toolwindow") ? "-toolwindow" : "+toolwindow" )
guiTheme.=" " ( inStr(options, "+alwaysontop") ? "+alwaysontop" : "" )
guiTheme.=" " ( inStr(options, "-caption") ? "-caption" : "" )
guiTheme.=" " ( inStr(options, "+0x800000") ? "+0x800000" : "" )
title:=title ? title : StrRep(a_scriptName, ".ahk"), gui:=freeGui()
if ( iPaths ) {
StringLeft, caption, iPaths, InStr(iPaths, "|")-1
StringTrimLeft, border, iPaths, InStr(iPaths, "|")
customFrame:=1, msg:=msg . " "
} Gui, %gui%:default
Gui, destroy
owner:=setOwner(options)
Gui, +lastfound +labelmb_GuiLabel -SysMenu %guiTheme%
guiID:=WinExist()
Gui, Color, %bgColor%
Gui, Margin, 5, 5
ifEqual, customFrame, 1, Gui, Margin, 8, 25
Gui, Font, c%color% %bold% %italic% s%size%, %font%
if ( icon ) {
if icon in 2,3,4,5
Gui, Add, Pic, vmb_Icon section Icon%icon%, User32.dll
else Gui, Add, Pic, vmb_Icon section w32 h32, %icon%
ys:="ys", xs:="xs"
} Gui, Add, Text, vmb_Text %ys% w%width%, %msg%
Gui, Font, norm
Gui, Margin, 5, 5
ifNotEqual, checkboxTxt,, Gui, Add, Checkbox, vmb_Checkbox x5, %checkboxTxt%
Loop % button0 {
xys:=a_index=1 ? "xs" : "ys"
Gui, Add, Button
, vmb_Button%a_index% section h%buttonH% %xys% gmb_buttonPushed
, % button%a_index%
} ifNotEqual, defButton,, GuiControl, +default, mb_Button%defButton%
Gui, Add, Button, vmb_ButtonDefaultButton x0 y0 hidden
GuiControl, Focus, mb_ButtonDefaultButton
if ( customFrame ) {
Gui -caption
Gui, Add, Pic, vmb_Caption x0 y0 w5 h20 gmb_GuiMove, %caption%
Gui, Add, Pic, vmb_BorderL x0 y20 w3, %border%
Gui, Add, Pic, vmb_BorderR x0 y20 w3, %border%
Gui, Add, Pic, vmb_BorderB x0 y0 h3, %border%
Gui, Font, bold
Gui, Add, Text, x12 y1 cC0C0C0 backgroundTrans, %title%
Gui, Add, Text, x10 y0 cBlack backgroundTrans, %title%
} Hotkey, IfWinActive, ahk_id%GuiID%
Hotkey, ^c, mb_Copy2Clipboard
Gui, Show, hide, %title%
Sleep, 10
setGuiPos(owner)
Critical Off
Gui +lastfound
WinWaitClose
Hotkey, ^c, mb_copy2Clipboard, Off
errorLevel:=mb_Checkbox ? 1 : 0
ifNotEqual, owner, 0, Gui, %owner%:default
return r
mb_buttonPushed:
StringRight, num, a_guiControl, 1
GuiControlGet, r,, %a_guicontrol%
StringReplace, r, r, & ;get rid of the ampersand
ifNotEqual, owner, 0, Gui, %owner%:-disabled
Gui, Submit
Gui, Destroy
return
mb_copy2Clipboard:
clipboard:=msg
return
mb_guiMove:
PostMessage, 0xA1, 2
return
mb_guiLabelSize:
if ( customFrame ) {
GuiControl, MoveDraw, mb_Caption, % "w" a_guiwidth
GuiControl, MoveDraw, mb_BorderL, % "h" a_guiheight-20
GuiControl, MoveDraw, mb_BorderR, % "h" a_guiheight-20 "x" a_guiwidth-3
GuiControl, MoveDraw, mb_BorderB, % "w" a_guiwidth "y" a_guiheight-3
}
if InStr(options, " left ")
return
Loop 3
GuiControlGet, mb_Button%a_index%, Pos
p1w:=mb_Button1W, p2w:=mb_Button2W, p3w:=mb_Button3W
if InStr(options, " right ") {
w:=customFrame ? ( button0=1 ? a_guiwidth-11 : a_guiwidth-6 ) : a_guiwidth
if ( button0=1 ) {
GuiControl, MoveDraw, mb_Button1, % "x" w-p1w+5
} else if ( button0=2 ) {
GuiControl, MoveDraw, mb_Button1, % "x" w-(p1w+p2w+10)
GuiControl, MoveDraw, mb_Button2, % "x" w-(p2w+5)
} else if ( button0=3 ) {
GuiControl, MoveDraw, mb_Button1, % "x" w-(p1w+p2w+p3w+15 )
GuiControl, MoveDraw, mb_Button2, % "x" w-(p2w+p3w+10 )
GuiControl, MoveDraw, mb_Button3, % "x" w-(p3w+5)
}
} else {
w:=a_guiwidth
if ( button0=1 ) {
GuiControl, MoveDraw, mb_Button1, % "x" w/2-p1w/2
} else if ( button0=2 ) {
GuiControl, MoveDraw, mb_Button1, % "x" w/2-( ( p1w+p2w+5)/2 )
GuiControl, MoveDraw, mb_Button2, % "x" w/2-( ( p1w+p2w+5)/2 )+p1w+5
} else if ( button0=3 ) {
GuiControl, MoveDraw, mb_Button1, % "x" w/2-( ( p1w+p2w+p3w+10 )/2 )
GuiControl, MoveDraw, mb_Button2, % "x" w/2-( ( p1w+p2w+p3w+10 )/2 )+p1w+5
GuiControl, MoveDraw, mb_Button3, % "x" w/2-( ( p1w+p2w+p3w+10 )/2 )+p1w+p2w+10
} }
return
}
;this function extracts the trailing characters of a string
;(for instance "White" from BackgroundWhite etc.)
strEnd(o, str) {
regExMatch(" " o " ", "i)[\t ]+" str "([^\s]+)[\t ]+", m)
return m1
}
; finds the next free gui
freeGui() {
Loop 99 {
Gui, %a_index%: +lastfoundExist
If ! WinExist()
return a_index
}
}
; handles setting the owner for the Msgbox() funcion etc.
; has to be called BEFORE the gui is created
; note: operates on the default Gui
; options can be one or more of the following:
; -owner: the gui will not be owned
; ownerN: sets GuiN as the owner
; -modal: the gui will be owned, but it's owner will not be disabled
; if an owner is not specified, A_Gui, or, if A_Gui, is blank, 1 will be used,
; unless the owner does not exist
setOwner(options="") {
If InStr(options, "-owner")
return 0
owner := StrEnd(options, "owner")
owner := owner ? owner : ( a_gui ? a_gui : 1 )
Gui, %owner%: +LastfoundExist
If ! WinExist()
return 0
If ! InStr(options, "-modal")
Gui, %owner%: +disabled
Gui, +Owner%owner%
return owner
}
; shows the default gui relative to 'owner'
; omit x and y to center it on it's owner
; note: operates on default gui
; specify "TopRight" or "tr" for x to
; display in the top-right corner of the owner
setGuiPos(owner, x="",y="", hide=0) {
If ( ! owner ) {
Gui, Show
return
} Gui, %owner%: +Lastfound
WinGetPos, ox, oy, ow, oh
Gui, +Lastfound
Gui, Show, hide
WinGetPos,,, w, h
if ( isIn(x, "tr, topRight") ) {
Gui, %owner%: +lastfound
getClientRect(px, py, ww, hh, winExist())
} else if (x!="" && y!="" ) {
px := ox+x, py := oy+y
} else {
Gui, %owner%: +Lastfound
WinGetPos, ox, oy, ow, oh
Gui, +Lastfound
WinGetPos,,, w, h
px := ox + ( ow/2 - w/2 )
py := oy + ( oh/2 - h/2 )
} hide := hide ? "hide" : ""
Gui, Show, x%px% y%py% %hide%
}
isIn(var, matchlist) {
if var in % matchlist
return 1
return 0
}
; grabs the client rectangle of a window
getClientRect(byRef x, byRef y="", byRef w="", byRef h="", hwnd="") { ; by Sean
hwnd := hwnd ? hwnd : WinExist()
VarSetCapacity(rt, 16)
DllCall("GetClientRect" , "Uint", hWnd, "Uint", &rt)
DllCall("ClientToScreen", "Uint", hWnd, "int64P", pt)
x := pt & 0xFFFFFFFF
y := pt >> 32 & 0xFFFFFFFF
w := DecodeInteger(&rt + 8)
h := DecodeInteger(&rt +12)
}
decodeInteger(ptr) {
return *ptr | *++ptr << 8 | *++ptr << 16 | *++ptr << 24
}