Alek Posted July 22, 2009 Share Posted July 22, 2009 Using winapi memory reading only works in xp (or less maybe) expandcollapse popup#include <Winapi.au3> Global Const $DataPtr = 0x1005330 Global Const $MinesPtr = 0x1005340 Global $MineSweeper_PID = Run("winmine.exe") ;run it Global $hProcess = _WinAPI_OpenProcess(0x1F0FFF, 1, $MineSweeper_PID, True) ;open it dim $read WinWait("Minesweeper") ;wait for the minesweeper to load. $DataStruct = DllStructCreate("dword mines;dword width;dword height") _WinAPI_ReadProcessMemory($hProcess, $DataPtr, DllStructGetPtr($DataStruct), DllStructGetSize($DataStruct), $read) ;Get widht, height and number of mines :) ConsoleWrite(DllStructGetData($DataStruct, "mines") & " Mines in a " & DllStructGetData($DataStruct, "width") & " by " & DllStructGetData($DataStruct, "height") & " grid " & @CRLF) WinActivate("Minesweeper") $Width = DllStructGetData($DataStruct, "width") - 1 $Height = DllStructGetData($DataStruct, "height") - 1 For $y = 0 To $Height For $x = 0 To $Width Switch _IsMine($x,$y) Case -1 ;Already open ContinueLoop Case 0 ;Safe to click on ControlClick("Minesweeper", "", "", "left", 1, 20 + ($x *16),(16 * $y) + 60) Case 1 ;MINE!!!! ControlClick("Minesweeper", "", "", "right", 1, 20 + ($x *16),(16 * $y) + 60) EndSwitch ;Sleep(25) ;Looks cool :P Next Next Func _IsMine($x, $y) $buffer = DllStructCreate("ubyte mine") _WinAPI_ReadProcessMemory($hProcess, $MinesPtr + (32 * ($y + 1)) + ($x + 1) , DllStructGetPtr($buffer), DllStructGetSize($buffer), $read) If DllStructGetData($buffer, "mine") = 0x40 Then Return -1 ElseIf DllStructGetData($buffer, "mine") = 0x0F Then Return 0 ElseIf DllStructGetData($buffer, "mine") = 0x8f Then Return 1 EndIf EndFunc [font="Impact"]Never fear, I is here.[/font] Link to comment Share on other sites More sharing options...
marselo Posted August 9, 2009 Share Posted August 9, 2009 HeHe nice job m8 ^^ it plays better than me >_< Link to comment Share on other sites More sharing options...
Pandemic Posted August 13, 2009 Share Posted August 13, 2009 Nice >_<. How of curiosity, who did you figure out how to use the dll file? I mean I know what they do, but how do you know what the... (for lack of a better word choice) stuff in it does? And the sleep(25) is neccissary if you're trying to solve an Expert puzzle . Else it goes too fast for it. -Pandemic Link to comment Share on other sites More sharing options...
Mega99 Posted August 13, 2009 Share Posted August 13, 2009 doesn't work in Vista >_< lol i don't even think Minesweeper is installed on vista.. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now