Sign in to follow this  
Followers 0
Markus

Pinball and Minesweeper Bot

18 posts in this topic

#1 ·  Posted (edited)

Being bored at work with only having the stupid windows xp games Minesweeper and Pinball I wrote bots for both. Now I'm even more bored.

PinballBot:

start pinball (or add a shellexecute line) (doesn't work with fullscreen)

HotKeySet("^q","quit")
WinMove("3D-Pinball","",0,0)
WinActivate("3D-Pinball","")
WinWaitActive("3D-Pinball","")
$sumleft=PixelChecksum(159,429,173,454)
$sumright=PixelChecksum(197,429,210,454)
AutoItSetOption("SendKeyDownDelay",100)
AutoItSetOption("SendKeyDelay",200)
While 1
    If PixelChecksum(159,429,173,454)<>$sumleft Then Send("y")
    If PixelChecksum(197,429,210,454)<>$sumright Then Send("m")
WEnd
Func quit()
    Exit
EndFunc

And the more difficult

MinesweeperBot:

ShellExecute("C:\WINDOWS\system32\winmine.exe")
WinWaitActive("MineSweeper")
HotKeySet("^q","_quit")
HotKeySet("^h","_forhotkey")
WinActivate("MineSweeper")
WinMove("MineSweeper","",0,0)

Sleep(200)
;Dim $alltime=0
Dim $xstart=15
Dim $ystart=105
Dim $fieldwidth=16
Dim $fieldheight=16
Dim $fieldspos[31][17][2]
Dim $fieldsstates[31][17][3]
Dim $fieldsprocessed[31][17]
Dim $fieldinfluenced[31][17]

For $y=1 To 16
    For $x=1 To 30
        $fieldspos[$x][$y][0]=$xstart+($x-1)*$fieldwidth
        $fieldspos[$x][$y][1]=$ystart+($y-1)*$fieldheight
    Next
Next
;MsgBox(0,"",_field_get_numb(7,2))
;MsgBox(0,"",_field_get_col(13,5))
;MsgBox(0,"",_field_get_col(26,7))
;MsgBox(0,"",Hex(PixelGetColor($fieldspos[5][13][0]+7,$fieldspos[5][13][1]+7)))
;MsgBox(0,"",Hex(PixelGetColor(327,250)))
_scan()
While 1 
    _bot()
;_calculatestates()
WEnd
Func _forhotkey()
    $teststring=""
    For $y=1 To 16
        For $x=1 To 30
            If $fieldsstates[$x][$y][0]=10 Then
                $teststring&="x"
            Else
                $teststring&=$fieldsstates[$x][$y][0]
            EndIf
        Next
        $teststring&=@CRLF
    Next
    MsgBox(0,"",$teststring)
EndFunc
Func _scan()
    For $y=1 To 16
        For $x=1 To 30
            $fieldsstates[$x][$y][0]=_field_get_numb($x,$y)
        Next
    Next
    _calculatestates()
EndFunc
Func _bot()
    For $y=1 To 16
        For $x=1 To 30
            $fieldsprocessed[$x][$y]=0
        Next
    Next
    For $y=1 To 16
        For $x=1 To 30
            If $fieldsstates[$x][$y][0]>0 And $fieldsstates[$x][$y][0]<9 Then
                If $fieldsstates[$x][$y][0]-$fieldsstates[$x][$y][1]=$fieldsstates[$x][$y][2] Then 
                    _setflags($x,$y)
                EndIf
                If $fieldsstates[$x][$y][0]=$fieldsstates[$x][$y][1] And $fieldsstates[$x][$y][2]>0 Then 
                    _setopenfields($x,$y)
                EndIf
            EndIf
        Next
    Next
    $clicked=0
    For $y=1 To 16
        For $x=1 To 30
            If $fieldsprocessed[$x][$y]=1 Then $clicked=1
        Next
    Next
    If $clicked=0 Then 
;MsgBox(0,"Bot Message","Nothing found with usual way." & @crlf & "Starting special search.")
        _checkspecialmoves()
    EndIf
    $clicked=0
    For $y=1 To 16
        For $x=1 To 30
            If $fieldsprocessed[$x][$y]=1 Then $clicked=1
        Next
    Next
    If $clicked=0 Then 
        MsgBox(0,"Bot Message","Also special search doesn't help - you have to guess." & @crlf & "Over and Out")
        _scan()
        #cs
        For $y=1 To 16
            If $clicked Then ExitLoop
            For $x=1 To 30
                If $clicked Then ExitLoop
                If $fieldsstates[$x][$y][0]=0 Then
                    MouseClick("left",$fieldspos[$x][$y][0]+16,$fieldspos[$x][$y][1]+16,1,0)
                    $fieldsprocessed[$x][$y]=1
                    Sleep(50)
                    $fieldsstates[$x][$y][0]=_field_get_numb($x,$y)
                    If $fieldsstates[$x][$y][0]=9 Then
                        _scanaroundfield($x,$y)
                    EndIf
                    _calculatestatesaroundfield($x,$y)
                    $clicked=1
                EndIf
            Next
        Next
        #ce
    EndIf
EndFunc
Func _checkspecialmoves()
    For $y=1 To 16
        For $x=1 To 30
            For $yinner=1 To 16
                For $xinner=1 To 30
                    $fieldinfluenced[$xinner][$yinner]=0
                Next
            Next
            If $fieldsstates[$x][$y][0]>1 And $fieldsstates[$x][$y][0]<7 And $fieldsstates[$x][$y][2]>1 Then
                _search($x,$y)
            EndIf
        Next
    Next
EndFunc
Func _search($xfield,$yfield)
    For $i=1 To 8
        Switch $i
            Case 1
                $tmpx=$xfield-1
                $tmpy=$yfield-1
            Case 2
                $tmpx=$xfield-1
                $tmpy=$yfield
            Case 3
                $tmpx=$xfield-1
                $tmpy=$yfield+1
            Case 4
                $tmpx=$xfield
                $tmpy=$yfield+1
            Case 5
                $tmpx=$xfield+1
                $tmpy=$yfield+1
            Case 6
                $tmpx=$xfield+1
                $tmpy=$yfield
            Case 7
                $tmpx=$xfield+1
                $tmpy=$yfield-1
            Case 8
                $tmpx=$xfield
                $tmpy=$yfield-1
        EndSwitch
            
        If $tmpx>0 And $tmpx<31 And $tmpy>0 And $tmpy<17 Then
            If $fieldsstates[$tmpx][$tmpy][0]>0 And $fieldsstates[$tmpx][$tmpy][0]<6 Then
                _setinfluence($xfield,$yfield)
                _subtractinfluence($tmpx,$tmpy)
                $numbStillInfluenced=0
                For $y=1 To 16
                    For $x=1 To 30
                        If $fieldinfluenced[$x][$y]=1 Then $numbStillInfluenced+=1
                    Next
                Next
                If $fieldsstates[$xfield][$yfield][0]-$fieldsstates[$xfield][$yfield][1]-$fieldsstates[$tmpx][$tmpy][0]+$fieldsstates[$tmpx][$tmpy][1]=$numbStillInfluenced Then
                    For $y=1 To 16
                        For $x=1 To 30
                            If $fieldinfluenced[$x][$y]=1 And $fieldsprocessed[$x][$y]=0 Then 
                ;MsgBox(0,"Bot Message","Special search succesful" & @crlf & "flag on: " & @crlf & "x: " & $x & " y: " & $y & @crlf & @crlf & "reason:" & @crlf & "field: x:" & $xfield & " y: " & $yfield & @crlf &  "Still Influenced: " & $numbStillInfluenced)
                                MouseClick("right",$fieldspos[$x][$y][0]+5,$fieldspos[$x][$y][1]+5,1,0)
                                $fieldsprocessed[$x][$y]=1
                                $fieldsstates[$x][$y][0]=10
                                _calculatestatesaroundfield($x,$y)
                            EndIf
                        Next
                    Next
                EndIf
            EndIf
        EndIf
    Next
EndFunc
Func _setinfluence($xfield,$yfield)
    For $i=1 To 8
        Switch $i
            Case 1
                $tmpx=$xfield-1
                $tmpy=$yfield-1
            Case 2
                $tmpx=$xfield-1
                $tmpy=$yfield
            Case 3
                $tmpx=$xfield-1
                $tmpy=$yfield+1
            Case 4
                $tmpx=$xfield
                $tmpy=$yfield+1
            Case 5
                $tmpx=$xfield+1
                $tmpy=$yfield+1
            Case 6
                $tmpx=$xfield+1
                $tmpy=$yfield
            Case 7
                $tmpx=$xfield+1
                $tmpy=$yfield-1
            Case 8
                $tmpx=$xfield
                $tmpy=$yfield-1
        EndSwitch
            
        If $tmpx>0 And $tmpx<31 And $tmpy>0 And $tmpy<17 Then
            If $fieldsstates[$tmpx][$tmpy][0]=0 Then
                $fieldinfluenced[$tmpx][$tmpy]=1
            EndIf
        EndIf
    Next
EndFunc
Func _subtractinfluence($xfield,$yfield)
    For $i=1 To 8
        Switch $i
            Case 1
                $tmpx=$xfield-1
                $tmpy=$yfield-1
            Case 2
                $tmpx=$xfield-1
                $tmpy=$yfield
            Case 3
                $tmpx=$xfield-1
                $tmpy=$yfield+1
            Case 4
                $tmpx=$xfield
                $tmpy=$yfield+1
            Case 5
                $tmpx=$xfield+1
                $tmpy=$yfield+1
            Case 6
                $tmpx=$xfield+1
                $tmpy=$yfield
            Case 7
                $tmpx=$xfield+1
                $tmpy=$yfield-1
            Case 8
                $tmpx=$xfield
                $tmpy=$yfield-1
        EndSwitch
            
        If $tmpx>0 And $tmpx<31 And $tmpy>0 And $tmpy<17 Then
            If $fieldsstates[$tmpx][$tmpy][0]=0 Then
                $fieldinfluenced[$tmpx][$tmpy]=0
            EndIf
        EndIf
    Next
EndFunc
Func _field_get_col($xfield,$yfield)
    Return Hex(PixelGetColor($fieldspos[$xfield][$yfield][0]+10,$fieldspos[$xfield][$yfield][1]+10))
EndFunc
Func _field_get_numb($xfield,$yfield)
    $col=_field_get_col($xfield,$yfield)
    $numb=0
    If $col="00C0C0C0" Then $numb=0;field to click
    If $col="000000FF" Then $numb=1
    If $col="00008000" Then $numb=2
    If $col="00FF0000" Then $numb=3
    If $col="00000080" Then $numb=4
    If $col="?" Then $numb=5
    If $col="?" Then $numb=6
    If $col="?" Then $numb=7
    If $col="?" Then $numb=8
    If $col="00000000" Then $numb=10;fahne
    If $numb=0 Then
        If Hex(PixelGetColor($fieldspos[$xfield][$yfield][0],$fieldspos[$xfield][$yfield][1]))<>"00FFFFFF" Then
            $numb="9";open field
        EndIf
    EndIf
    Return $numb
EndFunc
Func _field_get_flags_around($xfield,$yfield)
    $numberflags=0
    For $i=1 To 8
        Switch $i
            Case 1
                $tmpx=$xfield-1
                $tmpy=$yfield-1
            Case 2
                $tmpx=$xfield-1
                $tmpy=$yfield
            Case 3
                $tmpx=$xfield-1
                $tmpy=$yfield+1
            Case 4
                $tmpx=$xfield
                $tmpy=$yfield+1
            Case 5
                $tmpx=$xfield+1
                $tmpy=$yfield+1
            Case 6
                $tmpx=$xfield+1
                $tmpy=$yfield
            Case 7
                $tmpx=$xfield+1
                $tmpy=$yfield-1
            Case 8
                $tmpx=$xfield
                $tmpy=$yfield-1
        EndSwitch
            
        If $tmpx>0 And $tmpx<31 And $tmpy>0 And $tmpy<17 Then
            If $fieldsstates[$tmpx][$tmpy][0]=10 Then $numberflags+=1
        EndIf
    Next
    Return $numberflags
EndFunc
Func _field_get_openfields_around($xfield,$yfield)
    $numberopenfields=0
    For $i=1 To 8
        Switch $i
            Case 1
                $tmpx=$xfield-1
                $tmpy=$yfield-1
            Case 2
                $tmpx=$xfield-1
                $tmpy=$yfield
            Case 3
                $tmpx=$xfield-1
                $tmpy=$yfield+1
            Case 4
                $tmpx=$xfield
                $tmpy=$yfield+1
            Case 5
                $tmpx=$xfield+1
                $tmpy=$yfield+1
            Case 6
                $tmpx=$xfield+1
                $tmpy=$yfield
            Case 7
                $tmpx=$xfield+1
                $tmpy=$yfield-1
            Case 8
                $tmpx=$xfield
                $tmpy=$yfield-1
        EndSwitch
            
        If $tmpx>0 And $tmpx<31 And $tmpy>0 And $tmpy<17 Then
            If $fieldsstates[$tmpx][$tmpy][0]=0 Then $numberopenfields+=1
        EndIf
    Next
    Return $numberopenfields
EndFunc
Func _setflags($xfield,$yfield)
    For $i=1 To 8
        Switch $i
            Case 1
                $tmpx=$xfield-1
                $tmpy=$yfield-1
            Case 2
                $tmpx=$xfield-1
                $tmpy=$yfield
            Case 3
                $tmpx=$xfield-1
                $tmpy=$yfield+1
            Case 4
                $tmpx=$xfield
                $tmpy=$yfield+1
            Case 5
                $tmpx=$xfield+1
                $tmpy=$yfield+1
            Case 6
                $tmpx=$xfield+1
                $tmpy=$yfield
            Case 7
                $tmpx=$xfield+1
                $tmpy=$yfield-1
            Case 8
                $tmpx=$xfield
                $tmpy=$yfield-1
        EndSwitch
            
        If $tmpx>0 And $tmpx<31 And $tmpy>0 And $tmpy<17 Then
            If $fieldsstates[$tmpx][$tmpy][0]=0 And $fieldsprocessed[$tmpx][$tmpy]=0 Then
                MouseClick("right",$fieldspos[$tmpx][$tmpy][0]+5,$fieldspos[$tmpx][$tmpy][1]+5,1,0)
                $fieldsprocessed[$tmpx][$tmpy]=1
                $fieldsstates[$tmpx][$tmpy][0]=10
                _calculatestatesaroundfield($tmpx,$tmpy)
                
            EndIf
        EndIf
    Next
EndFunc
Func _setopenfields($xfield,$yfield)
;MouseClick("left",$fieldspos[$xfield][$yfield][0]+16,$fieldspos[$xfield][$yfield][1]+16)
;MouseClick("right",$fieldspos[$xfield][$yfield][0]+16,$fieldspos[$xfield][$yfield][1]+16)
;_scanaroundfield($xfield,$yfield)
;_calculatestatesaroundfield($xfield,$yfield)
    
    For $i=1 To 8
        Switch $i
            Case 1
                $tmpx=$xfield-1
                $tmpy=$yfield-1
            Case 2
                $tmpx=$xfield-1
                $tmpy=$yfield
            Case 3
                $tmpx=$xfield-1
                $tmpy=$yfield+1
            Case 4
                $tmpx=$xfield
                $tmpy=$yfield+1
            Case 5
                $tmpx=$xfield+1
                $tmpy=$yfield+1
            Case 6
                $tmpx=$xfield+1
                $tmpy=$yfield
            Case 7
                $tmpx=$xfield+1
                $tmpy=$yfield-1
            Case 8
                $tmpx=$xfield
                $tmpy=$yfield-1
        EndSwitch
            
        If $tmpx>0 And $tmpx<31 And $tmpy>0 And $tmpy<17 Then
            If $fieldsstates[$tmpx][$tmpy][0]=0 And $fieldsprocessed[$tmpx][$tmpy]=0 Then
                MouseClick("left",$fieldspos[$tmpx][$tmpy][0]+14,$fieldspos[$tmpx][$tmpy][1]+14,1,0)
                $fieldsprocessed[$tmpx][$tmpy]=1
                
                Sleep(50)
                $fieldsstates[$tmpx][$tmpy][0]=_field_get_numb($tmpx,$tmpy)
                If $fieldsstates[$tmpx][$tmpy][0]=9 Then
    ;MouseMove(0,0,0)
                    _scan()
                Else
                    _calculatestatesaroundfield($tmpx,$tmpy)
                EndIf
                
                
            EndIf
        EndIf
    Next
    
EndFunc
Func _scanaroundfield($xfield,$yfield)
    For $i=1 To 8
        Switch $i
            Case 1
                $tmpx=$xfield-1
                $tmpy=$yfield-1
            Case 2
                $tmpx=$xfield-1
                $tmpy=$yfield
            Case 3
                $tmpx=$xfield-1
                $tmpy=$yfield+1
            Case 4
                $tmpx=$xfield
                $tmpy=$yfield+1
            Case 5
                $tmpx=$xfield+1
                $tmpy=$yfield+1
            Case 6
                $tmpx=$xfield+1
                $tmpy=$yfield
            Case 7
                $tmpx=$xfield+1
                $tmpy=$yfield-1
            Case 8
                $tmpx=$xfield
                $tmpy=$yfield-1
        EndSwitch
            
        If $tmpx>0 And $tmpx<31 And $tmpy>0 And $tmpy<17 Then
            If $fieldsstates[$tmpx][$tmpy][0]=0 And $fieldsprocessed[$tmpx][$tmpy]=0 Then
                $fieldsprocessed[$tmpx][$tmpy]=1
                Sleep(50)
                $fieldsstates[$tmpx][$tmpy][0]=_field_get_numb($tmpx,$tmpy)
                If $fieldsstates[$tmpx][$tmpy][0]=9 Then
                    _scanaroundfield($tmpx,$tmpy)
                EndIf
                _calculatestatesaroundfield($tmpx,$tmpy)
            EndIf
        EndIf
    Next
EndFunc
Func _calculatestates()
    For $y=1 To 16
        For $x=1 To 30
            $fieldsstates[$x][$y][1]=_field_get_flags_around($x,$y)
        Next
    Next
    For $y=1 To 16
        For $x=1 To 30
            $fieldsstates[$x][$y][2]=_field_get_openfields_around($x,$y)
        Next
    Next
EndFunc
Func _calculatestatesaroundfield($xfield,$yfield)
    $fieldsstates[$xfield][$yfield][1]=_field_get_flags_around($xfield,$yfield)
    $fieldsstates[$xfield][$yfield][2]=_field_get_openfields_around($xfield,$yfield)
    For $i=1 To 8
        Switch $i
            Case 1
                $tmpx=$xfield-1
                $tmpy=$yfield-1
            Case 2
                $tmpx=$xfield-1
                $tmpy=$yfield
            Case 3
                $tmpx=$xfield-1
                $tmpy=$yfield+1
            Case 4
                $tmpx=$xfield
                $tmpy=$yfield+1
            Case 5
                $tmpx=$xfield+1
                $tmpy=$yfield+1
            Case 6
                $tmpx=$xfield+1
                $tmpy=$yfield
            Case 7
                $tmpx=$xfield+1
                $tmpy=$yfield-1
            Case 8
                $tmpx=$xfield
                $tmpy=$yfield-1
        EndSwitch
            
        If $tmpx>0 And $tmpx<31 And $tmpy>0 And $tmpy<17 Then
            $fieldsstates[$tmpx][$tmpy][1]=_field_get_flags_around($tmpx,$tmpy)
            $fieldsstates[$tmpx][$tmpy][2]=_field_get_openfields_around($tmpx,$tmpy)
        EndIf
    Next
EndFunc
Func _quit()
    Exit
EndFunc

How to use MinesweeperBot:

as the bot only works for professional mode (the biggest one) you have to start minesweeper before using the bot and set the mode to professional, then close minesweeper and start the bot (maybe you have to change the path in the first line).

run him and wait. The message "Bot Message" will appear. Always if that message appears you have to guess, as Minesweeper suxx you often have to guess....

Edited by Markus

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Share this post


Link to post
Share on other sites



the mode with the field size 16*30


"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Share this post


Link to post
Share on other sites

Botrecords:

Minesweeper: 33 seconds

Pinball: 2.6 millions


"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

i tried the minesweeper bot. It works pretty nice only problem is, it doesnt detect when you lost + its pretty annoying that popup each time. Also if i click it might move instantly after that and cause im moving it misclicks sometimes.

Share this post


Link to post
Share on other sites

ShellExecute('pinball.exe')
Sleep(5000)
HotKeySet("^q","quit")
WinMove("3D Pinball for Windows - Space Cadet","",0,0)
WinActivate("3D Pinball for Windows - Space Cadet","")
WinWaitActive("3D Pinball for Windows - Space Cadet","")
$sumleft=PixelChecksum(159,429,173,454)
$sumright=PixelChecksum(197,429,210,454)
AutoItSetOption("SendKeyDownDelay",100)
AutoItSetOption("SendKeyDelay",200)
While 1
    If PixelChecksum(159,429,173,454)<>$sumleft Then Send("z")
    If PixelChecksum(197,429,210,454)<>$sumright Then Send("/")
WEnd
Func quit()
    Exit
EndFunc

Added shellexecute and sleep. Also had to change window title and change y m to z / .

Very cool code though :mellow: Only problem is that the pinball goes to the same spot almost every time...

Share this post


Link to post
Share on other sites

Your pinball bot doesn't work for me. What's your screen res? I'm running xp 64bit so we have the same game (or should)

Change MineSweeper to Minesweeper

btw, I hate this kind of stuff :( but I was bored too :mellow:


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Your pinball bot doesn't work for me. What's your screen res? I'm running xp 64bit so we have the same game (or should)

Have to check the screen size in the office tomorrow :mellow: (weekend suxx :-P)

Only problem is that the pinball goes to the same spot almost every time...

You could change the pixelarea - or make an array with different areas, that are randomly checked.

"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Share this post


Link to post
Share on other sites

How does the minesweeper works ? i runs but all it does is giving me the bot message over and over.

It doesn't do anything if you have to guess. As there is no field opened at the beginning, you have to guess. So always when that message appears, click anywhere in the field and then "OK" in the message. If you have a game situation where you don't have to guess but that message still appears, there's a bug :mellow:


"It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Pinball bot works. Highscore = 3,829,250

Edit: Code below sends keys to pinball window only,allowing window changing without key sends.

ShellExecute('pinball.exe')
Sleep(5000)
HotKeySet("^q","quit")
WinMove("3D Pinball for Windows - Space Cadet","",0,0)
WinActivate("3D Pinball for Windows - Space Cadet","")
WinWaitActive("3D Pinball for Windows - Space Cadet","")
$sumleft=PixelChecksum(159,429,173,454)
$sumright=PixelChecksum(197,429,210,454)
AutoItSetOption("SendKeyDownDelay",100)
AutoItSetOption("SendKeyDelay",200)
While 1
    If PixelChecksum(159,429,173,454)<>$sumleft Then ControlSend("3D Pinball for Windows - Space Cadet","","","z")
    If PixelChecksum(197,429,210,454)<>$sumright Then ControlSend("3D Pinball for Windows - Space Cadet","","","/")
WEnd
Func quit()
    Exit
EndFunc
Edited by dbzfanatic

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

i added some features :mellow:

HotKeySet("^{END}", "quit")
Opt("SendKeyDownDelay", 100)
Opt("SendKeyDelay", 200)
$name = InputBox("", "Highscore name", "coga")
If @error Then Exit
Dim $xy1[4] = [159, 429, 173, 454]
Dim $xy2[4] = [197, 429, 210, 454]
Dim $xy3[4] = [319, 409, 338, 427]
Global $sum1, $sum2, $sum3
if WinExists("3D-Pinball") = False then ShellExecute(@ProgramFilesDir & "\Windows NT\Pinball\PINBALL.EXE")
start()
Func start()
    WinActivate("3D-Pinball")
    WinWaitActive("3D-Pinball")
    WinMove("3D-Pinball", "", 0, 0)
    $sum1 = PixelChecksum($xy1[0], $xy1[1], $xy1[2], $xy1[3])
    $sum2 = PixelChecksum($xy2[0], $xy2[1], $xy2[2], $xy2[3])
    $sum3 = PixelChecksum($xy3[0], $xy3[1], $xy3[2], $xy3[3])
;~ ControlGetFocus(""
EndFunc   ;==>start
While 1
    If PixelChecksum($xy1[0], $xy1[1], $xy1[2], $xy1[3]) <> $sum1 Then ControlSend("3D-Pinball", "", "", "y")
    If PixelChecksum($xy2[0], $xy2[1], $xy2[2], $xy2[3]) <> $sum2 Then ControlSend("3D-Pinball", "", "", "m")
    If PixelChecksum($xy3[0], $xy3[1], $xy3[2], $xy3[3]) <> $sum3 Then
        Sleep(1000)
        ControlSend("3D-Pinball", "", "", "{SPACE down}")
        Sleep(540)
        ControlSend("3D-Pinball", "", "", "{SPACE up}")
    EndIf
    If WinExists("3D-Pinball") = False Then start()
    If WinExists("Bestenliste") Or WinExists("High Scores") Then        
        If WinExists("Bestenliste") Then
            $id = ControlGetFocus("Bestenliste")
            ControlSend("Bestenliste", "", $id, $name)
            ControlClick("Bestenliste", "", "Button1")           
        Else
            $id = ControlGetFocus("High Scores")
            ControlSend("High Scores", "",$id, $name)
            ControlClick("High Scores", "", "Button1")          
        EndIf
        Sleep(1000)
        WinActivate("3D-Pinball")
        WinWaitActive("3D-Pinball")
        ControlSend("3D-Pinball", "", "", "{F2}")
    EndIf
WEnd
Func quit()
    Exit
EndFunc   ;==>quit
Edited by Worfox

Share this post


Link to post
Share on other sites

i love this

I want to make a freecell bot, what is the best way to do this?

sorry for the off topic.

Share this post


Link to post
Share on other sites

i love this

I want to make a freecell bot, what is the best way to do this?

sorry for the off topic.

It's not nice to hijack others' threads. Your question should be asked in General Help and Support.

New Bot Highschore: 4,203,250

Bot Code:

HotKeySet("^{END}", "quit")
Opt("SendKeyDownDelay", 100)
Opt("SendKeyDelay", 200)
$name = InputBox("", "Highscore name", "coga")
If @error Then Exit

Dim $xy1[4] = [159, 429, 173, 454]
Dim $xy2[4] = [197, 429, 210, 454]
Dim $xy3[4] = [319, 409, 338, 427]
Global $sum1, $sum2, $sum3

if WinExists("3D Pinball for Windows - Space Cadet") = False then ShellExecute(@ProgramFilesDir & "\Windows NT\Pinball\PINBALL.EXE")

start()

Func start()
    WinActivate("3D Pinball for Windows - Space Cadet")
    WinWaitActive("3D Pinball for Windows - Space Cadet")
    WinMove("3D Pinball for Windows - Space Cadet", "", 0, 0)
    $sum1 = PixelChecksum($xy1[0], $xy1[1], $xy1[2], $xy1[3])
    $sum2 = PixelChecksum($xy2[0], $xy2[1], $xy2[2], $xy2[3])
    $sum3 = PixelChecksum($xy3[0], $xy3[1], $xy3[2], $xy3[3])
;~ ControlGetFocus(""
EndFunc  ;==>start

While 1
    If PixelChecksum($xy1[0], $xy1[1], $xy1[2], $xy1[3]) <> $sum1 Then ControlSend("3D Pinball for Windows - Space Cadet", "", "", "z")
    If PixelChecksum($xy2[0], $xy2[1], $xy2[2], $xy2[3]) <> $sum2 Then ControlSend("3D Pinball for Windows - Space Cadet", "", "", "/")
    If PixelChecksum($xy3[0], $xy3[1], $xy3[2], $xy3[3]) <> $sum3 Then
        Sleep(1000)
        ControlSend("3D Pinball for Windows - Space Cadet", "", "", "{SPACE down}")
        Sleep(1000)
        ControlSend("3D Pinball for Windows - Space Cadet", "", "", "{SPACE up}")
    EndIf
    If WinExists("3D Pinball for Windows - Space Cadet") = False Then start()
    If WinExists("Bestenliste") Or WinExists("High Scores") Then       
        If WinExists("Bestenliste") Then
            $id = ControlGetFocus("Bestenliste")
            ControlSend("Bestenliste", "", $id, $name)
            ControlClick("Bestenliste", "", "Button1")    
        Else
            $id = ControlGetFocus("High Scores")
            ControlSend("High Scores", "",$id, $name)
            ControlClick("High Scores", "", "Button1")   
        EndIf
        Sleep(1000)
        WinActivate("3D Pinball for Windows - Space Cadet")
        WinWaitActive("3D Pinball for Windows - Space Cadet")
        ControlSend("3D Pinball for Windows - Space Cadet", "", "", "{F2}")
    EndIf
WEnd

Func quit()
    Exit
EndFunc  ;==>quit

Share this post


Link to post
Share on other sites

I used "3D-Pinball" because the title in the German version is different to the English..

German:

"3D-Pinball für Windows - Space Cadet"

English:

"3D Pinball for Windows - Space Cadet"

Share this post


Link to post
Share on other sites

Well the titlematchmode was set wrong or something because it didn't work until I set the full title. Probably something minor.

New huge high-score: 17,000,250!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0