automate minesweeper with python

J

Jay

I would like to create a python script that plays the Windows game
minesweeper.

The python code logic and running minesweeper are not problems.
However, "seeing" the 1-8 in the minesweeper map and clicking on
squares is. I have no idea how to proceed.
 
J

Jay

you may want to have a look at sikulihttp://groups.csail.mit.edu/uid/sikuli/

Intresting, but I actually have something already in python I want to
modify.
 
I

Ian Kelly

Intresting, but I actually have something already in python I want to
modify.

You should be able to use it with Jython. Or if you absolutely must
run CPython, JPype.
 
P

Paul McGuire

I would like to create a python script that plays the Windows game
minesweeper.

The python code logic and running minesweeper are not problems.
However, "seeing" the 1-8 in the minesweeper map and clicking on
squares is. I have no idea how to proceed.

You can interact with a Windows application using pywinauto (http://
pywinauto.openqa.org/).

Sounds like a fun little project - good luck!

-- Paul
 
J

Jay

pywinauto looks to be almost perfect. All I need now is to read the
numbers uncovered when a minesweeper square is clicked on, or that I
just hit a mine.
 
E

Emile van Sebille

On 7/1/2010 2:52 PM Jay said...

... or, you could always win...

http://www.daniweb.com/forums/thread186209.html

Did you actually try it? Though skeptical, I did, briefly, until I
decided that it probably should have been dated April 1. There is no way
to enter text into minesweeper, nor to make it full screen, nor, as far
as I know, for it to toggle pixels outside its window.
[/QUOTE]

Yes. It works.

Emile
 
I

Ian Kelly

Did you actually try it? Though skeptical, I did, briefly, until I decided
that it probably should have been dated April 1. There is no way to enter
text into minesweeper, nor to make it full screen, nor, as far as I know,
for it to toggle pixels outside its window.

Your objections are invalid. The fact that Minesweeper does not have
a text control does not mean that it cannot receive keypresses, and
the exterior pixel could hypothetically be implemented as a 1-pixel
borderless window belonging to the Minesweeper application.

There are enough details from enough different persons on the web,
with few if any dissenting opinions, that I'm inclined to believe it
probably works. I can't test it myself, though, because it apparently
no longer works in Windows Vista or 7, and I no longer have an XP box
around.
 
E

Ethan Furman

Terry said:
Did you actually try it? Though skeptical, I did, briefly, until I
decided that it probably should have been dated April 1. There is no way
to enter text into minesweeper, nor to make it full screen, nor, as far
as I know, for it to toggle pixels outside its window.

The pixel can be hard to see depending on your background colors and
whether your screen is adjusted correctly (I could see the white, but
not the black). But on XP Pro is still works.

~Ethan~
 
T

Terry Reedy

Did you actually try it? Though skeptical, I did, briefly, until I
decided that it probably should have been dated April 1. There is no way
to enter text into minesweeper, nor to make it full screen, nor, as far
as I know, for it to toggle pixels outside its window.

Yes. It works.[/QUOTE]

Thanks all. I tried again with other windows minimized so that the upper
left pixel is medium brown from the wallpaper, and I can make out the
white pixel. A maximized unfocued background window has that pixel
normally black surrounded by light blue pixels that make one white pixel
harder to see for imperfect eyes. Live, post errors, and learn ;-).
 
J

Jay

Thanks all. I tried again with other windows minimized so that the upper
left pixel is medium brown from the wallpaper, and I can make out the
white pixel. A maximized unfocued background window has that pixel
normally black surrounded by light blue pixels that make one white pixel
harder to see for imperfect eyes.  Live, post errors, and learn ;-).

OK, so how does a program read the pixel?
 
E

Emile van Sebille

On 7/2/2010 2:38 PM Jay said...
OK, so how does a program read the pixel?

Well, you start with a screen capture utility. I'd check is pywinauto
provides that access...

Emile
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top