Open Side Menu Go to the Top
Register
Bounty: Simple RNG for AHK Bounty: Simple RNG for AHK

02-08-2010 , 08:11 PM
I've been looking everywhere for a script that simply generates a random number and sends the resulting number as a keystoke. For example, hitting CTRL-R generates a number between 1 and 10 then sends a key stoke to 1-10 which ever it happens to choose.

The ultimate aim is to create a hotkey that will generate semi-random bet sizing. My idea was to use the script to send a command to Table Ninja which have assigned various standard bet sizes to the keys the AHK RNG would send keystokes to. For example, I set "1" in TN to be 50% pot, "2" to 67% pot, and "3" to 100% pot. So I hit CTRL-R and TN will input one of these into the bet box.

Basically what I want is an AHK script that will send a random keystroke (within a small range obv) to TN which in turn will input a bet. I asked Tarath several times in the TN thread, and while he said it would be easy to implement it never became a priority.

I can offer $25 (Stars transfer only) to the first person that can create such a script. It should be completely elementary to anyone with some experience with AHK. No fee is fine too considering it will likely take someone less time to generate the script than for me to write this email.

Alternative solutions to randomizing bet size are also welcome.

Thanks,
wm

P.S. There is an old and obsolete (and very awesome) AHK script called Poker Pad that had a command for random bet sizing. I think I found the relevant code in the script but really had no idea how to suit it to my uses:

http://www.autohotkey.net/~Xander/PokerPad/

What I thought was the relevant code was this from the main pokerpad.ahk:
Code:
}
	RandomMin = 0.25
	RandomMax = 1
	SetFactor("RandomMin")
	SetFactor("RandomMax")
	Relative1 = 0.25
	Relative2 = 0.333
	Relative3 = 0.5
	Relative4 = 0.667
	Relative5 = 0.75
	Relative6 = 0.9
	Relative7 = 1
	Relative8 = 1.5
	Relative9 = 2
	Fixed1 = 2
	Fixed2 = 3
	Fixed3 = 4
	Fixed4 = 5
	Fixed5 = 6
	Fixed6 = 7
	Fixed7 = 8
	Fixed8 = 9
	Fixed9 = 10
	local i, map0 := "Ins", map1 := "End", map2 := "Down", map3 := "PgDn", map4 := "Left", map5 := "Clear", map6 := "Right", map7 := "Home", map8 := "Up", map9 := "PgUp"
	local match, match0, match1, match2
	Loop, 9 {
		SetHotkey("Relative" . A_Index)
		SetFactor("Relative" . A_Index)
		local label := "Fixed" . A_Index
		IniRead, hotkey, PokerPad.ini, Hotkeys, Fixed%A_Index%, %A_Space%
		Loop, Parse, hotkey, |, %A_Space%
		{
			Hotkey, %A_LoopField%, %label%
			if RegExMatch(A_LoopField, "^([\^\!\+\#]+Numpad)(\d)$", match) {
				hotkey := match1 . map%match2%
				Hotkey, %hotkey%, %label%
			}
		}
		SetFactor("Fixed" . A_Index)
	}
and this from the functions.ahk :
Code:
GetRandomBet() {
	Random, factor, 25, 100
	return factor/100
Bounty: Simple RNG for AHK Quote
02-08-2010 , 08:21 PM
Quote:
Originally Posted by warmachine
For example, I set "1" in TN to be 50% pot, "2" to 67% pot, and "3" to 100% pot. So I hit CTRL-R and TN will input one of these into the bet box.
here, you can test this in notepad to ensure that the keys are getting sent. then test and make sure TN is recognizing it and let me know. obv you can change the min and max to what you need

Code:
#NoEnv
SendMode Input

minimum := 1
maximum := 3

^r::
   Random, randvar, %minimum%, %maximum%
   Send, {%randvar%}
return
Bounty: Simple RNG for AHK Quote
02-08-2010 , 08:31 PM
Sweet, I'll give it a shot after dinner.
Thanks for the quick work.
-wm
Bounty: Simple RNG for AHK Quote
02-08-2010 , 09:23 PM
Pretty much awesome. It's working well. I am using a gaming keypad with macros so all I had to do was bind CTRL-R to a key. Tested it in notepad then Stars and it works great. However, it will enter the keystroke in the text box if your cursor is over it. No biggie tho.

I knew the code would be simple. PM your Stars name if you'd like me to ship you $25.

Also, is it possible to add a modifier to the sent keystroke? For example, send "ALT-1" instead of "1", so I won't be randomly making random bets when I'm trying to write an email. I tried adding "^" in various places for CTRL-X, but couldn't get it to work.

I will now be playing GTO, so watch out.

Thanks again,
Bounty: Simple RNG for AHK Quote
02-09-2010 , 12:40 AM
Quote:
Originally Posted by warmachine

Also, is it possible to add a modifier to the sent keystroke? For example, send "ALT-1" instead of "1", so I won't be randomly making random bets when I'm trying to write an email. I tried adding "^" in various places for CTRL-X, but couldn't get it to work.
the ^r in the script is for the ctrl+R hotkey which generates and sends the random number.

i've changed it below so that it will send alt+number (its the ! symbol)

Code:
#NoEnv
SendMode Input

minimum := 1
maximum := 3

^r::
   Random, randvar, %minimum%, %maximum%
   Send, !%randvar%
return
so change your TN hotkeys to alt+1, alt+2, etc and give that a go
Bounty: Simple RNG for AHK Quote
02-09-2010 , 12:52 AM
Fixed it. May not be proper but:
Code:
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
;	Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


#NoEnv
SendMode Input

minimum := 1
maximum := 5

^r::
   Random, randvar, %minimum%, %maximum%
   Send, {Ctrl down} {%randvar%}
   Send, {Ctrl up}
return
Probably add more stuff now that greg nice gave me a good start.

-wm
Bounty: Simple RNG for AHK Quote
02-09-2010 , 01:09 AM
whatever works let me know if you run into problems with other stuff
Bounty: Simple RNG for AHK Quote

      
m