Old code:
; ; AutoHotkey Version: 1.0.47.00 ; Language: Anyone ; Platform: Windows XP with XP theme enabled ; Author: Fincs <[email protected]> ; ; Script Function: ; Minesweeper auto-solver ; ; Results ; ======= ; Nascent: 2 sec. ; Intermediate: 4 sec. ; Advanced: 8 sec. level := 1 ; 1 - nascent, 2 - intermediate, 3 - advanced #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. ; Process level level ++ If level = 2 ; Nascent c := 9 ; 9 columns If level = 3 ; Intermediate c := 16 ; 16 columns If level = 4 ; Advanced c := 30, r := 16 ; 30 columns, 16 rows If r = r := c Run, winmine ; Execute Minesweeper Sleep, 100 WinGetActiveTitle, title ; Get the title of Minesweeper WinMove, %title%,, 80, 80 ; Move the window to the position 80, 80 Send, {ALT}{DOWN %level%}{ENTER} ; Select level Sleep, 10 Send, xyzzy{LShift} ; Enter cheat code Sleep, 10 CoordMode, Mouse, Relative ; Define constants x = 21 y = 111 sum = 16 Loop, %r% { d := 0 Loop, %c% { MouseMove, %x%, %y% ; Move the mouse to the next square Sleep, 10 PixelGetColor, color, -80, -80 ; Check the color of the first pixel If color <> 0x000000 Click ; The pixel says "secure" x += sum d ++ } x = 21 y += sum }
New code:
; ; AutoHotkey Version: 1.0.47.00 ; Language: Anyone ; Platform: WinXP with XP theme enabled ; Author: Fincs <[email protected]> ; ; Script Function: ; Minesweeper auto-solver ; ; Results ; ======= ; Nascent: 2 sec. ; Intermediate: 4 sec. ; Advanced: 8 sec. level := 3 ; 1 - nascent, 2 - intermediate, 3 - advanced sleep := 1 ; 0 - no sleep when mouse is clicked, 1 - sleep #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetMouseDelay -1 ; Do the mouse operations immediately ; Process level level ++ If level = 2 ; Nascent c := 9 ; 9 columns If level = 3 ; Intermediate c := 16 ; 16 columns If level = 4 ; Advanced c := 30, r := 16 ; 30 columns, 16 rows If r = r := c Run, winmine,,, pid ; Execute Minesweeper WinWait, ahk_pid %pid% IfWinNotActive,,, WinActivate WinWaitActive WinMove,,, 80, 80 ; Move the window to the position 80, 80 Send, {ALT}{DOWN %level%}{ENTER} ; Select level Sleep, 10 Send, xyzzy{LShift} ; Enter cheat code Sleep, 10 CoordMode, Mouse, Relative ; Define constants x = 21 y = 111 sum = 16 Loop, %r% { d := 0 Loop, %c% { MouseMove, %x%, %y%, 0 ; Move the mouse to the next square PixelGetColor, color, -80, -80 ; Check the color of the first pixel If color <> 0x000000 Click ; The pixel says "secure" If sleep Sleep, 10 x += sum d ++ } x = 21 y += sum } WinWait, ahk_pid %pid% IfWinNotActive,,, WinActivate WinWaitActive