Not a member yet? Register for your free account!


Go Back   elitepvpers > Cabal Online > Cabal Guides & Templates
You last visited: Today at 06:10

  • Please register to post and access all features, it's quick, easy and FREE!

 

How to script a simple auto-bot [AutoIT]

This is a discussion on How to script a simple auto-bot [AutoIT] within the Cabal Guides & Templates forum part of the Cabal Online category; I guess this will be my contribution to this forum. NOTE: u can apply this to any game; i only ...

Reply
 
Thread Tools
Old 07/26/2007, 16:57   #1
Senior Member
 
Join Date: Jun 2007
Posts: 112
Received Thanks: 234

I guess this will be my contribution to this forum.

NOTE: u can apply this to any game; i only give cabal as a practical example.

  • Go to and download AutoIt Full Installation
  • Go to and download SciTE4AutoIt3.exe
  • Install them ofc ...
  • The most important action u can take is to THINK. I know it&#39;s hard for some but try >.< . What do we wanna do ?
    - auto-login
    - auto-hunt
    - auto-pot
  • because doing all 3 in a single script will just make things complicated and the program to run slower we just gonna make 3 different scripts for each action. And because it could be a pain and most probably ruin everything to run myself all 3 programs the auto-login will just run as the main-brain that will coordinate all.
  • The auto-login requires:
    - screen shoot will the log-in menu
    - screen shoot with the server select menu
    - screen shot with the char menu
    - in game SS (ScreenShoot)

    IMPORTANT: The SS&#39;s will be made by pressing the PrintScreen Button on the keyboard. Entering paint, Edit - > Paste and save it as 24-Bit BMP. Another format will just lose from pixel color range and u will do ABSOLUTELY NOTHING since the pixels won&#39;t be the same. I&#39;ll just use a personally made program that help me to capture the screen and save it with just a button.

    PS: Here i&#39;ll post the JPG versions of the SS&#39;s since they are a lot smaller.





  • Now after some THINKING i realize that i don&#39;t want my program to start log in 1st. Because i will be in front of my PC when running the game and program so i can log it in myself for the 1st time. So i want the program to start when i&#39;m actually in game. For this i need a particular color on an un-movable menu. First color that jumps in it&#39;s the GOLD from the Item Shop.
    So i go to Start -> All programs -> AutoIt v3 -> AutoIt Window Info ; i right click it and i choose Pin To Start Menu since I&#39;ll need it a lot. Now if u press Start on WinXp Desktop u will see it on the top list.
    I open it, i also open the ingame SS (i use AcdSee), i Press F to make the pic full screen and i see that the AutoIt Window Info stays on top and that is great since i need it. I do Option -> Magnify in AWI (AutoIt Window Info) and i also chose the Mouse Tab ... and voila i can chose EXACTLY the pixel i want to use.
    After i chose it i press Ctrl+Alt+F to freeze the AWI so i can copy the data collected.


  • Now i am actually ready too start my program. I right click the desktop -> New -> AutoIt v3 Script. I right click the file and press Edit. The SciTE will now open the script to be edited.

    NOTE: the ; marks a comment. It&#39;s just for the user, it&#39;s not being used by the program and it&#39;s not part of the code. It&#39;s just for u to understand it.

    Code:
    HotKeySet&#40;&#34;{F12}&#34;,&#34;startover&#34;&#41; &#59;i allocate to key F12 the function start over
    ;i do this because when i exit the game the auto-hunt might be too fast for me to stop 
    ; so i&#39;ll just press F12 and it will be stopped
    ; also u can add any key u want F1-12, NumPad0-9 ... and so on
    
    startover&#40;&#41; &#59; i call that same function to run so i just won&#39;t have to press F12 
    
    Func startover&#40;&#41;&#59;i declare it 
    
    Endfunc &#59;and i end it
    
    while 1&#59; it will just keep the program in stand by untill the function is called
    ; useless in our case since we called the function automatically but it&#39;s good for u to know it
    	sleep&#40;1000&#41;
    WEnd
    This is the structure of my program. Now i&#39;ll just write the function startover. Which is my main and only function.

  • U have to understand that you&#39;ll most probably won&#39;t achieve perfection from the 1st try. You&#39;ll have to work of your programs to eliminate the flaws. What i show u now it&#39;s the result of about 3 tries. Or about what i remember since my Hard-Disc broke :|
    Let&#39;s get on the function ...
    Code:
    Func startover&#40;&#41;
    while 1   &#59;because i want it to run over and over again
    ProcessClose&#40;&#34;hunt.exe&#34;&#41;   &#59;that&#39;s the auto-hunt i&#39;ll make later
    ProcessClose&#40;&#34;pot.exe&#34;&#41;    &#59;and the auto-pot i&#39;ll make later
    ;ProcessClose it basically just does what it says it closed a process
    ;what i do this ? because i don&#39;t want my auto-hunt and auto-pot to run more that once
    ;so each time the function initiate it will kill it?s *Sub-Functions*
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    while 1&#59;we start a loop that wait for u to enter the game 
    	PixelSearch&#40;964,743,964,743,0xF7E52B,15&#41; &#59; we look for the GOLD color we&#59;collected . The last number ?15? it?s the pixel color range it can search
    ;so basically it doesn?t have to be the EXACT pixel
    	If NOT @error Then&#59; PixelSearch color returns @error = 1 if the color ain?t found
    ;and 0 if the color is found
    ;NOT @error means @error = 0 
    ;so if it founds that GOLD pixel it continues
    	Run&#40;&#34;pot.exe&#34;&#41;&#59; run it
    	Run&#40;&#34;hunt.exe&#34;&#41;  &#59; run it
    	Mouseclick&#40;&#34;left&#34;,999,22,1&#41;&#59; this will close the mini-map in 1024x768
    	ExitLoop &#59; it exists the current while loop
    EndIf &#59; we close the IF
    sleep&#40;1000&#41; &#59; it waits 1000 ms &#40;1 second&#41; before it continnues
    Wend &#59; we close the while loop
    
    ;in less words this while loop will search for pixel over and over and over again
    ;until the pixel it?s found
    ;then it exit loop and it continues 
    
    EndFunc
    Ok so until now our program can see that we logged in and he starts the auto-hunt and auto-pot. The next step is to make it reconise a disconnect. And we search for particular elements.






    So i continue my function

    Code:
    while 1
    ;the best way is to use the same recognition system as before only the opposite way
    ;we don&#39;t want the GOLD pixel to be there
    	PixelSearch&#40;964,743,964,743,0xF7E52B,15&#41; &#59;same pixel search as before
    	&#036;n = @error
    while &#036;n &#59;while the pixel is not found
    Select 
        Case Hex&#40;PixelGetColor&#40;428,347&#41;,6&#41; = &#34;FEFEFE&#34; and Hex&#40;PixelGetColor&#40;581,444&#41;,6&#41; = &#34;EEEEEE&#34; 
    ; the 2 pixels in the main menu 
      Sleep&#40;200&#41; 
      ProcessClose&#40;&#34;hunt.exe&#34;&#41; &#59; we close both the Sub-Functions
      ProcessClose&#40;&#34;pot.exe&#34;&#41; &#59; we don&#39;t want keys to be pressed 
    ;while it writes the password
      Sleep&#40;6000&#41; 
      Send&#40;&#34;{Enter}&#34;&#41;&#59;just to be sure we try a log in before we right&#59;the password. This will clear the pass field and leave it blank
      Sleep&#40;2000&#41;
      MouseClick&#40;&#34;left&#34;,528,381,1,0&#41; &#59; left click in the pass field
      Sleep&#40;200&#41;
      Send&#40;&#34;PutYourPasswordHere&#34;&#41; &#59;it will write the pass
      Send&#40;&#34;{Enter}&#34;&#41;&#59;log in
      Sleep&#40;800&#41; 
      MouseMove&#40;950,650&#41; &#59;move the mouse to a non-related point
    ; u can notice some useless things that i add to the script just to be sure the program will never fail
    ;next server list 
    	Case Hex&#40;PixelGetColor&#40;457,572&#41;,6&#41; = &#34;EEEEEE&#34; 
             Sleep&#40;1000&#41;	
      Send&#40;&#34;{Right}&#34;&#41;&#59;it collapse the server list
      Send&#40;&#34;{Down 1}&#34;&#41;&#59; the number will be sub-server u want 1-20
      Sleep&#40;200&#41;
      EndIf
    ;next is char list
    Case Hex&#40;PixelGetColor&#40;755,575&#41;,6&#41; = &#34;55504A&#34;&#59; adaugi un Send&#40;&#34;{Down}&#34;&#41; 
    ;before the next Send&#40;&#34;{Enter}&#34;&#41; u have to add Send&#40;&#34;{Down x}&#34;&#41; where 
    ;x is 1 for the 2nd char, 2 for the 3rd char and so on
    ;u don&#39;t add anything if the char u wanna play with it&#39;s the 1st char
      Send&#40;&#34;{Enter}&#34;&#41;&#59;it selects the char
      ExitLoop 2&#59; it exits 2 loops&#58; the current one and the one that 
    ;started the search for disconnect
    EndSelect
    
    PixelSearch&#40;964,743,964,743,0xF7E52B,15&#41;
    	&#036;n = @error
    	Sleep&#40;1000&#41;
    ;this keeps the while loop running till success
    wend
    wend
    There u go ... u have a working auto-login in no time.


<hr>Append on Jul 26 2007, 16:58<hr> PS: plz don&#39;t post i have 2 more to write :P

<hr>Append on Jul 26 2007, 17:06<hr> [AUTO-POT]


We&#39;re just gonna take the in game SS and work with it.




Code:
while 1 
  
&#036;coord = PixelSearch&#40;186,26,187,26,0xA00C00,1&#41;&#59;looking for the HP pixel in a color&#59;range of 1 

If not @error Then&#59;if the color is not found
Send &#40;&#34;{F11}&#34;&#41; &#59;it presses F11
;in game Options -&#62; Game -&#62; unMark &#34;Use numeric Keys&#34;
;just trust me with this one

EndIf  	
  
Sleep&#40;100&#41; &#59; if we don&#39;t put this sleep the auto-pot will keep the CPU used 100%
WEnd
   

while 1&#59;just keep the script alive
	sleep&#40;1000&#41;
	wend

__________________

Dizzydbd is offline  
Thanks
39 Users
1h3gam3v1ru5 (06/13/2012), 29zany (09/30/2012), AcidRainZ (07/01/2008), ax5 (12/21/2009), azhula_89 (05/01/2010), biohazardzz (02/10/2011), ceforan321 (07/31/2008), Comatose123 (07/25/2012), CrossMarian (11/13/2008), cypher86 (07/01/2008), darkbetter (11/10/2011), deestruct (05/01/2010), genesisVI (05/20/2012), globenet25user (06/23/2008), goroz (11/29/2011), gothixxx12 (11/30/2009), hacker02 (09/30/2008), hollow ichigo (05/28/2008), Judgment (02/26/2008), Kelya (10/23/2009), koko6699 (02/07/2010), Mirceagab (10/25/2008), mmoobb (03/17/2008), OmegaArma (04/06/2010), Pellizzetti (10/22/2010), pizdulica (08/30/2009), pob_suwan (05/17/2010), qioz (02/06/2009), regan2008 (07/12/2008), rjrjrjrjrj (07/12/2012), Snipper (06/24/2009), stranger10101 (08/26/2009), styxboy (12/05/2008), troy500 (04/18/2008), UnitedMassacre (01/01/2009), Wileykid (05/16/2008), xBlizzarD (07/08/2008), xdraim (07/26/2010), Xlax (05/01/2008)
Old 07/26/2007, 17:21   #2
Junior Member
 
Join Date: Jul 2007
Posts: 3
Received Thanks: 0
good documant thanks
wwwthexfilescom is offline  
Old 07/26/2007, 17:32   #3
Senior Member
 
Join Date: Jun 2007
Posts: 112
Received Thanks: 234
[AUTO-HUNT]


Now this is more difficult
You need a bmp SS with every mob color u wanna hunt. I&#39;ll just make it for Green. Make the SS with the mob selected cuz u&#39;ll need that too.



  • First step is to take that pixel color
  • And the second one to take the HP LIMIT of the mob ... like this
  • U also have to take the 4 coordinates of the square for mob search
    I choose:
    &#036;xTop = 30
    &#036;yTop = 73
    &#036;xBot = 1002
    &#036;yBot = 692
    This should cover all screen that can be used for this.
    PS: bot from bottom
  • I&#39;ll show u the most simple way. U can make it more complex by adding more intelligent searching ways.

    Code:
    &#036;xTop = 30; i declare them 
    &#036;yTop = 73
    &#036;xBot = 1002
    &#036;yBot = 692
    &#036;mobGreen = &#34;0xC0BE40&#34;; i also declare the mob color
    
    Sleep&#40;6000&#41;
    while 1
    &#036;coord = PixelSearch&#40;&#036;xTop,&#036;yTop,&#036;xBot,&#036;yBot,&#036;mobGreen,5&#41;;i search for the green mobs
        &#036;n = @error
    	If NOT @error Then;if the mob is found
     while &#036;n = 0;while it is still in the screen
     &#036;x = Random&#40;&#036;coord&#91;0&#93;, &#036;coord&#91;0&#93;+40, 1&#41;;we randomize coordinates so we won&#39;t miss the mob
    ;since mobs have different shape and sizes
     &#036;y = Random&#40;&#036;coord&#91;1&#93;, &#036;coord&#91;1&#93;+40, 1&#41;
     MouseClick&#40;&#34;right&#34;, &#036;x, &#036;y, 2, 0&#41;; i click at the randomized coordinates
     &#036;mm = PixelGetColor &#40; 378 , 12 &#41;; i get the pixel color of that mob HP LIMIT
     &#036;mob = Hex&#40;&#036;mm, 6&#41;;since the pixel i got is hex and PixelGetcolor function returns a decimal value i convert it 
     If &#036;mob = &#34;7B0000&#34; Then; i compare the converted value i got from PixelGetColor in that point with the have i collected using AWI in the same point
     	ExitLoop; if it&#39;s a match &#40;that means that the mob was selected&#41;
    ;it will exit the loop and continue
     EndIf
     &#036;coord = PixelSearch&#40;&#036;xTop,&#036;yTop,&#036;xBot,&#036;yBot,&#036;mobGreen,5&#41;;we repeat the same pixel search
    ; the ideea is that the program will try to click the mob untill he is selected
        &#036;n = @error
     wend 
    
    ;in this moment we have the mob selected 
     If &#036;mob = &#34;7B0000&#34; Then  &#59; but we check it anyway
     	while &#036;mob = &#34;7B0000&#34; &#59; so as long as the mob is selected
      
      	Send&#40;&#34;{F4}&#34;&#41;; we just send the skills from F4 to F1
      	Send&#40;&#34;{F3}&#34;&#41;; chaotic i know but since we use speed hack
                Send&#40;&#34;{F2}&#34;&#41;;adding waiting times will just be a waste of time
          Send&#40;&#34;{F1}&#34;&#41;
    
       &#036;mm = PixelGetColor &#40; 378 , 12 &#41;;we once again look for the mob&#39;s HP so we can complete the while loop
       &#036;mob = Hex&#40;&#036;mm, 6&#41;;this means that the keys will be pressed untill the mob is dead
      	wend
      Send&#40;&#34;{Space}&#34;&#41;; after the mob is dead we collect the items 
      Sleep&#40;200&#41;
      Send&#40;&#34;{Space}&#34;&#41;
      Sleep&#40;200&#41;
      Send&#40;&#34;{Space}&#34;&#41;
      Sleep&#40;200&#41;
     	EndIf
    
    ;now remember the &#34;IF NOT @error Then&#34; from the start?
    ;what if there is no mob in the screen?
    ;what then?
    
    Else;if no mob is found
    Send&#40;&#34;{Right 7}&#34;&#41; &#59;rotate the camera to look in other directions 
    Endif
    Wend
  • And that&#39;s it we have a fully functional set of auto-bots.
Dizzydbd is offline  
Thanks
15 Users
1h3gam3v1ru5 (06/13/2012), darkbetter (11/10/2011), deestruct (05/01/2010), freakykami (10/23/2011), goroz (11/29/2011), mmoobb (04/05/2009), nero17 (07/21/2009), Pellizzetti (10/22/2010), Pirate Storm Player (06/10/2013), regan2008 (07/12/2008), shinoowns (07/23/2009), stranger10101 (08/26/2009), UnitedMassacre (01/01/2009), viky909 (01/23/2011), xBlizzarD (07/15/2008)
Old 07/26/2007, 18:41   #4
Junior Member
 
Join Date: Jul 2007
Posts: 12
Received Thanks: 2
+Karma
leet-pvp is offline  
Old 07/26/2007, 19:08   #5
Member
 
Join Date: Dec 2005
Posts: 98
Received Thanks: 21
Wow, 1 guy makes an AutoIT bot and everyone starts making "their contribution".

There are like 3 bots already, all made in autoit =.=
bafao is offline  
Old 07/26/2007, 19:40   #6
Junior Member
 
Join Date: Jul 2007
Posts: 12
Received Thanks: 2
and what do you wanna tell us with that?

if you compare this to all the others, this is so much better.
leet-pvp is offline  
Thanks
1 User
jhayjhay (06/18/2008)
Old 07/26/2007, 20:59   #7
Senior Member
 
Join Date: Jun 2007
Posts: 112
Received Thanks: 234
@bafao

U don&#39;t get it. I didn&#39;t made an AutoIT bot ... i explained the mechanics to do one. I left some blanks so ppl actually think not just leech. I think this should be more in a general gaming section ... but w/e.

ADDITIONAL INFO

Code:
AdlibEnable &#40; &#34;function&#34; &#91;, time&#93; &#41;
AdlibDisable &#40; &#41;
Ex: AdlibEnable("unstuck",30000)

Every 30 000 ms (30 seconds) the function "unstuck()" is called. U can use this in the auto-hunt function to take some action if mob isn&#39;t killed in 30 sec ... or w/e time u wanna set. Also don&#39;t forget to call AdlibDisable ( ) after the mob died.

Also u might of notice that the other programs posted are delay based. U should avoid that because u can&#39;t expect the same speed reaction every time (your game might lag) and also u should do while loops for every action that might change unexpected: like writing the password and trying to log in until the next screens is detected, trying to click on the founded mob until he is selected and so on.
U should also avoid PixelGet as much as u can. Use PixelSearch since u can give him a shade-variation and the pixel might not be the exact one all the time and also in some games PixelGet and PixelSearch in 1 singur pixel will always return BLACK. With PixelSearch u can do a wider area search and everything will work.


From a resolution to another

U don&#39;t wanna read the pixels and the positions again. First because it takes time and second because it&#39;s stupid.
The solution is simple. Let&#39;s say u wanna change
&#036;x = 500 and &#036;y = 350 from 1024x768 to 1280x1024.
- u calculate how much % is &#036;x from 1024
500 * 100 / 1024 = 48.82 %
&#036;xnew = 1280 * 48.82 /100 = 624.89 and that&#39;s not a valid coordinate. That&#39;s why the calculation formula will be &#036;xnew = Round(1280*48.82/100,0)
- some with &#036;y
350 * 100 / 768 = 45.57%
&#036;ynew = Round(1024*45.57/100,0) = 467


From full screen to windowmode

Just use this function
Code:
Opt&#40;&#34;PixelCoordMode&#34;, 1&#41;    &#59;1=absolute, 0=relative, 2=client
Quote:
Sets the way coords are used in the pixel functions, either absolute coords or coords relative to the current active window:
0 = relative coords to the active window
1 = absolute screen coordinates (default)
2 = relative coords to the client area of the active window
Dizzydbd is offline  
Thanks
2 Users
stranger10101 (08/26/2009), UnitedMassacre (01/01/2009)
Old 07/27/2007, 14:03   #8
300
Junior Member
 
Join Date: Jul 2007
Posts: 20
Received Thanks: 2
&#036;xTop = 30; i declare them
&#036;yTop = 73
&#036;xBot = 1002
&#036;yBot = 692
&#036;mobGreen = "0xC0BE40"; i also declare the mob color HERE

Sleep(6000)
while 1
&#036;coord = PixelSearch(&#036;xTop,&#036;yTop,&#036;xBot,&#036 ;yBot,&#036;mobGreen,5);i search for the green mobs
&#036;n = @error
If NOT @error Then;if the mob is found
while &#036;n = 0;while it is still in the screen
&#036;x = Random(&#036;coord[0], &#036;coord[0]+40, 1);we randomize coordinates so we won&#39;t miss the mob
;since mobs have different shape and sizes
&#036;y = Random(&#036;coord[1], &#036;coord[1]+40, 1)
MouseClick("right", &#036;x, &#036;y, 2, 0); i click at the randomized coordinates
&#036;mm = PixelGetColor ( 378 , 12 ); i get the pixel color of that mob HP LIMIT
&#036;mob = Hex(&#036;mm, 6);since the pixel i got is hex and PixelGetcolor function returns a decimal value i convert it
If &#036;mob = "7B0000" Then; HERE i compare the converted value i got from PixelGetColor in that point with the have i collected using AWI in the same point
ExitLoop; if it&#39;s a match (that means that the mob was selected)
;it will exit the loop and continue
EndIf
&#036;coord = PixelSearch(&#036;xTop,&#036;yTop,&#036;xBot,&#036 ;yBot,&#036;mobGreen,5);we repeat the same pixel search
; the ideea is that the program will try to click the mob untill he is selected
&#036;n = @error
wend

;in this moment we have the mob selected
If &#036;mob = "7B0000" Then ; HERE but we check it anyway
while &#036;mob = "7B0000" ; HERE so as long as the mob is selected

Send("{F4}"); we just send the skills from F4 to F1
Send("{F3}"); chaotic i know but since we use speed hack
Send("{F2}");adding waiting times will just be a waste of time
Send("{F1}")

&#036;mm = PixelGetColor ( 378 , 12 );we once again look for the mob&#39;s HP so we can complete the while loop
&#036;mob = Hex(&#036;mm, 6);this means that the keys will be pressed untill the mob is dead
wend
Send("{Space}"); after the mob is dead we collect the items
Sleep(200)
Send("{Space}")
Sleep(200)
Send("{Space}")
Sleep(200)
EndIf

;now remember the "IF NOT @error Then" from the start?
;what if there is no mob in the screen?
;what then?

Else;if no mob is found
Send("{Right 7}") ;rotate the camera to look in other directions
Endif
Wend







So where i posted HERE there is to change the value with getpixel?
Or could i just copy this and it would work?
300 is offline  
Thanks
1 User
UnitedMassacre (01/01/2009)
Old 07/27/2007, 15:12   #9
Senior Member
 
Join Date: Jun 2007
Posts: 112
Received Thanks: 234
like i said I DIDN&#39;T MADE A BOT i explained the process. But if u put them all together it should work. Why don&#39;t u wanna just think for a moment? :-w
Dizzydbd is offline  
Thanks
1 User
stranger10101 (08/26/2009)
Old 07/27/2007, 22:31   #10
300
Junior Member
 
Join Date: Jul 2007
Posts: 20
Received Thanks: 2
ok you helped me alot &#33;&#33;&#33;
Doing my own bot atm
Working pretty well&#33;
But i wanted a feature but there is a logical problem:
I Instantly relog if i see a player.
This is working pretty well at warchannel with the red and orange names. But not in the other channels&#33;
And now the problem. In the other channels the Player name is white&#33; (Like the own character name)
And its not possible to show the other players name without showing the own
So i would instantly relog if i join a channel.



Can you help me?
300 is offline  
Reply

Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Request Simple Auto Join War Script cracka3930 12Sky2 0 06/24/2010 17:35
[Autologin] Simple autoit script audi0slave SRO Exploits/Hacks/Bots/Guides 44 06/29/2009 19:55
NEED help making simple auto attack script seanyboyy Lineage 2 0 06/28/2008 19:11
[Request] Simple AutoIt Script EternalWinter Dekaron 5 06/26/2008 04:07
need help making a simple autoit script aznphoboi SRO Main - Discussions / Questions 2 05/21/2006 07:27



All times are GMT +2. The time now is 06:10.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.