Two Plus Two Newer Archives

Two Plus Two Newer Archives (http://archives1.twoplustwo.com/index.php)
-   Software (http://archives1.twoplustwo.com/forumdisplay.php?f=47)
-   -   ahk Colored Stacks (http://archives1.twoplustwo.com/showthread.php?t=541189)

Maunzekater 11-08-2007 08:51 AM

ahk Colored Stacks
 
Does anyone use this script and gets the same error:

"Error at line 191.
Line text: Convert(show)
Error: Duplicate function definition
The program will exit."

I tried it with all versions of Roland's Functions, without success.

PLOlover 11-09-2007 12:09 AM

Re: ahk Colored Stacks
 
anything like this for stars?

also OP there are 2 or 3 rolands functions you might have wrong one.

Maunzekater 11-09-2007 12:12 AM

Re: ahk Colored Stacks
 
There are 3 roland's functions, tried them all.

I doubt that there is a script like this for stars, because you need FreePHH running for party and there is AFAIK no similar software for stars.

Damn, really need this script, i steal too much against short stacks :/

PLOlover 11-09-2007 04:21 PM

Re: ahk Colored Stacks
 
well if you know any basic programming, it's telling you the convert() function if defined twice. so you could try to fix it i guess.

if you don't, just search the file in notepad for "convert(" without quotes, and trial and error comment out the lines that have it, one at a time, and it might work.

comment out is put a ";" (no quotes) first thing on the line.

convert() ; this is comment area

;convert() now the whole line is comment

Maunzekater 11-09-2007 05:07 PM

Re: ahk Colored Stacks
 
The problem is, there is only one convert() function.

I am a computer vision student, i should have mentioned that i did that already [img]/images/graemlins/smile.gif[/img]

When i start the script, it creates an .exe file and another ahk file. I don't know why this is necessary, the created file looks the exactly same as the former script.

I will have a look at it tomorrow, maybe i can fix it.

_dave_ 11-09-2007 06:53 PM

Re: ahk Colored Stacks
 
[ QUOTE ]

When i start the script, it creates an .exe file and another ahk file. I don't know why this is necessary, the created file looks the exactly same as the former script.


[/ QUOTE ]

Wait what? An EXE file? I don't think that should be there and sounds dangerous imo.

It should create new AHK files (one per table it is watching).

At a guess I'd say Convert first appeared in this script then later in Functions or something, producing the duplicate.

Maunzekater 11-10-2007 07:56 AM

Re: ahk Colored Stacks
 
I am sorry, of course the script does not create an .exe, but an .ini file. My bad.

Was too late yesterday.

Maunzekater 11-10-2007 08:32 AM

Re: ahk Colored Stacks
 
Ok, i fixed it. There is another convert() function in roland's function, which is included. That one takes 2 arguments instead on one, like in ColoredStacks.ahk

It really sucks and i didn't expect it, but ahk does not differentiate between functions that take a different number of arguments. No fun if you include a big file and the function namespace is already cluttered up.

Maunzekater 11-10-2007 08:35 AM

Re: ahk Colored Stacks
 
Hmmm.... the script runs now but i don't see any effect at all after playing for 10 minutes. FreePGH is running, i don't know what is wrong.

donkraft 11-11-2007 12:55 PM

Re: ahk Colored Stacks
 
I have the script running and working with Party SNGs. As far as I remember, I had to manually fix the convert() function. I believe I renamed the one in the Chipstackcolor script and renamed references to it.

I'll post it here, search for ConvertCS - those are the ones I renamed.

;------------ ColoredStacks v1.06 ---------------

; date: 7:55 PM Monday, April 02, 2007
; by Roland

#NoEnv
#SingleInstance force
#Include %a_scriptDir%
#Include Functions.ahk

SetWorkingDir %a_scriptDir%

OnExit HandleExit

SetTitleMatchMode 3
DetectHiddenWindows On

IsCompiled()
CheckAHKVersion("1.0.46.09")

ini = Stacks.ini
version = ColoredStacks v1.06

IfNotExist %ini%
FileAppend, % Colors_(), %ini% ;just what I plugged in

IniWrite, Dummy.exe, %ini%, General, exe

Install()

TrayMenu()

SetTimer, Tables, 1000
return

Tables:
list := TableIDListParty(LobbyIDParty())
Loop, Parse, list, `,
{
IfWinExist ColoredStacksGui%a_loopfield% ahk_classAutoHotkeyGUI ;if we alrady have one
continue
Run "AutoHotkey.exe" "/f" "_Colored_Stacks_.ahk" "%a_loopfield%" ;pass the id as parameter
WinWait ColoredStacksGui%a_loopfield%,, 20 ;wait for the gui to exist
}
return

;notifies every instance to update settings
SettingsChange() {
Critical
SetTitleMatchMode 1
WinGet, list, list, ColoredStacksGui ahk_classAutoHotkeyGUI
Loop %list% {
thisID := list%a_index%
PostMessage, 0x5556,,,, ahk_id%thisID% ;post exit msg
}
}

;shut down every instance
HandleExit:
Critical
SetTitleMatchMode 1
WinGet, list, list, ColoredStacksGui ahk_classAutoHotkeyGUI
Loop %list% {
thisID := list%a_index%
PostMessage, 0x5555,,,, ahk_id%thisID% ;post exit msg
}
ExitApp

Conf:
Thread NoTimers
Gui +Lastfound +Toolwindow
Hotkey, IfWinActive, % "ahk_id" WinExist()
Hotkey, tab, Tab
Gui, Margin, 5, 5
Gui, Font,, Comic Sans MS
IniRead, totalRanges, %ini%, Ranges, totalRanges, 10
Gui, Add, Text, Section, Upper bound:
Loop % totalRanges {
IniRead, u, %ini%, Upper, upper%a_index%, % a_index * 20
Gui, Add, Edit, vu%a_index% xs wp h20, % u
}
Gui, Add, Text, ys Section, Color:
Loop % totalRanges {
IniRead, lv%a_index%, %ini%, Colors, color%a_index%
c := lv%a_index%
Gui, Add, ListView,
(
vlv%a_index% xs -Hdr r1 -Multi -Tabstop
w150 Background%c%
Altsubmit gConfColor
), 1|2
}
IniRead, trans, %ini%, General, trans, 80
Gui, Add, Text, x5 Section, Transparency:
Gui, Add, Edit, vtrans wp h20, %trans%
;Gui, Add, Text, ys, PartyGaming exe:
;IniRead, exe, %ini%, General, exe, %a_space%
;Gui, Add, Edit, vexe wp+25 h20 Section, %exe%
;Gui, Add, Button, h20 ys gConfExe, ...
Gui, Add, Button, x5 h20 Section +default, &Submit
Gui, Add, Button, ys h20, &Cancel
Gui Show,, Ranges and Colors
return

Tab:
GuiControlGet, f, focusV
StringTrimLeft, n, f, 1
If ( n != totalRanges ) {
SendPlay {tab}
return
}
GuiControl, Focus, u1
SendPlay ^{a}
return

ButtonSubmit:
Gui Submit
Loop % totalRanges {
IniWrite, % u%a_index%, %ini%, Upper, upper%a_index%
IniWrite, % lv%a_index%, %ini%, Colors, color%a_index%
}
IniWrite, %trans%, %ini%, General, trans
IniWrite, %exe%, %ini%, General, exe
Gui Destroy
SettingsChange()
return

ButtonCancel:
GuiClose:
GuiEscape:
Gui Destroy
return

ConfColor:
If ( a_guiControlEvent != "normal" )
return
c := ColorPicker()
If ( c="" )
return
GuiControl, +Background%c%, % a_guiControl
%a_guiControl% = %c%
return

ConfExe:
Gui +OwnDialogs
FileSelectFile, f, 1, %a_programFiles%\PartyGaming
, Please select the PartyGaming executable:, *.exe
If ( f="" )
return
GuiControl,, exe, % f
return

TrayMenu() {
global
Menu, Tray, NoStandard
Menu, Tray, DeleteAll
Menu, Tray, Add, &Help, Help
Menu, Tray, Default, &Help
Menu, Tray, Add
Menu, Tray, Add, &About, About
Menu, Tray, Add
Menu, Tray, Add, &Settings, Conf
Menu, Tray, Add
Menu, Tray, Add, E&xit, Exit
Menu, Tray, Tip, %version%
}

Help:
Run % Web() "http://www.overcards.com/wiki/moin.cgi/ColoredStacks"
return

About:
TrayTip, %version%, Author: Roland`nE-mail: Roland@overcards.com,,1
return

Exit:
ExitApp

Colors_() {
c =
(
[Colors]
color1=00FF00
color2=80FF00
color3=FFFF00
color4=FF0000
color5=FF8040
color6=ED7700
color7=800000
color8=0080C0
color9=005580
color10=0000A0
)
return c
}

Install() {
FileDelete, _Colored_Stacks_.ahk
FileRead, code, %a_scriptName%
name = ColoredStacks
start =
(
############## %name% ##############
)
StringTrimLeft, code, code, InStr(code, start) - 2
StringTrimRight, code, code, 4
FileAppend, %code%, _Colored_Stacks_.ahk
}

/*
;############## ColoredStacks ##############

#NoEnv
#NoTrayIcon
#SingleInstance off
#Include %a_scriptDir%
#Include Functions.ahk

SetWorkingDir %a_scriptDir%

SetBatchLines -1 ;only to spped-up the launch

OnExit HandleExit

OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x204, "WM_RBUTTONDOWN")
OnMessage(0x5555, "ExitMsg")
OnMessage(0x5556, "Settings") ;gets sent when the user hits Submit in conf Gui

format = txt ;can be changed to hhf when testing with FPHG

ini = Stacks.ini

Settings()

;"fr" for fullRing - whatever
frX = 475,651,693,646,458,216,41,5,47,222
frY = 69,124,218,369,394,394,352,223,103,69
StringSplit, frX, frX, `,
StringSplit, frY, frY, `,

timer = 1000

targetID = %1% ;the command line param

myScreenName := MyScreenName(targetID)
gameType := gameTypeParty(WinGetTitle(targetID))

Gui +Lastfound +AlwaysOnTop +Toolwindow
Gui, Color, White ;figured noone would want white
WinSet, TransColor, White %trans%
Gui -Caption
Loop 10 {
Gui, Add, Progress, vp%a_index% BackgroundWhite ;initially transparent
;remove the border (this style might get lost when moving/showing ctrls later; we'd have to do this again)
Control, ExStyle, -0x20000, msctls_progress32%a_index%
}
Gui Show, Hide, ColoredStacksGui%targetID% ;a hopefully unique title...

6max = 0
WinWaitStatic(targetID, 2000, 5000) ;wait until PartyPlanner's done moving it etc.
If ( WinMinMax(targetID) != -1 ) {
;this makes the pixel search thing somewhat reliable
WinSet, AlwaysOnTop, On, ahk_id%targetID%
6max := Is6max(targetID)
WinSet, AlwaysOnTop, Off, ahk_id%targetID%
}

SetBatchLines 30 ;we can set this even higher probably, please experiment

SetTimer, ShowHide, %timer%
return

;------------ end of auto-execute section ---------------

;------ Settings -------

Settings() {
global
Critical
IniRead, totalRanges, %ini%, Ranges, totalRanges, 10
Loop % totalRanges {
IniRead, upper%a_index%, %ini%, Upper, upper%a_index%, % a_index * 10
IniRead, color%a_index%, %ini%, Colors, color%a_index%
}
IniRead, trans, %ini%, General, trans, 80
IniRead, exe, %ini%, General, exe, Dummy.exe
Gui +Lastfound
WinSet, TransColor, White %trans%
}

;------- ShowHide ---------

ShowHide:
If ! WinExist("ahk_id" targetID) ;if the table was closed, exit
exitApp
If ( WinMinMax(WinExist("a")) ;active window maximised, target minimized...
|| WinMinMax(WinExist("ahk_id" targetID)) = -1) {
Gui Hide
xp = -32000
} else {
Gui +AlwaysOnTop
WinGetPos, x, y, w, h, ahk_id%targetID%
If ( x != xp || y != yp || w != wp ) { ;target was moved/resized
xp = %x% ;set these to the new coords
yp = %y%
wp = %w%
Gui, Show, % "x" x+3 "y" y+26 "w" w-6 "h" h-29 "NoActivate"
cw := Floor( 101 / ( 796 - 3 ) * ( w - 3 ) ) ;width of the controls
ch := Floor( 35 / ( 579 - 26 ) * ( h - 26 ) ) ;height of the control
Loop 10 {
x := Floor( ( ( frX%a_index% - 3 ) / ( 796 - 3 ) ) * ( w - 3 ) ) ;x-position
y := Floor( ( ( frY%a_index% - 26 ) / ( 579 - 26 ) ) * ( h - 26 ) ) ;y-position
GuiControl, Move, p%a_index%, x%x% y%y% w%cw% h%ch% ;move it
}
}
}
handID := HandID(targetID) ;re-do colors after every hand
If ( handID != handID_p ) {
ColorStacks()
handID_p = %handID%
}
return

;--------- ColorStacks ----------

ColorStacks() {
global
Thread NoTimers
;returns the full path of the file where the hh for %targetID% resides (also works for FPHG)
file := HHFile(targetID, exe)
hh := HH(file, lastHandID(targetID)) ;grabs the hhs
;fills several arrays with names relative to seats, stacks relative to names etc
SeatsStacksNames(hh, targetID)
bb := GetBBParty(targetID, GameTypeParty(WinGetTitle(targetID))) ;get the bb
Loop 10 {
thisP := p(a_index, 6max) ;have to convert in case 6max
If ( sn%a_index%%TargetID% = ""
|| sn%a_index%%TargetID% = myScreenName ) { ;if no player, hide ctrl and skip rest of loop
GuiControl, Hide, p%thisP%
continue
}
GuiControl, Show, p%thisP% ;show in case it was hidden
invested := InvestedLastHand(hh, sn%a_index%%targetID%) ;$ won/lost on last hand
stack := Round( ( stack%a_index%%targetID% - invested ) / bb ) ;stack in BBs
If ( ! stack ) ;if stack couldn't be determined, hide ctrl
GuiControl, Hide, p%thisP%
If ( 6max && IsIn(a_index, "2,4,7,9") ) ;if we're 6max, hide these ctrls
GuiControl, Hide, p%a_index%
c := Color(stack) ;get the new color
GuiControl, +Background%c%, p%thisP% ;set the color
}
}

;-------- Color ------------

Color(bb) {
global
Loop % totalRanges {
lower := a_index - 1 ;lower bound is prev upper bound
If ( ! upper%lower% )
upper%lower% = 0
If IsBetween(bb, upper%lower%, upper%a_index%)
return % color%a_index% ;if it's in this range, return this color
}
return % color%totalRanges%
}

;--------- Toggle6max ---------

Toggle6max() {
global
ConvertCS(6max)
6max := 1 - 6max
ColorStacks()
}

;--------- p ----------

;converts seat positions for 6max
p(p, 6max) {
If ( ! 6max )
return p
If ( p = 1 )
return 1
If ( p = 2 )
return 3
If ( p = 3 )
return 5
If ( p = 4 )
return 6
If ( p = 5 )
return 8
If ( p = 6 )
return 10
}

;------- Convert --------

;convert to 6max / fullring
ConvertCS(show) {
local seats
seats = 2,4,7,9
Loop, Parse, Seats, `,
GuiControl, Show%show%, p%a_loopfield%
return
}

;--------- WM_LBUTTONDOWN ---------

;CTRL+LBUTTON toggles 6max, otherwise click
WM_LBUTTONDOWN() {
If ( GetKeyState("Ctrl") ) {
Toggle6max()
return
}
GuiControl, Hide, %a_guiControl%
Click
GuiControl, Show, %a_guiControl%
}

;--------- WM_RBUTTONDOWN ---------

;just click
WM_RBUTTONDOWN() {
GuiControl, Hide, %a_guiControl%
Click R
GuiControl, Show, %a_guiControl%
}

;--------- HandleExit ---------

HandleExit:
exitApp

/*


All times are GMT -4. The time now is 07:22 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.