Jump to content

[FIRST TIME WITH AUTOIT] Minesweeper Bot help?


Recommended Posts

btw this is on windows 7, and I have VERY basic knowledge of autoit right now. I've been using it for exactly 4 hours. Anyways, so I'm trying to make a bot that actually PLAYS minesweeper for you. Doesn't win, doesn't edit memory, I just want it to be like an actual player. So I had no idea what to do and this is the first part of my script. I'm pretty sure theres a better way to make the mouse click on a box than pixel colors, but I don't know how. Any suggestions?

WinWaitActive( "Minesweeper" )
Beep(500, 1000)
WinActivate("Minesweeper")
$coord= PixelSearch( 0,0, @DesktopWidth, @DesktopHeight, 0x8FC2F3)
If Not @error Then
    MouseClick( "left", $coord[0], $coord[1], 1, 0)
EndIf
Link to comment
Share on other sites

First of all, welcome to the forums! ;)

Second, about your question.

Straight from the helpfile:

Remember, a typical display at 1024 x 768 has 786432 pixels. Although PixelSearch is optimized, narrowing the search area helps speed up the result.

Take a look at WinGetPos and WinGetClientSize.

If you use these functions first to get Minesweeper coords and size, you can optimize the speed of PixelSearch.

Like this.

HotKeySet("{ESC}", "_Exit")

Global $sTitle = WinGetTitle("Minesweeper")
Global $sColor = 0x8FC2F3

If (Not WinActive($sTitle)) Then WinActivate($sTitle)
WinWaitActive($sTitle)

Dim $aWinPos = WinGetPos($sTitle)
Dim $aWinSize = WinGetClientSize($sTitle)

While 1
    $aCoord = PixelSearch($aWinPos[0], $aWinPos[1], $aWinSize[0], $aWinSize[1], $sColor)
    If (IsArray($aCoord)) Then
        MouseClick("left", $aCoord[0], $aCoord[1], 1, 0)
    EndIf
WEnd

Func _Exit()
    Exit
EndFunc

EDIT: Added While, WEnd.

The script now keeps looking for the color until you press ESCAPE.

Also, I have no idea if this will work. I can't test on Win7 because I simply don't have it.

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

Welcome to the forum !

See this post first...

:)!

I think Minesweeper is allowed.

I even did a minesweeper bot once before.;)

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

I would like to know where the line is drawn. I do not BOT and do not think that it is fair to BOT (CHEATING), but have seen many threads that do not get blocked/closed and there needs to be a stand. NO $!#$@#$ BOTS or allow them - but make up YOUR mind.

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

[================================================================================]

legend:

'[' Left border.

']' Right border.

'=' Line.

if this topic gets locked its probably because the bickering about (whatever). And not the minesweeper game part.

But request like "but make up YOUR mind" could do the trick to.

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

  • Developers

I would like to know where the line is drawn. I do not BOT and do not think that it is fair to BOT (CHEATING), but have seen many threads that do not get blocked/closed and there needs to be a stand. NO $!#$@#$ BOTS or allow them - but make up YOUR mind.

Excuse me.... Go play somewhere else when things are making you emotional but don't vent it here.

The rules are clear these days!

*click*

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...