![]() We can use a technique called a ‘ for loop’ :). While this works okay, what if we wanted to do 10, 100, 1000 of these? Our code would be hard to read. ![]() We could do the following: #include Func gotoCookieClicker() Local $url = " " Local $oIE = _IECreate($url) $HWND = _IEPropertyGet($oIE, "hwnd") WinSetState($HWND, "", _IEAction($oIE, "visible") _IELoadWait($oIE) EndFunc gotoCookieClicker() MouseClick($MOUSE_CLICK_LEFT, 275, 475) MouseClick($MOUSE_CLICK_LEFT, 275, 475) MouseClick($MOUSE_CLICK_LEFT, 275, 475) MouseClick($MOUSE_CLICK_LEFT, 275, 475) MouseClick($MOUSE_CLICK_LEFT, 275, 475) What if we want to click a bunch of times? You can research that outside this lesson :). To solve this and make the script portable across systems, you can use relative positioning, apposed to the absolute positioning we use here. One thing to note is that different size screens would have the game elements in different locations. Here is an example code that worked for my screen: #include Func gotoCookieClicker() Local $url = " " Local $oIE = _IECreate($url) $HWND = _IEPropertyGet($oIE, "hwnd") WinSetState($HWND, "", _IEAction($oIE, "visible") _IELoadWait($oIE) EndFunc gotoCookieClicker() MouseClick($MOUSE_CLICK_LEFT, 275, 475) ![]() We can use the X,Y coordinates given by the Finder Tool, and use that in our MouseClick function call. You get points for clicking on the large cookie on the left, and you can purchase upgrades on the right. In the next step, we will actually start to bot the game. Then after, we call the function as ‘gotoCookieclicker()’. Notice how first we create, or define the function. Try it out: #include Func gotoCookieClicker() Local $url = " " Local $oIE = _IECreate($url) $HWND = _IEPropertyGet($oIE, "hwnd") WinSetState($HWND, "", _IEAction($oIE, "visible") _IELoadWait($oIE) EndFunc gotoCookieClicker() Function’s allow us to define some piece of logic, and then call the function instead of all the code inside of it. In order to clean it up, let’s create a function. The code is starting to get more complicated. To launch a visible screen at max size, update the code to the following: #include Local $oIE = _IECreate(" ") $HWND = _IEPropertyGet($oIE, "hwnd") WinSetState($HWND, "", _IEAction($oIE, "visible") _IELoadWait($oIE) When I run the above code, Internet Explorer starts in a small window. The website we want to go to is ‘ ’.īefore looking at the code below, try to update the code yourself. Next, let’s change to actually use the website of the game we are going to be botting. Hopefully you got to see AutoIt in action :). To run your program from the editor, hit F5. Create a browser window and navigate to a website, wait 5 seconds and navigate to another wait 5 seconds and navigate to another #include Local $oIE = _IECreate(" Sleep(5000) _IENavigate($oIE, " ") Sleep(5000) _IENavigate($oIE, " ")Ĭopy this example to your file ‘ cookie_clicker_bot’, and save. With these tools, we can easily control an Internet Explorer window programmatically.įind the example for ‘ _IENavigate’. This is at the end of the same top section as ‘ File’. The SciTE program will add the file extension ‘.au3’, which is used for AutoIT files. We can name and save it with ‘File -> Save’, or CTRL+S.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |