Click every rectangle 1 time.

02/06/2014 17:52 xX4m4zingXx#1
I want to make a bot for mff. an auto plant and water bot, but how can i make it click every square 1 time?
[Only registered and activated users can see links. Click Here To Register...]
This is my code right now:
Code:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\ruud\documents\koda\forms\mff bot.kxf
$Form1_1 = GUICreate("Form1", 150, 213, 200, 128)
$Exit = GUICtrlCreateButton("Exit", 80, 80, 65, 25)
$Plant = GUICtrlCreateButton("Plant!", 8, 80, 65, 25)
$Seeds = GUICtrlCreateCombo("Seeds", 8, 16, 124, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Carrot")
GUICtrlSetCursor (-1, 2)
GUICtrlCreateInput("", 40, 48, 33, 21)
$From = GUICtrlCreateLabel("From", 8, 48, 27, 17)
$To = GUICtrlCreateLabel("To", 80, 48, 17, 17)
GUICtrlCreateInput("", 98, 48, 33, 21)
$Username = GUICtrlCreateInput("Username", 8, 112, 121, 21)
$Password = GUICtrlCreateInput("Password", 8, 144, 121, 21)
$Login = GUICtrlCreateButton("Login!", 8, 176, 137, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

		 Case $Exit
			Exit

		 Case $Plant
			_bot()

		 Case $Login
			_Login()

		 func _bot()
		 EndFunc

		 func _Login()
			$_Username = GUICtrlRead($Username)
			$_Password = GUICtrlRead($Password)
			MouseMove(585, 160, 10)
			Sleep(300)
			MouseClick("left")
			Sleep(300)
			Send($_Username)
			Sleep(300)
			MouseMove(772, 160, 10)
			Sleep(300)
			MouseClick("left")
			Sleep(300)
			Send($_Password)
			Sleep(300)
			MouseMove(962, 160, 10)
			MouseClick("left")
		 EndFunc
	EndSwitch
WEnd
02/06/2014 18:01 lolkop#2
Quote:
Originally Posted by xX4m4zingXx View Post
I want to make a bot for mff. an auto plant and water bot, but how can i make it click every square 1 time?
[Only registered and activated users can see links. Click Here To Register...]
Edit:
sry i forgot the $y part of the loop before... here's the correct one:
Code:
Dim $middleOfTheFirstRect[2] = [<x>,<y>], $widthOfRects = <width>, $heightOfRects = <heigth>
For $x=0 To 11
	For $y=0 To 9
		MouseClick('left', $middleOfTheFirstRect[0]+$x*$widthOfRects, $middleOfTheFirstRect[1]+$y*$heightOfRects, 1, 0)
	Next
Next
02/06/2014 18:18 xX4m4zingXx#3
Can you explain me where to add it and if i to edit something
and can you maybe explain me how it works/ what it means?
I am a beginner. I began yesterday.
02/06/2014 18:25 lolkop#4
Quote:
Originally Posted by xX4m4zingXx View Post
Can you explain me where to add it and if i to edit something
and can you maybe explain me how it works/ what it means?
I am a beginner. I began yesterday.
for loops are incrementing the given variable from the given start, to the given endpoint...
Code:
For <variable>=<startpoint> to <endpoint>
    <action>
Next
for example:
Code:
For $variable=1 to 5
    MsgBox(0, "for loop example", "current value of "&$variable>)
Next
is equal to:
Code:
MsgBox(0, "for loop example", "current value of 1")
MsgBox(0, "for loop example", "current value of 2")
MsgBox(0, "for loop example", "current value of 3")
MsgBox(0, "for loop example", "current value of 4")
MsgBox(0, "for loop example", "current value of 5")
so all you have to do is looping through the x and y coordinates in your case...
using 2 for-loops would be a nice and clean way to do that.

starting @ the middle of the first rectangle and walk through them all, by simply increasing the coordinates by width and heigth of the rects...
02/06/2014 19:24 xX4m4zingXx#5
But when i do this and someone does have another screen resolution. will it then work?

Bump
02/09/2014 12:52 xX4m4zingXx#6
Ok i added this in my bot but it goes from top to bottom i want to go it from left to right :$
and if someone does have another screen resolution does it work then?
02/09/2014 12:59 lolkop#7
Quote:
Originally Posted by xX4m4zingXx View Post
Ok i added this in my bot but it goes from top to bottom i want to go it from left to right :$
and if someone does have another screen resolution does it work then?
it handles the inner loop first...
simply change the order of the loops, to make it go from left to right first.

in order to get the middle of the first rect, you could used pixelsearch.
02/09/2014 13:10 xX4m4zingXx#8
Quote:
Originally Posted by lolkop View Post
it handles the inner loop first...
simply change the order of the loops, to make it go from left to right first.

in order to get the middle of the first rect, you could used pixelsearch.
I just found out that loops :)
but if i want to use pixelsearch for what do i have to seek then? the whole screen(where you plant) or just 1 rectangle? and can you make a bot scroll down so it makes sure that you can see the whole screen(where you plant)
02/09/2014 13:15 lolkop#9
Quote:
Originally Posted by xX4m4zingXx View Post
I just found out that loops :)
but if i want to use pixelsearch for what do i have to seek then? the whole screen(where you plant) or just 1 rectangle? and can you make a bot scroll down so it makes sure that you can see the whole screen(where you plant)
if you wanna make it work in any case, you'll have to switch to paket based stuff.

pixelbased bots will allways find their limits... since you can't hande the users browser settings, scrolling down won't fix any problems... pixelsearch will only work, if the pixel you're looking for, is currently visible on the users screen.
02/09/2014 14:05 xX4m4zingXx#10
Ok, but can't you make that when you see only half of the screen and the bot sees that 2 that you can make it scroll?
02/12/2014 22:07 xX4m4zingXx#11
bump
02/12/2014 22:25 FacePalmMan#12
you can also use controlclick so it clicks on parts of the screen that are not visible.
or if you want it to farm while you are afk then you can also use winhttp.
02/15/2014 02:57 xX4m4zingXx#13
but is it possible to make this bot i have now:
Code:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\ruud\documents\koda\forms\mff bot.kxf
$Form1_1 = GUICreate("Form1", 150, 213, 200, 128)
$Exit = GUICtrlCreateButton("Exit", 80, 80, 65, 25)
$Plant = GUICtrlCreateButton("Plant!", 8, 80, 65, 25)
$Seeds = GUICtrlCreateCombo("Seeds", 8, 16, 124, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Carrot")
GUICtrlSetCursor (-1, 2)
GUICtrlCreateInput("", 40, 48, 33, 21)
$From = GUICtrlCreateLabel("From", 8, 48, 27, 17)
$To = GUICtrlCreateLabel("To", 80, 48, 17, 17)
GUICtrlCreateInput("", 98, 48, 33, 21)
$Username = GUICtrlCreateInput("Username", 8, 112, 121, 21)
$Password = GUICtrlCreateInput("Password", 8, 144, 121, 21)
$Login = GUICtrlCreateButton("Login!", 8, 176, 137, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

		 Case $Exit
			Exit

		 Case $Plant
			_bot()

		 Case $Login
			_Login()

		 func _bot()
			Dim $middleOfTheFirstRect[2] = [569, 244], $widthOfRects = 40, $heightOfRects = 40
			For $y=0 To 9
			   For $x=0 To 11
				  MouseClick('left',$middleOfTheFirstRect[0]+$x*$widthOfRects ,$middleOfTheFirstRect[1]+$y*$heightOfRects , 1, 0)
			   Next
			Next
		 EndFunc

		 func _Login()
			$_Username = GUICtrlRead($Username)
			$_Password = GUICtrlRead($Password)
			MouseMove(585, 160, 10)
			Sleep(300)
			MouseClick("left")
			Sleep(300)
			Send($_Username)
			Sleep(300)
			MouseMove(772, 160, 10)
			Sleep(300)
			MouseClick("left")
			Sleep(300)
			Send($_Password)
			Sleep(300)
			MouseMove(962, 160, 10)
			MouseClick("left")
		 EndFunc
	EndSwitch
WEnd
that it works on every screen resolution and that it can find the place to plant?
03/08/2014 20:22 xX4m4zingXx#14
Bump
03/08/2014 20:38 alpines#15
To get it work on every resoulution you either have to do it for every resolution or make a better bot without clicking.