View Single Post
  #105  
Old 03-24-2007, 04:23 PM
Finnisher Finnisher is offline
Senior Member
 
Join Date: Oct 2006
Location: Åbo
Posts: 1,117
Default Re: My PokerStars SNG AHK script

[ QUOTE ]
anyone got a good autotimebank script?

[/ QUOTE ]
http://forumserver.twoplustwo.com/showfl...mp;#Post8921318

Gnumsploitz edited _dave_'s script so there's probably some extra stuff in there but it doesn't do anything else than click the timebank:

[ QUOTE ]
; #### StarsBuddyList ####

; AHK version: 1.0.46.03
; date: January 13, 2007
; version: 0.01
; author: _dave_ @ 2p2 forums
; thx to Roland & JukofYork for some of the functions


;--------------- SETTINGS -----------------------

border_colour := "ff0000"
border_size := 0
trans := 255
timebank_min := 10
timebank_max := 13
refresh_interval := 333

;--------------- END OF SETTINGS ----------------


#NoEnv
#SingleInstance, Force
SendMode Input
SysGet, border, 32
SysGet, caption, 4
last_table_id := ""
tablequeue := ""
SetTimer, refreshqueue, %refresh_interval%
return

refreshqueue:
ids := TableIDListStars()
Loop, Parse, tablequeue, `,
{
StringTrimLeft, this_id, A_LoopField, InStr(A_LoopField, "_")
if (!InStr(ids, this_id))
{
StringReplace, tablequeue, tablequeue, %A_LoopField%, , All
}
}
Loop, Parse, ids, `,
{
ControlGet, v, Visible, , Edit7, ahk_id%A_LoopField%
if (v)
{
;table is waiting
if (!InStr(tablequeue, A_LoopField))
{
DllCall("QueryPerformanceCounter", "Int64 *", CurrentQPC)
tablequeue := tablequeue . "," . CurrentQPC . "-" . A_TickCount . "_" . A_LoopField
}
}
else
{
if (InStr(tablequeue, A_LoopField))
{
StringReplace, tablequeue, tablequeue, %A_LoopField%, , All
}
}
}
tmp := ""
Loop, Parse, tablequeue, `,
{
if (InStr(A_LoopField, "0x"))
{
tmp := tmp . "," . A_LoopField
}
}
Sort, tmp, N D`,
tablequeue := CleanList(tmp)

;Msgbox, %tablequeue%
most_urgent_table := ""
Loop, Parse, tablequeue, `,
{
StringTrimLeft, most_urgent_table, A_LoopField, InStr(A_LoopField, "_")
break
}
tc := A_TickCount
Loop, Parse, tablequeue, `,
{
StringTrimLeft, waiting_time, A_LoopField, InStr(A_LoopField, "-")
StringTrimRight, waiting_time, waiting_time, ( StrLen(waiting_time) - (InStr(waiting_time, "_")-1) )
waiting_time := (tc - waiting_time) / 1000
;MsgBox, %waiting_time%
if (waiting_time > 10 && waiting_time < 13)
{
StringTrimLeft, waiting_table, A_LoopField, InStr(A_LoopField, "_")
timebank_x := 530
timebank_y := 440
relStarsClientPoint(waiting_table, timebank_x, timebank_y)
PostLeftClick(timebank_x, timebank_y, waiting_table, 0)
}

}

;Msgbox, %most_urgent_table%
makegui(most_urgent_table)
return





TableIDListStars()
{
SetTitleMatchMode 2
WinGet, id, id, PokerStars Lobby
WinGet, pid, PID, ahk_id%id%
WinGet, list, list, $ ahk_pid%pid%
Loop %list%
{
this_id := list%a_index%
If (this_id != id)
{
ids = %ids%,%this_id%
}
}
WinGet, list, list, MiniFT ahk_class AutoHotkeyGUI
Loop %list%
{
this_id := list%a_index%
ids = %ids%,%this_id%

}
StringTrimLeft, ids, ids, 1
return ids
}

;removes empty items (and trailing delimiters)
CleanList(list, del="") {
del := del="" ? "," : del
Loop {
StringReplace, list, list, %del%%del%, %del%, UseErrorLevel
If ! ErrorLevel
break
}
If InStr(list, del) = 1
StringTrimLeft, list, list, 1
If InStr(list, del,0,0) = StrLen(list)
StringTrimRight, list, list, 1
return list
}

makegui(id="")
{
;Msgbox, %id%
global last_table_id
global border_colour
global border_size
global trans

if (id != last_table_id)
{
last_table_id := id

if(!id)
{
Gui, 1: Cancel
Gui, 2: Cancel
Gui, 3: Cancel
Gui, 4: Cancel
return
}

WinGetPos, x, y, w, h, ahk_id%id%
global border
global caption
x := x + border
y := y + border + caption
w := w - (2*border)
h := h - (2*border) - caption



;top
guinum := 1
Gui, %guinum%: +Alwaysontop +Lastfound +Owner
Gui, %guinum%: Color, %border_colour%
WinSet, Transparent, %trans%
Gui, %guinum%: -Caption
Gui, %guinum%: Show, w%w% h%border_size% x%x% y%y% NoActivate

;left
guinum++
Gui, %guinum%: +Alwaysontop +Lastfound +Owner
Gui, %guinum%: Color, %border_colour%
WinSet, Transparent, %trans%
Gui, %guinum%: -Caption
Gui, %guinum%: Show, w%border_size% h%h% x%x% y%y% NoActivate

;bottom
guinum++
Gui, %guinum%: +Alwaysontop +Lastfound +Owner
Gui, %guinum%: Color, %border_colour%
WinSet, Transparent, %trans%
Gui, %guinum%: -Caption
y2 := y + h - border_size
Gui, %guinum%: Show, w%w% h%border_size% x%x% y%y2% NoActivate

;right
guinum++
Gui, %guinum%: +Alwaysontop +Lastfound +Owner
Gui, %guinum%: Color, %border_colour%
WinSet, Transparent, %trans%
Gui, %guinum%: -Caption
x2 := x + w - border_size
Gui, %guinum%: Show, w%border_size% h%h% x%x2% y%y% NoActivate

x3 := x + (w/2)
y3 := y + (h/2)
;SoundBeep, 750, 100
Coordmode, Mouse, Screen
;MouseMove, x3, y3, 0
}
}


PostLeftClick(x, y, table_id, activate=1, control_class="") {
; ### 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), %control_class%, ahk_id%table_id%
PostMessage, 0x202 , 0, ((y<<16)^x), %control_class%, ahk_id%table_id%
}

relStarsClientPoint(id, ByRef x, ByRef y)
{
global border
global caption
rw := 792
rh := 546
WinGetPos, , , w, h, ahk_id%id%
w := w - (2*border)
h := h - (2*border) - caption

x := Floor( (x / rw ) * w )
y := Floor( (y / rh) * h )

}


[/ QUOTE ]
Reply With Quote