Two Plus Two Older Archives  

Go Back   Two Plus Two Older Archives > Internet Gambling > Internet Gambling
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-17-2005, 07:26 PM
Guest
 
Posts: n/a
Default Game pad & AHK script - adding direction pad?

I am using the AHK script below w/ a game pad. It works great as is, but my mouse-induced tendonitis requires a change. I would like to use direction pad (joypov) to select/move between tables, but this isn't recognized as an AHK. It can be used I think as a "GetKeyState" but I don't know how to do this. Can anyone tell me how to incorporate joypov into the script below (it would replace the commands toward the end that use Joy5,6,7 and 8)?


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Party Poker Keyboard Shortcuts
;
; Distributed the Online Poker FAQ
; See http://www.onlinepokerfaq.com/guide/...ess-poker.html
;
; Based on an original script by "illunious" at 2+2, posted 8/18/2004.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Define keys for fold, check/call, and bet/raise
;
; The key for each action is defined by the string before the double colon.
; You can change the key like this:
; Regular keys: a, b, c, 1, 2, 3, etc.
; Function keys: F1, F2, etc.
; Numeric keypad: Numpad1, Numpad2, NumpadPlus, etc
; Arrows keys: Left, Right, Up, Down
; Control key prefix: add caret in front, like this: ^f, ^c, ^r
; Alt key prefix: add exclamantion point in front: !f, !c, !r
; Windows key prefix: add hash mark in front: #f, #c, #r

; Fold (left most button)
joy1::
;MouseClick, left, 240, 474
;Sleep, 100
MouseClick, left, 240, 474
Sleep, 100
return

; Check/Call (middle button)
joy4::
;MouseClick, left, 385, 474c
;Sleep, 100
MouseClick, left, 385, 474
Sleep, 100
return

; Bet/Raise (right most button)
joy3::
;MouseClick, left, 550, 474
;Sleep, 100
MouseClick, left, 550, 474
Sleep, 100
return

; AutoPost
joy9::
MouseClick, left, 14, 533
Sleep, 100
return

; Deal me out
joy10::
MouseClick, left, 14, 568
Sleep, 100
return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Define keys for relative motion to the right, to the left, etc.
; For example, "Numpad6" goes one window to the right.
; This depends on where the mouse starts.

; WindowLeft
Left::
CoordMode, Mouse, Relative
MouseMove,-400,300
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
return

; WindowDown
Down::
CoordMode, Mouse, Relative
MouseMove,400,900
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
return

; WindowRight
Right::
CoordMode, Mouse, Relative
MouseMove,1200,300
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
return

; WindowUp
Up::
CoordMode, Mouse, Relative
MouseMove,400,-300
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Define keys for absolute mouse motion to a particular window.
; For example, "Numpad7" always goes to the upper-left window.
; This does not depend on where the mouse starts.

; WindowNW
joy5::
CoordMode, Mouse, Screen
MouseMove,400,300
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
return

; WindowNE
joy6::
CoordMode, Mouse, Screen
MouseMove,1200,300
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
return

; WindowSW
joy7::
CoordMode, Mouse, Screen
MouseMove,400,900
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
return

; WindowSE
joy8::
CoordMode, Mouse, Screen
MouseMove,1200,900
MouseGetPos, curPosX, curPosY, curWin
WinGetTitle, title, ahk_id %curWin%
WinActivate, %title%
return
Reply With Quote
  #2  
Old 09-17-2005, 08:40 PM
MrMoo MrMoo is offline
Member
 
Join Date: Sep 2004
Posts: 43
Default Re: Game pad & AHK script - adding direction pad?

A couple of assumptions. I'm running at 1600x1200. I'm also running party. My joystick is identified by AHK as "1Joy". If you run the joystick test script in the AHK help file that will tell you what yours is running at. If you only have 1 joystick this will probably work as is. This script isn't very efficient. It's basically an endless loop so it uses a decent amount of CPU utilization. If you're running 4 games, pokertracker, AHK, and some other stuff, your system may slow down a bit. I tried adding a sleep statement at the end but I wasn't getting the desired response rate I needed to 4 table. This could probably be optomized but I haven't gone to the effort of doing so.

AHK identifies joystick movement by using the GetKeyState function. The direction pad uses the X and Y coordinates. X and Y coordinates vary between 0 and 100 where 50 is no movement (I believe this is right). So when you move the d-pad right joyx gets set to greater than 50. The script is basically a continuous loop looking for x or y to reach a threshold which indicates use of the d-pad. Once it detects this is moves up, down, left or right one exact screen width or height of a party window (795x581). So if your mouse is on the fold button and you click up, it will move the mouse to the window above and it will be on the fold button on that window. It also activates the window. Lastly it does some checking that it can actually move to that window. So if you have a 4 table layout, your on the bottom window and you click down, it won't move because there is no table lower than that.

The formatting got a little messed up during copy/paste. Sorry.

<font class="small">Code:</font><hr /><pre>
#SingleInstance

CoordMode, Mouse
SetFormat, float, 03 ; Omit decimal point from axis position percentages

Hotkey, 1Joy1, Fold
Hotkey, 1Joy2, Call
Hotkey, 1Joy3, AutoPostBlind
Hotkey, 1Joy4, Talk
Hotkey, 1Joy5, Bet
Hotkey, 1Joy6, InsertBet

Loop
{
GetKeyState, joyx, 1JoyX
GetKeyState, joyy, 1JoyY
if joyx &gt; 75 ;Joystick Right
{
MouseGetPos, x, y
SysGet, VirtualWidth, 78 ;Get the computers full virtual resolution width
newX := x + 795
newY := y
if newX &lt; %VirtualWidth%
{
MouseMove, %newX%, %newY%, 2
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
WinActivate, ahk_id %winID%
}
}
if joyx &lt; 25 ;Joystick Left
{
MouseGetPos, x, y
if x &gt; 795
{
newX := x - 795
newY := y
MouseMove, %newX%, %newY%, 2
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
WinActivate, ahk_id %winID%
}
}
if joyy &gt; 75 ;Joystick Down
{
MouseGetPos, x, y
SysGet, VirtualHeight, 79 ;Get the computers full virtual resolution height
newX := x
newY := y + 581
if newY &lt; %VirtualHeight%
{
MouseMove, %newX%, %newY%, 2
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
WinActivate, ahk_id %winID%
}
}
if joyy &lt; 25 ;Joystick Up
{
MouseGetPos, x, y ;Get the mouses current position
if y &gt; 581 ;Check that the mouse is at least one "screen" down
{
newX := x ;Set the new x coordinate 0 pixels different
newY := y - 581 ;Set the new y coordinate 581 pixels up
MouseMove, %newX%, %newY%, 2 ;Move the mouse to the new coordinates
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
WinActivate, ahk_id %winID%
}
}
;Sleep, 100
}
return

Fold:
MouseGetPos, , , winID,
WinGetPos, x, y, w, h, ahk_id %winID%
newX := x + 245
newY := y + 475
WinActivate, ahk_id %winID%
BlockInput On
MouseClick, left, %newX%, %newY%
BlockInput Off
return

Call:
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
newX := x + 405
newY := y + 475
WinActivate, ahk_id %winID%
BlockInput On
MouseClick, left, newX, newY
BlockInput Off
return

Bet:
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
newX := x + 565
newY := y + 475
WinActivate, ahk_id %winID%
BlockInput On
MouseClick, left, newX, newY
BlockInput Off
return

AutoPostBlind:
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
newX := x + 15
newY := y + 535
WinActivate, ahk_id %winID%
BlockInput On
MouseClick, left, newX, newY
BlockInput Off
return

InsertBet:
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
newX := x + 360
newY := y + 440
WinActivate, ahk_id %winID%
BlockInput On
MouseClick, left, newX, newY
MouseClick, left, newX, newY
Send, {BS}
Sleep, 100
BlockInput Off
return

Talk:
MouseGetPos, , , WinID,
WinGetPos, x, y, w, h, ahk_id %winID%
newX := x + 200
newY := y + 570
WinActivate, ahk_id %winID%
BlockInput On
MouseClick, left, newX, newY
MouseClick, left, newX, newY
Send, {BS}
Sleep, 100
BlockInput Off
return

</pre><hr />
Reply With Quote
  #3  
Old 09-17-2005, 09:19 PM
Guest
 
Posts: n/a
Default Re: Game pad & AHK script - adding direction pad?

Thanks. A couple questions: my monitor is 1400x1050. I don't know how to make that adjustment. Do you know if it is possible to easily add the part of your script that controls the direction pad to my script?
Reply With Quote
  #4  
Old 09-17-2005, 11:47 PM
MrMoo MrMoo is offline
Member
 
Join Date: Sep 2004
Posts: 43
Default Re: Game pad & AHK script - adding direction pad?

Now that I'm thinking about it, it should work fine with your resolution. The only time the resolution comes into play is when it looks to see if it can move windows. For example, if your on the bottom window, and you click down, it takes the current mouse position, adds the distance in pixels of a party window down, and if it exceeds the resolution of your monitor, it won't move.

If you have overlapping screens, this script might not work.

I'd just try the script out and see if it works.
Reply With Quote
  #5  
Old 09-18-2005, 12:19 AM
Guest
 
Posts: n/a
Default Re: Game pad & AHK script - adding direction pad?

Glad to hear about the pixels.
I tried it and it doesn't work. But I don't even know how to format it. When I pasted it into notepad all of the code took up 3 lines. I don't know if this is cosmetic or relevant...
Reply With Quote
  #6  
Old 09-18-2005, 12:57 AM
MrMoo MrMoo is offline
Member
 
Join Date: Sep 2004
Posts: 43
Default Re: Game pad & AHK script - adding direction pad?

PM me your email and I'll send it that way.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:14 AM.


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