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)
-   -   Party SNG Joystick Script - Updated (http://archives1.twoplustwo.com/showthread.php?t=39097)

Bishop22 02-17-2006 03:33 AM

Party SNG Joystick Script - Updated
 
No idea if anyone is still using this, there has certainly been more advanced scripts posted lately but just in case anybody wants the updated version for the new Party software..here it is...

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Party SNG Joystick Script
;
;
; Joystick Portions Based on an original script by "illunious" at 2+2.
; Widget Portion Based on an original script by "SamIAm" at 2+2.
; Compiled and optimized for SNGs by Bishop22 at 2+2. 1/06
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Define keys for fold, check/call, and bet/raise
;
;;Joy1= Fold/Fold In Turn/Fold to any bet
;;Joy2= Check/Call
;;Joy3= Bet/Raise/All-in Button (as would appear to call an All-In)
;;Joy4= Send Tournament Summary and close ended tournament
;;Joy5= Left Click Mouse
;;Joy6= Bring Focus to Bet window and clear it
;;Joy7= Last Song - Winamp
;;Joy8= Next Song - Winamp
;;Joy9= All-In types "999999" in bet window, player needs to confirm by pressing
;; joy3 for 'Bet'.
;;Joy10= Buy-In to Tourny, once table is up pressing this key will Buy-In to seat 5
;; or seat 6 (this can be adjusted to you preference below)


;*****Joystick Portion***********

; Increase the following value to make the mouse cursor move faster:
; The setting of 1 is ideal for 8-tabling (pretty quick), you may want to go lower
; if you are playing 4 tables or less

; Increase the following value to make the mouse cursor move faster:
JoyMultiplier = 1

; Decrease the following value to require less joystick displacement-from-center
; to start moving the mouse. However, you may need to calibrate your joystick
; -- ensuring it's properly centered -- to avoid cursor drift. A perfectly tight
; and centered joystick could use a value of 1:
JoyThreshold = 3

; Change these values to use joystick button numbers other than 1, 2, and 3 for
; the left, right, and middle mouse buttons, respectively:
ButtonLeft = 5

; If your joystick has a POV control, you can use it as a mouse wheel. The
; following value is the number of milliseconds between turns of the wheel.
; Decrease it to have the wheel turn faster:
WheelDelay = 250

; If your system has more than one joystick, increase this value to use a joystick
; other than the first:
JoystickNumber = 1

; END OF CONFIG SECTION -- Don't change anything below this point unless you want
; to alter the basic nature of the script.

#SingleInstance

Hotkey, %JoystickNumber%Joy%ButtonLeft%, ButtonLeft

; Calculate the axis displacements that are needed to start moving the cursor:
JoyThresholdUpper = 50
JoyThresholdUpper += %JoyThreshold%
JoyThresholdLower = 50
JoyThresholdLower -= %JoyThreshold%

SetTimer, WatchJoystick, 10 ; Monitor the movement of the joystick.

GetKeyState, JoyInfo, %JoystickNumber%JoyInfo
IfInString, JoyInfo, P ; Joystick has POV control, so use it as a mouse wheel.
SetTimer, MouseWheel, %WheelDelay%


;************Widgets**************


;FOLD = Joy1; Will attempt to find fold buttons in the following order:
newButton("fold", 1, "AfxWnd4217") ;(
newButton("checkFoldInTurn", 1, "AfxWnd4223")
newButton("foldInTurn", 1, "AfxWnd4222")
newbutton("foldtoanybet", 1, "AfxWnd4240")

;CALL = Joy2; Will attempt to find check/call buttons in order:
newButton("call", 2, "Call (", 1)
newButton("check", 2, "AfxWnd4218") ;(
newButton("cInTurn", 2, "AfxWnd4224")
newButton("callbb", 2, "AfxWnd4225")

;RAISE = Joy3; Will attempt to find bet/raise buttons in this order:
newButton("bet", 3, "Bet", 1)
newButton("raise", 3, "Raise ", 1)
newButton("r1InTurn", 3, "AfxWnd4226")
newbutton("allin", 3, "AfxWnd42s16")

;Buyin to seat 5 or 6 can be adjusted by changing last number of var3
newButton("buyin5", 4, "AfxWnd428")
newButton("buyin6", 4, "AfxWnd429")



;;;;Joystick Button Assignments;;;


;Uses F3 F4; For Winamp Volume
F3::
WinActivate, ahk_class Winamp v1.x
MouseClick, WheelUp, , , 2
return
F4::
WinActivate, ahk_class Winamp v1.x
MouseClick, WheelDown, , , 2
return


Joy1::
MouseGetPos,,, curWin
WinActivate, ahk_id %curWin%
clickVis(1)
return
Joy2::
MouseGetPos,,, curWin
WinActivate, ahk_id %curWin%
clickVis(2)
return
Joy3::
MouseGetPos,,, curWin
WinActivate, ahk_id %curWin%
clickVis(3)
return
Joy4::
MouseGetPos,,, curWin
ControlCLick, Yes, ahk_id %curWin%
MouseGetPos,,, curWin
ControlClick, AfxWnd423, ahk_id %curWin%
WinWait, Welcome,,3
WinMinimize ;
return

;Joy5 is mapped to Left CLick in Joystick Portion

Joy6::
MouseGetPos,,, curWin
ControlClick, x355 y435, ahk_id %curWin%
Send {Del 4}
Send {BS 4}
return
Joy7::
WinActivate, ahk_class Winamp v1.x
Send z
return
Joy8::
WinActivate, ahk_class Winamp v1.x
Send b
return
Joy9::
MouseGetPos,,, curWin
ControlClick, x355 y435, ahk_id %curWin%
Send 999999
return


F1::BuyinPartA()
F2::BuyinPartB()

;Joy10:: ;;**Not working, commentted out**;;
;BuyinPartA()
;BuyinPartB()
;return

NumpadAdd::
MouseGetPos,,, curWin
ControlClick, x355 y435, ahk_id %curWin%
Send {Del 4}
Send {BS 4}
return


NumpadEnter::
clickVis(3)
return


F11::
debug()
return



return ; End of auto-execute section.


;***************Functions*********************
;*******Don't Change Anything Below***********

;Part A and B of Buying Function
;This is some serious donkey programming, couldn't figure
;out how to map the joystick to the entire buyin function

BuyinPartA()
{
ClickVis(4)
return
}

BuyinPartB()
{
Sleep, 300
WinActivate, Tournament
Control, Check,, Button2, Tournament
Winactivate, Tournament
ControlCLick, Button5, Tournament, NL,, 2, d
sleep, 50
ControlCLick, Button5, Tournament, NL,, 2, u
}


debug()
{
local but, num, Output
but = 1
Loop
{
if(but > numButtons)
break
num = 1
Loop
{
if(num > numButtons%but%)
break
if(visible(but,num) = 1)
Output = % Output . names%but%x%num% . " is visible.`n"
num += 1
}
but += 1
}
MsgBox %Output%
}

clickVis(button)
{
local output, i, isVis, currString, currMatch
WinGetTitle, winTitle, A
i = 1
Loop
{
if(i > numButtons%button%)
break
if (visible(button,i) = 1)
{
currMatch := matches%button%x%i%
SetTitleMatchMode, %currMatch%
currString := strings%button%x%i%
ControlClick, %currString%, %winTitle%
break
}
i += 1
}
}

visible(but, num)
{
local currentMatch, currentString
local output
currentMatch = % matches%but%x%num%
currentString = % strings%but%x%num%
SetTitleMatchMode % currentMatch
ControlGet, output, Visible, , %currentString%, %winTitle%
if output <> 1
{
output = 0
}
return output
}

newButton(name, button, string, match=3)
{
local buttonCount
numButtons += 1
numButtons%button% += 1
buttonCount := numButtons%button%
names%button%x%buttonCount% := name
matches%button%x%buttonCount% := match
strings%button%x%buttonCount% := string
}
; The subroutines below do not use KeyWait because that would sometimes trap the
; WatchJoystick quasi-thread beneath the wait-for-button-up thread, which would
; effectively prevent mouse-dragging with the joystick.

ButtonLeft:
SetMouseDelay, -1 ; Makes movement smoother.
MouseClick, left,,, 1, 0, D ; Hold down the left mouse button.
SetTimer, WaitForLeftButtonUp, 10
return

ButtonRight:
SetMouseDelay, -1 ; Makes movement smoother.
MouseClick, right,,, 1, 0, D ; Hold down the right mouse button.
SetTimer, WaitForRightButtonUp, 10
return

ButtonMiddle:
SetMouseDelay, -1 ; Makes movement smoother.
MouseClick, middle,,, 1, 0, D ; Hold down the right mouse button.
SetTimer, WaitForMiddleButtonUp, 10
return

WaitForLeftButtonUp:
GetKeyState, JoyStateLeft, %JoystickNumber%Joy%ButtonLeft%
if JoyStateLeft = D ; The button is still, down, so keep waiting.
return
; Otherwise, the button has been released.
SetTimer, WaitForLeftButtonUp, off
SetMouseDelay, -1 ; Makes movement smoother.
MouseClick, left,,, 1, 0, U ; Release the mouse button.
return

WaitForRightButtonUp:
GetKeyState, JoyStateRight, %JoystickNumber%Joy%ButtonRight%
if JoyStateRight = D ; The button is still, down, so keep waiting.
return
; Otherwise, the button has been released.
SetTimer, WaitForRightButtonUp, off
MouseClick, right,,, 1, 0, U ; Release the mouse button.
return

WaitForMiddleButtonUp:
GetKeyState, JoyStateMiddle, %JoystickNumber%Joy%ButtonMiddle%
if JoyStateMiddle = D ; The button is still, down, so keep waiting.
return
; Otherwise, the button has been released.
SetTimer, WaitForMiddleButtonUp, off
MouseClick, middle,,, 1, 0, U ; Release the mouse button.
return

WatchJoystick:
MoveMouse? = n ; Set default.
SetFormat, float, 03
GetKeyState, joyx, %JoystickNumber%JoyX
GetKeyState, joyy, %JoystickNumber%JoyY
if joyx > %JoyThresholdUpper%
{
MoveMouse? = y
DeltaX = %joyx%
DeltaX -= %JoyThresholdUpper%
}
else if joyx < %JoyThresholdLower%
{
MoveMouse? = y
DeltaX = %joyx%
DeltaX -= %JoyThresholdLower%
}
else
DeltaX = 0
if joyy > %JoyThresholdUpper%
{
MoveMouse? = y
DeltaY = %joyy%
DeltaY -= %JoyThresholdUpper%
}
else if joyy < %JoyThresholdLower%
{
MoveMouse? = y
DeltaY = %joyy%
DeltaY -= %JoyThresholdLower%
}
else
DeltaY = 0
if MoveMouse? = y
{
DeltaX *= %JoyMultiplier%
DeltaY *= %JoyMultiplier%
SetMouseDelay, -1 ; Makes movement smoother.
MouseMove, %DeltaX%, %DeltaY%, 0, R
}
return

MouseWheel:
GetKeyState, JoyPOV, %JoystickNumber%JoyPOV
if JoyPOV = -1 ; No angle.
return
if (JoyPOV > 31500 or JoyPOV < 4500) ; Forward
Send {WheelUp}
else if JoyPOV between 13500 and 22500 ; Back
Send {WheelDown}
return

RETURN

jmillerdls 02-17-2006 05:34 AM

Re: Party SNG Joystick Script - Updated
 
If I had any clue what this did...I might be interested.

Bishop22 02-17-2006 06:37 AM

Re: Party SNG Joystick Script - Updated
 
[ QUOTE ]
If I had any clue what this did...I might be interested.

[/ QUOTE ]

It allows you to use a joystick to multitable, the analog joystick moves the mouse and buttons' functions are descibed in the comments:

;;Joy1= Fold/Fold In Turn/Fold to any bet
;;Joy2= Check/Call
;;Joy3= Bet/Raise/All-in Button (as would appear to call an All-In)
;;Joy4= Send Tournament Summary and close ended tournament
;;Joy5= Left Click Mouse
;;Joy6= Bring Focus to Bet window and clear it
;;Joy7= Last Song - Winamp
;;Joy8= Next Song - Winamp
;;Joy9= All-In types "999999" in bet window, player needs to confirm by pressing
;; joy3 for 'Bet'.
;;Joy10= Buy-In to Tourny, once table is up pressing this key will Buy-In to seat 5

MrGunner 01-07-2007 01:36 PM

Re: Party SNG Joystick Script - Updated
 
I would love this to work but I donīt seem to get all the buttons to work. Is that because of Party update or my gamepad?

Bishop22 01-07-2007 01:41 PM

Re: Party SNG Joystick Script - Updated
 
The buttons have changed numerous times since the last time I updated this, since I am a US player I don't play on Party. You could try table navigator from the FAQ or use window spy (part of AHK) to update my script.

MrGunner 01-07-2007 01:57 PM

Re: Party SNG Joystick Script - Updated
 
Ok, I will try that. Thanks


All times are GMT -4. The time now is 01:53 PM.

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