Last active
March 8, 2016 15:32
-
-
Save fisknils/708e0c57ca1ff2f17d3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Misc.au3> | |
#include <Array.au3> | |
AutoItSetOption("PixelCoordMode",2) | |
AutoItSetOption("MouseCoordMode",2) | |
HotKeySet("{ESC}", "Terminate") | |
HotKeySet("{PAUSE}", "Toggle") | |
$enabled = True | |
;HotKeySet("{F1}","getPixelColorAndCursorPos") | |
; setNewParams(true) ; only fetch color | |
;setNewParams(false) ; fetch colors + x and y | |
if not ProcessExists("mitosis.exe") Then | |
Run("C:\Program Files (x86)\Steam\steamapps\common\Mitos.is The Game\Mitosis.exe") | |
EndIf | |
WinWait("Mitos.is: The Game") | |
$hwnd = WinGetHandle("Mitos.is: The Game") | |
$coinColor = 16770873 | |
$diamondColor = 13695742 | |
$log = true | |
$ncm = 0 | |
$dir = "asc" | |
$x = 1920/2 | |
$y = 1080/2 | |
$lastHour = -1 | |
$tx = 1 | |
$ty = 1 | |
$splitIn = 18 | |
while(1) | |
; Splitting code | |
;~ $splitIn -= 1 | |
if ($splitIn < 0) Then | |
$splitIn = 18 | |
MouseMove(1920,1024) | |
Send(" ") | |
MouseMove(1,1) | |
Send(" ") | |
MouseMove(1920,1) | |
Send(" ") | |
MouseMove(1,1024) | |
EndIf | |
; / Splitting code | |
; ToolTip("press escape to quit" & $tx,$tx,$ty) | |
if not $enabled Then | |
Sleep(1000) | |
ContinueLoop | |
EndIf | |
$tx += 1 | |
WinActivate($hwnd) | |
WinWaitActive($hwnd) | |
$continue = True | |
if $lastHour <> @HOUR Then | |
if (checkDiamondsAchievement()) Then | |
EndIf | |
EndIf | |
if (PixelGetColor(957,557) = 16777215) And (PixelGetColor(919, 531) = Dec("E52C58")) Then ; checkPlay | |
MouseClick("left",957,557,1,1) | |
Sleep(1000) | |
$splitIn = 3 | |
Else | |
checkClick(944,338,16777215,"close") ; checkClose | |
checkClick(952,341,16777215) ; checkOpen | |
checkClick(871,596,16777215,"reconnect") ; checkReconnect | |
checkClick(872,612,16777215,"continue") ; checkContinue | |
checkClick(818,211,16710651,"cancel") ; checkCancel | |
EndIf | |
If checkForColor($coinColor,"coins") > 0 Then | |
ContinueLoop | |
ElseIf checkForColor($diamondColor,"diamonds") > 0 Then | |
ContinueLoop | |
ElseIf checkForPellets() > 0 Then | |
ContinueLoop | |
EndIf | |
WEnd | |
Func Terminate() | |
Exit | |
EndFunc | |
Func getPixelColorAndCursorPos() | |
$x = MouseGetPos(0) | |
$y = MouseGetPos(1) | |
$c = PixelGetColor($x,$y) | |
$str = "checkClick(" & $x & "," & $y & "," & $c & ") ;" | |
ClipPut($str) | |
;ToolTip($str) | |
EndFunc | |
Func getPixelColorByCursor() | |
$x = MouseGetPos(0) | |
$y = MouseGetPos(1) | |
$c = PixelGetColor($x,$y) | |
$str = $c | |
ClipPut($str) | |
;ToolTip($str) | |
EndFunc | |
Func rMouseMove() | |
$rx = Random(1,1920) | |
$ry = Random(1,1080) | |
MouseMove($rx,$ry,2) | |
EndFunc | |
Func newtt($tt) | |
;ToolTip($tt,1,1) | |
EndFunc | |
Func checkForColor($color,$debugmessage="") | |
$midx = @DesktopWidth/2 | |
$midy = @DesktopHeight/2 | |
$diff = -1 | |
$r = 0 | |
$x1 = 1 | |
$y1 = 1 | |
$x2 = @DesktopWidth | |
$y2 = @DesktopHeight | |
$err = 0 | |
while $err < 1 | |
$d = PixelSearch($x1,$y1,$x2,$y2,$color,1,4) | |
$err = @error | |
if @error < 1 and isarray($d) Then | |
dbgmessage($debugmessage) | |
if $diff = -1 or getDistance($midx,$d[0])+getDistance($midy,$d[1]) < $diff Then | |
$x = $d[0] | |
$y = $d[1] | |
MouseMove($x,$y,1) | |
$diff = getDistance($midx,$x)+getDistance($midy,$y) | |
$r = 1 | |
EndIf | |
$x1 = $d[0] | |
$y1 = $d[1] | |
EndIf | |
WEnd | |
return $r | |
EndFunc | |
func dbgmessage($msg) | |
if stringlen($msg)>0 Then | |
;ToolTip($msg,1,1) | |
EndIf | |
EndFunc | |
Func getDistance($x1,$x2) | |
if $x1 > $x2 Then | |
Return $x1-$x2 | |
Else | |
Return $x2-$x1 | |
EndIf | |
EndFunc | |
Func checkForCoins() | |
$c = 16770873 | |
$d = PixelSearch(1,1,@DesktopWidth,@DesktopHeight,$c) | |
if @error < 1 and isarray($d) Then | |
$break = True | |
MouseMove($d[0],$d[1],3) | |
return 1 | |
Else | |
return 0 | |
EndIf | |
EndFunc | |
Func checkForPellets() | |
Global $last_action | |
Local $x = 0 | |
Local $y = 1 | |
Local $pellet_colors[7] = [0xFDCB65,0x89E55C,0x66FFFF,0x5C5CE5,0xE55CE5,0x5CB9E7,0xE45B5B9] | |
For $i = 0 to UBound($pellet_colors) -1 | |
$d = PixelSearch(1,1,1920,1080,$pellet_colors[$i]) | |
if @error < 1 and IsArray($d) Then | |
$break = True | |
MouseMove($d[$x],$d[$y],3) | |
$last_action = TimerInit() | |
return 1 | |
EndIf | |
Next | |
return 0 | |
EndFunc | |
Func checkClick($x,$y,$color,$debugmessage="") | |
Global $last_action | |
if PixelGetColor($x,$y) = $color Then | |
if PixelGetColor(967,317) <> 0xE52C58 Then | |
dbgmessage($debugmessage) | |
MouseClick("left",$x,$y,1,1) | |
$last_action = TimerInit() | |
return True | |
EndIf | |
EndIf | |
Return False | |
EndFunc | |
Func checkDiamondsAchievement() | |
Global $lastHour | |
if not checkClick(1270,48,4242884) Then ; click achievements | |
return False | |
Else | |
$lastHour = @HOUR | |
EndIf | |
Sleep(1500) | |
checkClick(526,674,3232277) ; inside achievements (the achievement) | |
Sleep(500) | |
checkClick(1729,41,4242627) ; inside achievements (get reward) | |
Sleep(500) | |
checkClick(928,211,16777215) ; inside achievements (close) | |
Sleep(500) | |
checkClick(31,46,4242884) ; inside achievements (back) | |
return True | |
EndFunc | |
Func setNewParams($onlyColors=false) | |
;HotKeySet("{F2}","getPixelColorByCursor") | |
while(1) | |
Sleep(100) | |
WEnd | |
EndFunc | |
func Toggle() | |
global $enabled | |
if $enabled Then | |
$enabled = False | |
Else | |
$enabled = True | |
EndIf | |
EndFunc | |
Func _MouseMove($x,$y) | |
EndFunc | |
Func timeToSeconds() | |
EndFunc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment