By Jukofyork at 2+2 Forums.
Party AHK Planner
This is a reworked copy of Dave's StarsPlanner. I took out all the unnecessary functions. Also, there is no auto-closing of any popup-windows.
Screenshot
Instructions
Make sure to have the latest version of AutoHotkey installed http://www.autohotkey.com
Run this script - you should get a Party AHK Planner window (as in the screenshot above) appear.
Open some Party tables, arrange them as you'd like them to always be.
Hit the "Capture" button on Party AHK Planner, enter a name for your new layout.
It should pop up a Message box, e.g. "Found 8 Party Tables" or similar.
Close the Party tables, they are no longer required.
Hit the "Configure" button, if desired - drag the tables around so thet they fill in the order you would like. New tables will be put in to the first empty slot in numerical order.
Hit "Save Changes" if you are happy with your layout.
Tick the "Enable Arrange Tables" Check box on Party AHK Planner window. New tables should be automatically re-sized and moved to where you want them to go.
Experiment with other options - they are fairly self explanitory I think.
If you hit the Minimze Windows button, all Party tables will be minimized to the taskbar. If after that, you press the Restore Windows button, all tables will return to their original position. If you checked the Enable Arrange Tables box, it will be turned off when you minimize the tables, and turned on again if you press the Restore Windows button.
Enjoy!
Revision History
v0.01
Initial release.
v0.01b
Added a button to reset the size and position (to [0,0]) of the Party lobby in case the "mini-lobby" bug happens which makes your lobby look like this:
v0.01c
1. Have made it so we don't move the window to (0,0) just before a resize (no need for this on Party).
2. Have made it so that we now use the mouse's postion for drag&drop on a window (feels more natural than using the window's top left coord).
v0.01d (24th September 2008)
1. We are now careful not to try to arrange tournament lobbys.
2. We are now careful to wait for a table to fully open before arranging it.
Download
Code
;------------------------------------------------------------------------------------------
;;;;;;;;;;;;;;;;; CODE STARTS HERE
/*
Party AHK Planner, converted to work at Party by Jukofyork, but all the real work done
by _dave_ who wrote the original Stars Planner.
Contributions by Roland, PietM, Jukofyork.
Mimics some of the layout behaviour of the fantastic PartyPlanner, but using AHK. Enjoy!
Also added PietM's code of having a minimize/restore button.
0.1b: Added the Reset Lobby button to fix the "tiny lobby problem".
0.1c: 1. Made it so we don't move the window to (0,0) for Party.
2. Have made it so that we now use the mouse's postion for
drag&drop on a window (feels more natural than using the
window's top left coord).
0.1d: 1. We are now careful not to try to arrange tournament lobbys.
2. We are now careful to wait for a table to fully open before arranging it.
*/
#NoEnv
#SingleInstance, Force
SendMode Input
using_sngopener := 1
SysGet, border, 32
SysGet, caption, 4
slotcount := 0
w := 5
h := 6
x := 3
y := 345
Loop, 24
{
Loop, 2
{
slotcount += 1
slot%slotcount%w := w
slot%slotcount%h := h
slot%slotcount%x := x
slot%slotcount%y := y
slot%slotcount%id := ""
}
}
slotcount := 0
customfillorder = 1,2,3,4
SetTimer, DoPlanning, 250
SetTimer, DoPlanning, Off
SetTimer, DoPlanningConfig, 250
SetTimer, DoPlanningConfig, Off
SetTimer, KeepLobbyUp, 1000
SetTimer, KeepLobbyUp, Off
inifile := "PartyAHKPlanner-v0.01.ini"
ChosenLayout := 0
MinMaxWindows := 0
FileGetSize, inipresent, %inifile%
if (ErrorLevel)
{
str := "[Layouts]`nnumlayouts=0`n`n[Defaults]`nPlanTablesOn=0`nKeepLobbyOn=0`nChosenLayout=0`ngx=0`ngy=0"
FileAppend, %str%, %inifile%
}
Gui, Add, Checkbox, vPlanTables gPlanTables x10 y10, Enable Re-Size and Arrange Tables
Gui, Add, Checkbox, vKeepLobby gKeepLobby x10 y30, Enable Keep Lobby
Gui, Add, ComboBox, vLayoutChoice gLayoutChoice w190 x240 y10 Limit AltSubmit
Gui, Add, Button, vCaptureLayout gCaptureLayout x240 y40 w60 h30 , Capture
Gui, Add, Button, vConfigureLayout gConfigureLayout x305 y40 w60 h30 , Configure
Gui, Add, Button, vDeleteLayout gDeleteLayout x370 y40 w60 h30 , Delete
Gui, Add, Button, Hidden vConfigSave gConfigSave x240 y40 w90 h30 , Save Layout
Gui, Add, Button, Hidden vConfigCancel gConfigCancel x340 y40 w90 h30 , Cancel
Gui, Add, Button, vMinMaxBtn gMinMaxBtn x10 y50 w100 h20, Minimize Windows
Gui, Add, Button, vResetLobbyBtn gResetLobbyBtn x120 y50 w100 h20, Reset Lobby
IniRead, gx, %inifile%, Defaults, gx
IniRead, gy, %inifile%, Defaults, gy
Gui, Show, x%gx% y%gy% h80 w440, Party AHK Planner v0.1d
IniRead, ChosenLayout, %inifile%, Defaults, ChosenLayout
refresh_layout()
IniRead, PlanTablesOn, %inifile%, Defaults, PlanTablesOn
if (PlanTablesOn)
{
GuiControl, , PlanTables, %PlanTablesOn%
GoSub PlanTables
}
IniRead, KeepLobbyOn, %inifile%, Defaults, KeepLobbyOn
if (KeepLobbyOn)
{
GuiControl, , KeepLobby, %KeepLobbyOn%
GoSub KeepLobby
}
return
MinMaxBtn:
if (MinMaxWindows)
{
GuiControl, , MinMaxBtn, Minimize Windows
MinMaxWindows := 0
tables := TableIDListParty()
Loop, Parse, tables, `,
{
WinRestore, ahk_id%A_LoopField%
}
if (dummyPlanTables) {
GuiControl, , PlanTables, 1
SetTimer, DoPlanning, On
}
} else
{
GuiControl, , MinMaxBtn, Restore Windows
MinMaxWindows := 1
dummyPlanTables := PlanTables
if (PlanTables)
{
GuiControl, , PlanTables, 0
SetTimer, DoPlanning, Off
}
tables := TableIDListParty()
Loop, Parse, tables, `,
{
WinMinimize, ahk_id%A_LoopField%
}
}
return
ResetLobbyBtn:
; Reset the Party lobby to top left and correct dimentions.
SetTitleMatchMode, 2
WinMove, Poker Lobby, , 0, 0, 786, 566
return
GUIClose:
Gui, Submit, NoHide
IniDelete, %inifile%, Defaults
IniWrite, %PlanTables%, %inifile%, Defaults, PlanTablesOn
IniWrite, %KeepLobby%, %inifile%, Defaults, KeepLobbyOn
IniWrite, %ChosenLayout%, %inifile%, Defaults, ChosenLayout
WinGetPos, gx, gy, , , Party AHK Planner v0.1
IniWrite, %gx%, %inifile%, Defaults, gx
IniWrite, %gy%, %inifile%, Defaults, gy
ExitApp
return
PlanTables:
Gui, Submit, NoHide
if (PlanTables)
{
GuiControl, Disable, CaptureLayout
GuiControl, Disable, ConfigureLayout
GuiControl, Disable, DeleteLayout
SetTimer, DoPlanning, On
}
else
{
SetTimer, DoPlanning, Off
GuiControl, Enable, CaptureLayout
GuiControl, Enable, DeleteLayout
GuiControl, Enable, ConfigureLayout
}
return
KeepLobby:
Gui, Submit, NoHide
if (KeepLobby)
{
WinGet, id, id, Poker Lobby
WinGet, ismin, MinMax, ahk_id%id%
If (ismin = -1)
{
WinRestore, ahk_id%id%
}
SetTimer, KeepLobbyUp, On
}
else
{
SetTimer, KeepLobbyUp, Off
}
return
LayoutChoice:
Gui, Submit, NoHide
ChosenLayout := LayoutChoice
refresh_layout()
return
DeleteLayout:
Gui, Submit, NoHide
Gui +OwnDialogs
IniRead, layoutname, %inifile%, Layouts, %LayoutChoice%
Msgbox, 4 , , You are about to delete the saved layout:`n`n%layoutname%`n`nAre You Sure?
IfMsgBox, Yes
{
Critical
IniRead, numlayouts, %inifile%, Layouts, numlayouts
FileRead, file, %inifile%
if not ErrorLevel
{
IniDelete, %inifile%, Layouts, %LayoutChoice%
IniDelete, %inifile%, Layout%LayoutChoice%
newnumlayouts := numlayouts - 1
IniWrite, %newnumlayouts%, %inifile%, Layouts, numlayouts
FileRead, file, %inifile%
c := numlayouts - LayoutChoice
needchanged := ""
Loop, %c%
{
n := (numlayouts - A_Index) + 1
needchanged := n . "," . needchanged
}
StringTrimRight, needchanged, needchanged, 1
Loop, Parse, needchanged, `,
{
oldnum := "`n" . A_LoopField . "="""
newnum := "`n" . (A_LoopField - 1) . "="""
StringReplace, file, file, %oldnum%, %newnum%, A
oldstr := "[Layout" . A_LoopField . "]"
newstr := "[Layout" . (A_LoopField - 1) . "]"
StringReplace, file, file, %oldstr%, %newstr%, A
}
FileDelete, %inifile%
FileAppend, %file%, %inifile%
}
Critical, Off
IniRead, numlayouts, %inifile%, Layouts, numlayouts
if (ChosenLayout > numlayouts)
{
ChosenLayout -= 1
ChosenLayout := IIf(ChosenLayout, ChosenLayout, 0)
IniWrite, %ChosenLayout%, %inifile%, Defaults, %ChosenLayout%
}
refresh_layout()
}
return
CaptureLayout:
Gui +OwnDialogs
InputBox, newlayout, Layout Name, Please enter a name for this captured layout., , , , gx+10, gy+30, , ,
if (!ErrorLevel)
{
tl := ""
tl2 := ""
if (newlayout = "")
{
Msgbox, Please enter a name for the new layout
return
}
tables := TableIDListParty()
numtables := 0
Loop, Parse, tables, `,
{
numtables += 1
}
t := 0
tl := ""
if (numtables > 0)
{
Loop, Parse, tables, `,
{
t += 1
WinGetPos, l%t%x, l%t%y, l%t%w, l%t%h, ahk_id%A_LoopField%
tl := tl . "," . t
}
StringTrimLeft, tl, tl, 1
Msgbox, Found %t% Party Poker tables
order := ""
if (t > 0)
{
Loop, %t%
{
order := order . "," . l%A_Index%x . "." . l%A_Index%y
}
StringTrimLeft, order, order, 1
Sort, order, N D,
Loop
{
Loop, Parse, order, `,
{
StringTrimRight, x, A_LoopField, (StrLen(A_LoopField) - InStr(A_LoopField, "."))+1
StringTrimLeft, y, A_LoopField, InStr(A_LoopField, ".")
Loop, Parse, tl, `,
{
if (l%A_LoopField%x = x && l%A_LoopField%y = y)
{
tmp := A_LoopField
tl := RemoveFromList(tl,tmp)
tl2 := tl2 . "," . tmp
break
}
}
}
if (tl = "")
{
break
}
}
StringTrimLeft, tl2, tl2, 1
sect := numlayouts + 1
cl := ""
Loop, Parse, tl2, `,
{
x := l%a_loopfield%x
y := l%a_loopfield%y
w := l%a_loopfield%w
h := l%a_loopfield%h
IniWrite, %x%, %inifile%, Layout%sect%, %A_Index%x
IniWrite, %y%, %inifile%, Layout%sect%, %A_Index%y
IniWrite, %w%, %inifile%, Layout%sect%, %A_Index%w
IniWrite, %h%, %inifile%, Layout%sect%, %A_Index%h
cl := cl . "," . A_Index
}
StringTrimLeft, cl, cl, 1
IniDelete, %inifile%, Layouts, numlayouts
IniWrite, %sect%, %inifile%, Layouts, numlayouts
IniWrite, "%newlayout%", %inifile%, Layouts, %sect%
IniWrite, %t%, %inifile%, Layout%sect%, slotcount
IniWrite, %cl%, %inifile%, Layout%sect%, customfillorder
ChosenLayout := sect
refresh_layout()
}
}
}
return
ConfigureLayout:
Gui, Submit, NoHide
ChosenLayout := LayoutChoice
GuiControl, Disable, PlanTables
GuiControl, Disable, LayoutChoice
GuiControl, Hide, CaptureLayout
GuiControl, Hide, ConfigureLayout
GuiControl, Hide, DeleteLayout
filename := "PartyAHKPlannerConfigureLayoutGUI.ahk"
FileDelete, %filename%
guinum := 10
Loop, %slotcount%
{
x := slot%A_Index%x
y := slot%A_Index%y
w := slot%A_Index%w
h := slot%A_Index%h
w := w - (2*border)
h := h - (2*border) - caption
guinum += 1
str := "Gui " . guinum . ": -Resize -SysMenu`n"
FileAppend, %str%, %filename%
str := "Gui " . guinum . ": Font, c0000ff s40 bold, Arial`n"
FileAppend, %str%, %filename%
str := "Gui " . guinum . ": Add, Text, , Slot " . A_Index . "`n"
FileAppend, %str%, %filename%
str := "Gui " . guinum . ": Show , w" . w . " h" . h . " x" . x . " y" . y . " , Party AHK Planner Slot #" . A_Index . "`n"
FileAppend, %str%, %filename%
}
Run "AutoHotkey.exe" "/f" "%filename%"
SetTitleMatchMode, 3
Loop, %slotcount%
{
WinWait, Party AHK Planner Slot #%A_Index%
WinGet, id, id, Party AHK Planner Slot #%A_Index%
s := ExFromList(customfillorder,A_Index)
slot%s%id := id
}
SetTimer, DoPlanningConfig, On
Sleep, 2000
GuiControl, Show, ConfigSave
GuiControl, Show, ConfigCancel
FileDelete, %filename%
return
ConfigSave:
filename := "PartyAHKPlannerConfigureLayoutGUI.ahk"
GuiControl, Hide, ConfigSave
GuiControl, Hide, ConfigCancel
GuiControl, Show, CaptureLayout
GuiControl, Show, ConfigureLayout
GuiControl, Show, DeleteLayout
order := ""
SetTitleMatchMode 3
Loop, %slotcount%
{
title := "Party AHK Planner Slot #" . A_Index
WinGet, id, id, %title%
s := 0
Loop, %slotcount%
{
s += 1
if (slot%s%id = id)
{
order := order . "," . s
break
}
}
}
StringTrimLeft, order, order, 1
SetTitleMatchMode 2
DetectHiddenWindows, On
WinGet, list, list, %filename%
Loop, %list%
{
id := list%A_Index%
WinClose, ahk_id%id%
}
DetectHiddenWindows, Off
SetTimer, DoPlanningConfig, Off
IniDelete, %inifile%, Layout%ChosenLayout%, customlayout
IniWrite, %order%, %inifile%, Layout%ChosenLayout%, customfillorder
GuiControl, Enable, LayoutChoice
GuiControl, Enable, PlanTables
refresh_layout()
return
ConfigCancel:
GuiControl, Hide, ConfigSave
GuiControl, Hide, ConfigCancel
GuiControl, Show, CaptureLayout
GuiControl, Show, ConfigureLayout
GuiControl, Show, DeleteLayout
SetTitleMatchMode 2
DetectHiddenWindows, On
WinGet, list, list, %filename%
Loop, %list%
{
id := list%A_Index%
WinClose, ahk_id%id%
}
DetectHiddenWindows, Off
SetTimer, DoPlanningConfig, Off
GuiControl, Enable, LayoutChoice
GuiControl, Enable, PlanTables
return
refresh_layout()
{
global
SetTimer, DoPlanning, Off
IniRead, numlayouts, %inifile%, Layouts, numLayouts
layoutlist := ""
Loop, %numLayouts%
{
IniRead, tmp, %inifile%, Layouts, %A_Index%
layoutlist := layoutlist . tmp
if (A_Index < numlayouts)
{
layoutlist := layoutlist . "|"
}
}
GuiControl,, LayoutChoice, |%layoutlist%
GuiControl, Choose, LayoutChoice, %ChosenLayout%
IniRead, slotcount, %inifile%, Layout%ChosenLayout%, slotcount
Loop, %slotcount%
{
IniRead, slot%A_Index%x, %inifile%, Layout%ChosenLayout%, %A_Index%x
IniRead, slot%A_Index%y, %inifile%, Layout%ChosenLayout%, %A_Index%y
IniRead, slot%A_Index%w, %inifile%, Layout%ChosenLayout%, %A_Index%w
IniRead, slot%A_Index%h, %inifile%, Layout%ChosenLayout%, %A_Index%h
slot%A_Index%id := ""
}
IniRead, customfillorder, %inifile%, Layout%ChosenLayout%, customfillorder
if (PlanTables)
{
SetTimer, DoPlanning, On
}
}
win_adjustsize(id, desired_w)
{
global border
global caption
WinGetClass, winclass, ahk_id%id%
;Msgbox, %winclass%
; ### JUK: Not sure what the other version does, but it doesn't work at Party.
; ### - If this is resizing constantly, then it doesn't show any CPU?
desired_h := (desired_w / 1.45155) + border + caption
WinMove, ahk_id%id%, , , , desired_w, desired_h
}
TableIDListParty()
{
SetTitleMatchMode 2
WinGet, id, id, Poker Lobby
WinGet, pid, PID, ahk_id%id%
WinGet, list, list, $ ahk_pid%pid%
Loop %list%
{
this_id := list%a_index%
If (this_id != id)
{
; ### JUK: This now is careful not to add tourney lobbys or tables whichg are in the process of opening.
WinGetTitle, title, ahk_id%this_id%
IfNotInString, title, Tournament lobby ; ### JUK: We don't want tourney lobbys.
{
ControlGet, OutputHwnd, Hwnd,, Edit1, ahk_id%this_id%
if (OutputHwnd <> "") ; ### JUK: We must wait for the window to finish opening first.
ids = %ids%,%this_id% ; ### JUK: Lets add it then.
}
}
}
StringTrimLeft, ids, ids, 1
return ids
}
fixtables()
{
global slotcount
global customfillorder
tables := TableIDListParty()
t := ""
GetKeyState, state, LButton
if (state = "D")
{
MouseGetPos, , , id
if (InStr(tables, id))
{
Sleep, 70
GetKeyState, state, LButton
if (state = "D")
{
Loop
{
Sleep, 10
GetKeyState, state, LButton
if (state = "U")
{
MouseGetPos, , , id
if (InStr(tables, id, true, 0))
{
; ### JUK: Have changed this, as it feels more natural to drap&drop a window using the
; mouse's position as the drop-off point (rather than the top left of the
; window).
;WinGetPos, x, y, this_w, this_h, ahk_id%id%
CoordMode, Mouse, Screen
MouseGetPos, x, y
o := 0
Loop, %slotcount%
{
o += 1
if (slot%o%id = id )
{
oldslot := o
break
}
}
c := slotcount + 1
Loop, %slotcount%
{
c -= 1
newslot := c
if (slot%c%x > (x) )
{
continue
}
else if (slot%c%y > (y) )
{
continue
}
else
{
break
}
}
t := slot%newslot%id
slot%newslot%id := slot%oldslot%id
slot%oldslot%id := t
}
break
}
}
}
}
else
{
;do nothing
}
}
c := 0
Loop, %slotcount%
{
c += 1
if (slot%c%id = "")
{
;do nothing
}
else if (InStr(tables, slot%c%id, true, 0))
{
;do nothing
}
else
{
slot%c%id := ""
}
}
Loop, parse, tables, `,
{
id := A_LoopField
c := 0
has_slot := 0
custom := 1
first_available := slotcount+1
Loop, %slotcount%
{
c += 1
c1 := c
if (customfillorder)
{
c := IIf(ExFromList(customfillorder,c),ExFromList(customfillorder,c), c)
if (slot%c%id = "" && GetItemPos(customfillorder,c) < first_available )
{
first_available := GetItemPos(customfillorder, c)
custom := 1
}
}
else if (slot%c%id = "" && c < first_available )
{
first_available := c
}
if (slot%c%id = id)
{
has_slot := 1
}
c := c1
}
if (first_available > slotcount && has_slot=0)
{
TrayTip, PartyAHKPlanner, Too many tables, not enough slots, 10
WinClose, ahk_id%id%
}
else if (has_slot=0)
{
if (custom)
{
first_available := ExFromList(customfillorder,first_available)
}
slot%first_available%id := id
}
c := 0
Loop, %slotcount%
{
c += 1
if (slot%c%id = id)
{
IfWinExist, ahk_id%id%
{
WinGetPos, , , this_w, this_h, ahk_id%id%
if ((this_w > slot%c%w) || (this_w < slot%c%w) )
{
;WinMove, ahk_id%id%, , 0, 0 ; ### JUK: No need to do this at Party.
WinActivate,ahk_id%id%
win_adjustsize(id, slot%c%w)
Sleep, 40
}
WinGetPos, x, y, , , ahk_id%id%
if (x != slot%c%x || y != slot%c%y)
{
WinMove, ahk_id%id%, , slot%c%x, slot%c%y
}
}
Else
{
slot%c%id := ""
}
}
}
}
}
fixtables_config()
{
global slotcount
global customfillorder
WinGet, list, list, Party AHK Planner Slot #
tables := ""
Loop, %list%
{
tables := tables . "," . list%A_Index%
}
StringTrimLeft, tables, tables, 1
t := ""
GetKeyState, state, LButton
if (state = "D")
{
MouseGetPos, , , id
if (InStr(tables, id))
{
Sleep, 70
GetKeyState, state, LButton
if (state = "D")
{
Loop
{
Sleep, 10
GetKeyState, state, LButton
if (state = "U")
{
MouseGetPos, , , id
if (InStr(tables, id, true, 0))
{
WinGetPos, x, y, this_w, this_h, ahk_id%id%
o := 0
Loop, %slotcount%
{
o += 1
if (slot%o%id = id )
{
oldslot := o
break
}
}
c := slotcount + 1
Loop, %slotcount%
{
c -= 1
newslot := c
if (slot%c%x > (x) )
{
continue
}
else if (slot%c%y > (y) )
{
continue
}
else
{
break
}
}
t := slot%newslot%id
slot%newslot%id := slot%oldslot%id
slot%oldslot%id := t
}
break
}
}
}
}
else
{
;do nothing
}
}
c := 0
Loop, %slotcount%
{
c += 1
if (slot%c%id = "")
{
;do nothing
}
else if (InStr(tables, slot%c%id, true, 0))
{
;do nothing
}
else
{
slot%c%id := ""
}
}
Loop, parse, tables, `,
{
id := A_LoopField
c := 0
has_slot := 0
custom := 1
first_available := slotcount+1
Loop, %slotcount%
{
c += 1
c1 := c
if (customfillorder)
{
c := IIf(ExFromList(customfillorder,c),ExFromList(customfillorder,c), c)
if (slot%c%id = "" && GetItemPos(customfillorder,c) < first_available )
{
first_available := GetItemPos(customfillorder, c)
custom := 1
}
}
else if (slot%c%id = "" && c < first_available )
{
first_available := c
}
if (slot%c%id = id)
{
has_slot := 1
}
c := c1
}
if (first_available > slotcount && has_slot=0)
{
TrayTip, PartyAHKPlanner, Too many tables, not enough slots, 10
WinClose, ahk_id%id%
}
else if (has_slot=0)
{
if (custom)
{
first_available := ExFromList(customfillorder,first_available)
}
slot%first_available%id := id
}
c := 0
Loop, %slotcount%
{
c += 1
if (slot%c%id = id)
{
IfWinExist, ahk_id%id%
{
WinGetPos, , , this_w, this_h, ahk_id%id%
if ((this_w > slot%c%w) || (this_w < slot%c%w) )
{
WinMove, ahk_id%id%, , stot%c%x, slot%c%y, slot%c%w, slot%c%h
}
WinGetPos, x, y, , , ahk_id%id%
if (x != slot%c%x || y != slot%c%y)
{
WinMove, ahk_id%id%, , slot%c%x, slot%c%y
}
}
Else
{
slot%c%id := ""
}
}
}
}
}
;###########################################
;################# Lists ####################
;###########################################
;adds said item to the end of said list
AddToList(list,item,del=""){
del := IIf(del="",",",del)
If list =
return item
return list . del . item
}
;return item at said position in said list
ExFromList(list,pos=1,del="") {
del := IIf(del,del,",")
StringSplit, item, list, %del%
return item%pos%
}
;removes said item from said list
RemoveFromList(list,item=1,del="") {
del := IIf(del,del,",")
If InStr(list, item . del)
return StrRep(list, item . del, "", 0)
else if InStr(list, del . item, "", 0)
return StrRep(list, del . item, "", 0)
else if (item = list)
return
else
return list
}
;removes the nth item from said list
RemoveItemNFromList(list,n,del="") {
del := IIf(del,del,",")
return RemoveFromList(list, ExFromList(list,n,del))
}
;returns the position of said item in said list
;(0 if not in list)
GetItemPos(list,item,del="") {
del := IIf(del,del,",")
StringSplit, array, list, %del%
Loop %array0% {
If array%a_index% = %item%
return a_index
}
return 0
}
;inserts said item at said position in said list
InsertItem(list,item,pos,del="") {
del := IIf(del="",",",del)
StringSplit,array,list,%del%
Loop % IIf( ( pos < array0 ), array0, pos ) {
thisItem := array%a_index%
If ( a_index != pos )
newList = %newList%%del%%thisItem%
else
newList = %newList%%del%%item%%del%%thisItem%
}
If ( InStr(newList, ",",0,0) = StrLen(newList) )
StringTrimRight, newList, newList, 1
StringTrimLeft, newList, newList, 1
return newList
}
;removes empty items (and trailing delimiters)
CleanList(list, del="") {
If 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
}
List_longest(list, del="") {
del := IIf( del="", ",", del)
longest = 0
Loop, Parse, list, %del%
{
If (longest < StrLen(a_loopfield))
longest := StrLen(a_loopfield)
}
return longest
}
IIf(_boolExpr, _exprTrue, _exprFalse) {
If _boolExpr
Return _exprTrue
else
return _exprFalse
}
StrRep(str,char,rep_char="",all=1) {
StringReplace,str,str,%char%,%rep_char%,%all%
return str
}
GetPixelCount(x1, y1, x2, y2, color, options="")
{
CoordMode, Pixel, Screen
pixels := (x2 - x1 + 1)*(y2 - y1 + 1)
If ( pixels <= 0 )
{
ErrorLevel = 1
return
}
count = 0
x = %x1%
Loop
{
If ( x > x2 )
{
break
}
y = %y1%
Loop
{
If ( y > y2 )
{
break
}
PixelGetColor, c, x, y, %options%
If ( c = color )
{
count++
}
y++
}
x++
}
return count
}
DoPlanning:
fixtables()
return
DoPlanningConfig:
fixtables_config()
return
KeepLobbyUp:
SetTitleMatchMode, 2
WinGet, id, id, Poker Lobby
WinGet, ismin, MinMax, ahk_id%id%
If (ismin = -1)
{
WinRestore, ahk_id%id%
}
return
ExitSub:
return
;------------------------------------------------------------------------------------------
;;;;;;;;;;;;;;;;; CODE ENDS HERE]
Category: AutoHotkey


