| Senior Member
Join Date: Dec 2008
Posts: 357
Reputation: 23
 cBay Rating: | Need help making CL bot (Edited post to fit new situation
So I've gotten pretty far for a newb at AHK. I've been making a bot for CL that is identical to Revolver .357. I can see how it's creator might have struggled in it's creation. So far I've resorted to not make it silent, since, I have no idea how to do that with Controlclick. It's cause it uses the browser control in it's own GUI. And as to doing all three games at the same time, I can't figure out how to arrange the loops so they answer in rapid succession.
So I'm requesting some help here, and i'll post my source. I'm not planning on releasing it since there are probably better tools out there. That, and I used the code from DBN and an example I found.
So here's the source: Code: OnExit, WebTerminate
SetTitleMatchMode, 2
SetControlDelay -1
W := A_ScreenWidth-100
H := A_ScreenHeight-100
WinTitle = Be A Man v1.0
ChickMouseX := 317
ChickMouseY := 381
SpellMouseX := 320
SpellMouseY := 335
WordMouseX := 320
WordMouseY := 394
WinGet, WinID, ID, Be A Man v1.0
Delay := 1000
GUI:
Gui +LastFound
Gui Margin, 0, 0
Gui, Add, Tab2, h50 w%W% gMyTab vSelTab, Chicktionary|SpellingBee|WordSlugger
Gui, Tab, 1
Gui, Add, Button, x0 y25 w100 h20 gLoadGames, Load Games
Gui, Add, Edit, x100 y25 w380 h20 vletters1,
Gui, Add, Button, x480 y25 w100 h20 gGo1, Go!
Gui, Tab, 2
Gui, Add, Button, x0 y25 w100 h20 gLoadGames, Load Games
Gui, Add, Edit, x100 y25 w380 h20 vletters2,
Gui, Add, Button, x480 y25 w100 h20 gGo2, Go!
Gui, Tab, 3
Gui, Add, Button, x0 y25 w100 h20 gLoadGames, Load Games
Gui, Add, Edit, x100 y25 w380 h20 vletters3,
Gui, Add, Button, x480 y25 w100 h20 gGo3, Go!
GoSub, WebInit
Gui, Show, h420 w650, %WinTitle%
WinGet, WinID, ID, Be A Man v1.0
Return
WebInit:
GoSub, GuiStart
hGui := WinExist()
pwb1 := COM_AtlAxGetControl(COM_AtlAxCreateContainer(hGui, 0, 50, 650, 350, "Shell.Explorer"))
pwb2 := COM_AtlAxGetControl(COM_AtlAxCreateContainer(hGui, 0, 50, 650, 350, "Shell.Explorer"))
pwb3 := COM_AtlAxGetControl(COM_AtlAxCreateContainer(hGui, 0, 50, 650, 350, "Shell.Explorer"))
psink1 := COM_ConnectObject(pwb1, "Web1_")
psink2 := COM_ConnectObject(pwb2, "Web2_")
psink3 := COM_ConnectObject(pwb3, "Web3_")
OldhWnd := Chicktionary := GetHostWindow(pwb1)
SpellingBee := GetHostWindow(pwb2)
WordSlugger := GetHostWindow(pwb3)
WinHide, ahk_id %IE3%
COM_Invoke(pwb1, "Navigate", "http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1234036872&rver=5.5.4177.0&wp=MBI&wreply=http:%2F%2Fclub.live.com%2FPages%2FHome%2FHomePage.aspx%3Flc%3D1033&lc=1033&id=251128")
loop
If (rdy:=COM_Invoke(pwb1,"readyState") = 4)
break
Return
GuiStart:
COM_AtlAxWinInit()
Return
MyTab:
Gui, Submit, NoHide
WinHide, % "ahk_id " . OldhWnd
WinShow, % "ahk_id " . %SelTab%
OldhWnd := %SelTab%
Gui, Show
return
LoadGames:
COM_Invoke(pwb1, "Navigate", "http://club.live.com/Pages/Games/GamePlay.aspx?game=Chicktionary&mode=play")
;COM_Invoke(pwb2, "Navigate", "http://club.live.com/Pages/Games/GamePlay.aspx?game=Spelling_Bee&mode=play")
;COM_Invoke(pwb3, "Navigate", "http://club.live.com/Pages/Games/GamePlay.aspx?game=Word_Slugger&mode=play")
loop
If (rdy:=COM_Invoke(pwb1,"readyState") = 4)
break
Return
Go1:
Gui, Submit, NoHide
if ( StrLen( letters1 ) != 7 )
{
Msgbox, 16, Be A Man v.10, You must enter 7 letters.
return
}
File = %A_Temp%\CBot_tmp.htm
RunWait, curl.exe --output "%File%" --form-string "letters=%letters1%" -F "request=form" -F "sort=length" "http://www.anagrammer.com/",, UseErrorLevel Hide
CurlError := ErrorLevel
IfNotExist, %File%
{
Msgbox, 16, Be A Man v1.0, Failed to download word list. Error code: %CurlError%`nSee this page to get the code definition: http://curl.haxx.se/docs/manpage.html#EXIT
Gui, Show
return
}
FileRead, WordPage, %File%
FileDelete, %File%
StringGetPos, Position, WordPage, <p style='font-family:Verdana;'>
If ErrorLevel
{
Msgbox, 16, Be A Man v1.0, Anagrammer.com did not send a word list! The HTML it sent has been saved to the clipboard.
Clipboard := WordPage
return
}
StringTrimLeft, WordPage, WordPage, %Position%
StringLeft, WordPage, WordPage, % InStr( WordPage, "`n" ) ;%
; Interpret HTML
StringReplace, WordPage, WordPage, <br>, `n, All
StringReplace, WordPage, WordPage, , %A_Space%, All
WordList := ""
IsInTag := false
Loop, % StrLen( WordPage ) ;%
{
if IsInTag
{
if ( SubStr( WordPage, A_Index, 1 ) = ">" )
IsInTag := false
continue
}
if ( SubStr( WordPage, A_Index, 1 ) = "<" )
{
IsInTag := true
continue
}
WordList .= SubStr( WordPage, A_Index, 1 )
}
WordPage := ""
StringReplace, WordList, WordList, %A_Space%- bingo,, All
StringTrimRight, WordList, WordList, CPosition
StringReplace, Clipboard, WordList, `n, `r`n, All ; Save to the clipboard with the correct newline format for notepad.
if ( GetKeyState( "ScrollLock", "T" ) )
SetScrollLockState, Off
Aborted := false
Loop, Parse, WordList, `n, %A_Space%%A_Tab%1234567890
{
Sleep, %Delay%
if ( A_LoopField == "Chars" || A_LoopField = "" )
continue
if ( GetKeyState( "ScrollLock", "T" ) )
{
Aborted := true
break
}
WordLength := StrLen( A_LoopField )
if ( WordLength < 3 )
break
if ( WordLength > 7 )
{
Msgbox, 16, Chiktionary Bot, A word was recieved that is longer than 7 letters. Anagrammer.com probably didn't send a proper word list.
Clipboard := WordPage
Gui, Show
break
}
WinActivate, ahk_id %WinID%
Click, %ChickMouseX%, %ChickMouseY% ; Make sure the flash input is active.
SendRaw, %A_LoopField%
Send, {Click 493 381}{BS}{BS}{BS}{BS}{BS}{BS}{BS} ;
}
Aborted := false
;
;
;
;
; ;
;
;
;
Return
Go2:
Gui, Submit, NoHide
COM_Invoke(pwb2, "Navigate", Go1)
loop
If (rdy:=COM_Invoke(pwb2,"readyState") = 4)
break
Return
Go3:
Gui, Submit, NoHide
COM_Invoke(pwb3, "Navigate", Go1)
loop
If (rdy:=COM_Invoke(pwb3,"readyState") = 4)
break
Return
GuiClose:
WebTerminate:
Gui, Destroy
COM_Release(pwb1)
COM_Release(pwb2)
COM_Release(pwb3)
COM_AtlAxWinTerm()
ExitApp
Web1_NavigateComplete2(prms, this)
{
Global
GuiControl,text,page1,% COM_Invoke(pwb1, "LocationUrl")
}
Web2_NavigateComplete2(prms, this)
{
Global
GuiControl,text,page2,% COM_Invoke(pwb2, "LocationUrl")
}
Web3_NavigateComplete2(prms, this)
{
Global
GuiControl,text,page3,% COM_Invoke(pwb3, "LocationUrl")
}
GetHostWindow(pwb)
{
COM_GUID4String(IID_IOleWindow, "{00000114-0000-0000-C000-000000000046}")
DllCall(COM_VTable(pwb, 0), "Uint", pwb, "str", IID_IOleWindow, "UintP", pow)
DllCall(COM_VTable(pow, 3), "Uint", pow, "UintP", hWnd)
DllCall(COM_VTable(pow, 2), "Uint", pow)
Return DllCall("GetParent", "Uint", hWnd)
}
Yeah, half of it is copy paste of DBN source, the other half an example of IE controls. The problems I need solved are:
1. How can I make the bot silent, and still functional?
2. How can I run all the games at the same time, answering one after the other?
EDIT: Here's the compiled version of this source: http://rapidshare.com/files/195318632/BeAMan.exe |