Auto timebank clicker for microgaming

  • 7 replies
    • RasTweet
      RasTweet
      Bronze
      Joined: 26.12.2009 Posts: 4,553
      :O I didn't even know that was possible :facepalm: But I rarely need the timebank though.
    • acetbfish
      acetbfish
      Bronze
      Joined: 11.03.2011 Posts: 804
      For anyone interested in an auto timebank clicker for microgaming, here is a working script (taken from 2+2):
      code:
      ;Prima Auto Time Bank v0.1
      ;writen by boske @ 2+2 forums
      
      ;settings
      clearChat := 1 ;set to 0 for use with the grabber
      
      ;start of code
      #persistent
      #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
      #SingleInstance Force
      SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
      SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
      
      SysGet, border, 32
      SysGet, caption, 4
      caption := border + caption
      tableSize := 0
      SetControlDelay -1
      
      player_action = bet, called, raised, went all-in, posted, wins, returned, folded, shows, mucked, checked
      
      SetTimer, UpdateTables, 1000
      return
      
      UpdateTables:
      SetTitleMatchMode 2
      winget, tables, list, ahk_class GFX_INT_DLG_WINDOW_GAME
      
      loop, %tables%
      {
      
      
      	id := tables%a_index%
      	clicked_%id% := clicked_%id%
      
      	WinGetTitle, title, ahk_id%id%
      	
              StringReplace, title, title, €, $, All
      	StringReplace, title, title, £,$,All
      	
      
      
              if(!hero)
      	{
      	  StringMid, hero, title, InStr(title, " - $")-1, , L
      
      	  StringTrimLeft, hero, hero, InStr(hero, " - ", true, 0)+2
      	}
      
      
      	tablename := SubStr(title,Instr(title, "$"))
      	tablename := SubStr(tablename,Instr(tablename, " ")+3)
      	StringLeft, tablename, tablename, Instr(tablename,"[")-2
      
      	WinGet, maximized, MinMax, ahk_id %id%
      	if (maximized = -1)
      		continue ;check other tables
      
      	tablesize := GetTableSize(id)
      	
      	checkTable(id)
      	
      }
      return
      
      checkTable(id)
      {
      	global tablesize, hero, player_action, ClearChat
      	
      	ControlGetText, hh, RichEdit20W1, ahk_id%id%
      	if(ClearChat)
      	{
      	  ControlSetText, RichEdit20W1, , ahk_id%id% ; blank the chat so any changes to the chatbox can be easily detected and appended in future SetText commands
      	}
      
      	loop, Parse, hh, `n
      	{
      		if InStr(a_loopfield, "posted small blind")
      		{
      			first_line := a_index ; first line of current hand
      		}
      
      		if(InStr(a_loopfield, hero) && InStr(a_loopfield, "to respond"))
      		{
      ; > hero, you have 10 seconds to respond
      			StringTrimLeft, timeleft, a_loopfield, InStr(a_loopfield, "have ")+4
      			timeleft := SubStr(timeleft, 1, InStr(timeleft, " ")-1)
      ;msgbox %timeleft%
      			if(timeleft == 10 && clicked_%id% == 0)
      			{
      			  timeNeeded := 1
      			}
      		}
      		else
      		{ ;only if last action
      			if( a_loopfield contains player_action )
      			{
      				timeNeeded := 0
      				clicked_%id% := 0
      			}
      		}
      	}
      	if(timeNeeded)
      	{	
      		clickTimeBank(id)
      		clicked_%id% := 1
      	}
      	if(ClearChat)
      	{
      		loop, Parse, hh, `n
      		{
      			if(a_index >= first_line) ;current hand
      			{
      				if (hh3 == "")
      				  hh3 := a_loopfield	
      				else
      				  hh3 := hh3 . "`n" . a_loopfield ; append lines of active hand
      			}
      		}
      
      		;detect changes to the chatbox since blanked
      		ControlGetText, hh4, RichEdit20W1, ahk_id%id%
      		If hh4 <> ""
      		  hh3 := hh3 . hh4 ; append any changes in the chatbox to hh3
      
      		ControlSetText, RichEdit20W1, %hh3%, ahk_id%id%
      	}
      }
      
      clickTimeBank(id)
      {
      	global tablesize, border
      
      	if(tablesize == 2)
      	{
      		PostLeftClick(345,200,id,0)
      	}
      	if(tablesize == 3)
      	{
      		PostLeftClick(440,395,id,0)
      	}
      	if(tablesize == 1)
      	{
      		x := 440
      		y := 400
      		WinGetPos, , ,w , , ahk_id %id%
      		w := w - (2*border)
      		factor := w/808
      
      		x := Round(x*factor)
      		y := Round(y*factor)
      		
      		PostLeftClick(x,y,id,0)
      	}
      
      
      }
      
      
      ;returns 1 if normal table, 2 if mini table, 3 if large table
      getTableSize(id)
      {
      	WinGetPos, , ,w ,h , ahk_id %id%
      
      	if (h == 367)
      		return 2
      	if (w == 1024)
      		return 3
      	else
      		return 1
      }
      
      
      ;Juks rocks
      PostLeftClick(x, y, table_id, activate=0) {
      ; ### JUK: Send the down left click, then the mouse-up messages.
      ; NOTE: This is relative to the top left of the client area and NOT the top left of the
      ;       window (ie: It *doesn't* include the title-bar like AHK's MouseClick does!!!).
      If activate
       WinActivate, ahk_id%table_id%
      PostMessage, 0x201, 0x0001, ((y<<16)^x), , ahk_id%table_id%
      PostMessage, 0x202 , 0, ((y<<16)^x), , ahk_id%table_id%
      }
    • geoka1
      geoka1
      Platinum
      Joined: 30.08.2008 Posts: 480
      nice. but what do i have to do with this?
    • acetbfish
      acetbfish
      Bronze
      Joined: 11.03.2011 Posts: 804
      Go here: http://www.autohotkey.com/ and download the programme.
      After downloading it, create a notepad and copy-paste the code. Save the notepad with the name [whatever name you want].ahk (not .txt which is the default notepad's extension) and then just run it. Maybe you need to run it with administrator rights, but I'm not sure about that.
    • geoka1
      geoka1
      Platinum
      Joined: 30.08.2008 Posts: 480
      thank you. it is little bit complicated for me but i will try it.
    • RasTweet
      RasTweet
      Bronze
      Joined: 26.12.2009 Posts: 4,553
      Haven't tried it yet but thanks acebtfish!
    • janmat70
      janmat70
      Basic
      Joined: 10.05.2009 Posts: 5
      This script work now? can anyone confirm?