Code:
;
; by _dave_ of twoplustwo software forum
;
; contributions by Jukofyork, Roland
;
#NoEnv
SendMode Input
#SingleInstance, Force
SysGet, border, 32
SysGet, caption, 4
caption := border + caption
GroupAdd, StarsTables, ahk_class PokerStarsTableFrameClass
bglist := ""
bgnames := ""
Loop, *.jpg
{
bglist := bglist . A_LoopFileLongPath . "`n"
StringTrimRight, picname, A_LoopFileName, 4
bgnames := bgnames . picname . "`n"
}
StringTrimRight, bglist, bglist, 1
StringTrimRight, bgnames, bgnames, 1
;Msgbox %bgnames%
return
^RButton::
id := getid()
IfWinExist, ahk_id%id% ahk_group StarsTables
{
Loop, Parse, bgnames, `n
{
Menu, menu, Add, %a_loopfield%, changeBackground
}
Menu, menu, Show
}
return
changeBackground:
Loop, Parse, bglist, `n
{
if (A_Index = A_ThisMenuItemPos)
{
newpic := A_LoopField
}
}
SetBackground(id, newpic)
WinActivate, ahk_id%id%
return
SetBackground(win, newpic)
{
SetTitleMatchMode, 2
WinGet, pspid, pid, PokerStars Lobby
PostStarsClick(400, 52, win)
WinWait, Options ahk_pid%pspid% ahk_class #32770,, 5
If (errorLevel)
{
return
}
WinGet, id, id
Sleep, -1
ControlFocus, Button12, ahk_id%id%
ControlSend, Button12, {SPACE}, ahk_id%id%
WinWait, Table Themes ahk_pid%pspid% ahk_class #32770,, 5
If (errorLevel)
{
return
}
WinGet, themes_id, id
Sleep, -1
ControlFocus, Button1, ahk_id%themes_id%
ControlSend, Button1, {SPACE}, ahk_id%themes_id%
WinWait, Background ahk_pid%pspid% ahk_class #32770,, 5
If (errorLevel)
{
return
}
WinGet, background_id, id
Sleep, -1
Loop, 10
{
ControlGet, en_test, Enabled, , Edit1, ahk_id%background_id%
if !(en_test)
{
WinActivate, ahk_id%background_id%
ControlClick, Button1, ahk_id%background_id%
Sleep, 333
}
else
{
break
}
}
ControlSetText, Edit1, %newpic%, ahk_id%background_id%
Sleep, -1
ControlFocus, Button4, ahk_id%background_id%
ControlSend, Button4, {SPACE}, ahk_id%background_id%
Loop, 9
{
ControlGetText, apply_test, Button3, ahk_id%themes_id%
if (apply_test = "Apply")
{
break
}
Sleep, 333
}
WinActivate, ahk_id%background_id%
ControlFocus, Button5, ahk_id%background_id%
ControlSend, Button5, {SPACE}, ahk_id%background_id%
Sleep, -1
WinActivate, ahk_id%themes_id%
ControlFocus, Button3, ahk_id%themes_id%
ControlSend, Button3, {SPACE}, ahk_id%themes_id%
Sleep, -1
WinWait, Apply Theme ahk_pid%pspid% ahk_class #32770,, 5
If (errorLevel)
{
return
}
WinGet, at_id, id
Sleep, -1
WinActivate, ahk_id%at_id%
ControlFocus, Button4, ahk_id%at_id%
ControlSend, Button4, {SPACE}, ahk_id%at_id%
Sleep, -1
WinActivate, ahk_id%win%
}
getid()
{
;MsgBox, Table Under Cursor Mode
MouseGetPos, , , id
return 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 )
}
;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%
}
PostStarsClick(x, y, id)
{
relStarsClientPoint(id, x, y)
PostLeftClick(x, y, id)
}
~^!q::
ExitApp
return