AutoIt AutoPot Script

08/13/2009 04:25 DragonicaIt#1
**** THIS SCRIPT ONLY WORK IN WINDOW MODE ****
**** THIS SCRIPT ONLY WORK IN WINDOW MODE ****
**** THIS SCRIPT ONLY WORK IN WINDOW MODE ****

Hi all, scripted an autoIt script that will do auto login and autopot
This script utilize a configuration file name config.dat to do the following, so it should be in the same folder as where the script is.

To terminate the script just press F11.

Auto Login (ID must be save)
Default Server/Channel Selection
Default Character Selection
As for the autopot, it is scripted to run @ 70% of the HP/MP level. (HP pot at key 1, MP pot at key 2)

It is scripted base on the game window x,y location.
So it should still work for any screen resolution and any location the game screen is drag to.

Note that the game will be minimize and restore during some parts of the auto login as during focusing on the game the mouse refuses to move. So the script will minimize the game shift the mouse, restore the game and click on where the mouse is.

So there might be high chances that it will not work good for slower computer. If that happen just edit the function "clickloc($locx, $locy)" and add some delay into the script.


CURRENTLY MY SCREEN IS USING 1680 x 1050.
SO PLEASE LET ME KNOW :p

The actual autoIt Script
Code:
;HotKey for terminating the script
HotKeySet("{F11}", "Terminate") 

#include <file.au3>

$i = 1
Dim $aRecords
;Window title for dragonica should be changed after every patch
$WinTitle = "Dragonica (Client Ver : 0.1.23)"	

;Force focus on dragonica
WinActivate($WinTitle)	

;Reading config file if error reading terminate script
If Not _FileReadToArray("config.dat",$aRecords) Then	
   MsgBox(4096,"Error", "Error reading configuration")
   Exit
EndIf

;Continuous looping
While $i <> 0	
	if $i = 2 Then
		Sleep(500)
		$i = 1
	Else
		;If autologin flag is true in the config file and game exist
		If ($aRecords[2] = 'True' And WinExists($WinTitle)) Then
			checkLogin()
		EndIf
		;If the game exist check for hp and mp
		If (WinExists($WinTitle)) Then
			checkHp70()
			checkMp70()
		EndIf
		$i = 2
	EndIf
WEnd

Func checkLogin()
	;Getting window x,y,width,height
	$size = WinGetPos($WinTitle)
	;Setting flags for login/server/character selection to false
	$isLoginScreen = False
	$isServerScreen = False
	$isCharScreen = False

	;Searching for 3 pixel to determine if it is really the login screen
	If 	(Hex(PixelGetColor( $size[0]+419 , $size[1]+485 ), 6) = '4d3413' And Hex(PixelGetColor( $size[0]+750 , $size[1]+440 ), 6) = 'f2455e' And Hex(PixelGetColor( $size[0]+190 , $size[1]+520 ), 6) = '89b694') Then
		$isLoginScreen = True
	EndIf
	
    ;If it is the login screen proceed to login
	If $isLoginScreen = True Then
		;Send password keypress to the game
		ControlSend($WinTitle,'','',$aRecords[4]);
		sleep(200)
		;Time to login.
		ControlSend($WinTitle,'','','{ENTER}');
	EndIf
	
	Sleep(1000)
	
	;Searching for 3 pixel to determine if it is really the server selection screen
	If 	(Hex(PixelGetColor( $size[0]+60 , $size[1]+55 ), 6) = 'fbc34f' And Hex(PixelGetColor( $size[0]+515 , $size[1]+455 ), 6) = 'f64500' And Hex(PixelGetColor( $size[0]+515 , $size[1]+700 ), 6) = 'f64700') Then
		$isServerScreen = True
	EndIf

	If $isServerScreen = True Then
		;Default server selection screen Kaye/Elga
		If $aRecords[6] = 'Kaye' Then
			ClickLoc($size[0]+210, $size[1]+350)
		ElseIf $aRecords[6] = 'Elga' Then
			ClickLoc($size[0]+330, $size[1]+350)
		EndIf
		
		Sleep(500)
		
		;Default channel selection
		If($aRecords[8] = 1 Or $aRecords[8] = 2 Or $aRecords[8] = 3) Then
			ClickLoc($size[0]+440+(($aRecords[8]-1)*160), $size[1]+518)
		ElseIf($aRecords[8] = 4 Or $aRecords[8] = 5 Or $aRecords[8] = 6) Then
			ClickLoc($size[0]+440+(($aRecords[8]-4)*160), $size[1]+561)
		ElseIf($aRecords[8] = 7 Or $aRecords[8] = 8 Or $aRecords[8] = 9) Then
			ClickLoc($size[0]+440+(($aRecords[8]-7)*160), $size[1]+604)
		ElseIf($aRecords[8] = 10) Then
			ClickLoc($size[0]+440+(($aRecords[8]-10)*160), $size[1]+647)
		EndIf
	EndIf
	
	Sleep(2000)
	
	;Searching for 3 pixel to determine if it is really the character selection screen
	If 	(Hex(PixelGetColor( $size[0]+25 , $size[1]+775 ), 6) = 'aa7640' And Hex(PixelGetColor( $size[0]+1010 , $size[1]+775 ), 6) = 'dfb677' And Hex(PixelGetColor( $size[0]+1010 , $size[1]+35 ), 6) = 'dbb070') Then
		$isCharScreen = True
	EndIf
	
	;Default character screen
	If $isCharScreen = True Then
		ClickLoc($size[0]+625, $size[1]+185+(($aRecords[10]-1)*145))
		Sleep(200)
		ControlSend($WinTitle,'','','{ENTER}');
	EndIf
	
	Sleep(3000)
EndFunc

Func checkHp70()
	$size = WinGetPos($WinTitle)
	;checking if hp falls below 70%
	$checkHp70 = Hex(PixelGetColor( $size[0]+675 , $size[1]+730 ), 6)
	
	;If hp falls below 70% autopot
	If $checkHp70 = '343434' Then
		ControlSend($WinTitle,'','','{1}');Uses hp pots
		Sleep(10000)
	EndIf
EndFunc

Func checkMp70()
	$size = WinGetPos($WinTitle)
	;checking if mp falls below 70%
	$checkMp70 =  Hex(PixelGetColor( $size[0]+675 , $size[1]+767 ), 6)

	;If mp falls below 70% autopot
	If $checkMp70 = '6D6D6C' Then
		ControlSend($WinTitle,'','','{2}');Uses mp pots
		Sleep(10000)
	EndIf
EndFunc

;FUNCTION FOR DOING CLICKING ON LOCATION OF THE SCREEN
;THIS FUNC WILL MINIMIZE AND RESTORE THE GAME INTERFACE
;AS DURING FOCUSING ON THE GAME THE MOUSE WILL NOT MOVE
Func ClickLoc($LocX, $LocY)
	WinSetState($WinTitle, "", @SW_MINIMIZE)
	MouseMove($LocX, $LocY, 0)
	WinActivate($WinTitle)
	ControlClick($WinTitle,'','','primary', 3)
	ControlClick($WinTitle,'','','primary', 3)
EndFunc

Func Terminate()
    Exit 0
EndFunc
The config.dat file
Code:
[AutoLogin]
True
[Password]
Password
[DefaultServer]
Kaye
[DefaultChannel]
5
[DefaultCharacter]
1
As the script is getting information @ a specific line so even if u don't want certain things to execute that line must still be there just empty that line or enter something the script doesn't understands :p

[AutoLogin] >>> True/False
[Password] >>> Autologin password
[Default Server] >>> Kaye/Elga
[DefaultChannel] >>> 1 to 10
[DefaultCharacter] >>> 1 to 4

The below is just an example
Code:
[AutoLogin]
True
[Password]
Password
[DefaultServer]

[DefaultChannel]
5
[DefaultCharacter]
The script will AutoLogin, with password as "Password".
It will skip the default server selection and proceed to choose channel 5.
And no character will be selected at the character selection screen.

Pardon me for a poorly written script. But I'm just sharing :D
08/13/2009 04:31 lon3lykid#2
wow~ i try to understand the coding but failed...
anyway, thk for sharing & try to apply to my chracter
08/13/2009 21:34 gentorsic#3
im a complete noob using autoit. i just need some enlightenment how and where to use those codes.
08/13/2009 23:50 B 2 The Lessed#4
Quote:
Originally Posted by gentorsic View Post
im a complete noob using autoit. i just need some enlightenment how and where to use those codes.
scite script editor, c&p the code and change what has to be changed. Save it to somewhere on your computer, rightclick the file and click 'Run Script'.
08/14/2009 00:34 beansprout#5
Only need the Auto pot.. Can help removing the auto login script? I tried but failed, Lol ~
08/14/2009 04:10 DragonicaIt#6
Quote:
Originally Posted by beansprout View Post
Only need the Auto pot.. Can help removing the auto login script? I tried but failed, Lol ~
Code:
;HotKey for terminating the script
HotKeySet("{F11}", "Terminate") 

$i = 1
;Window title for dragonica should be changed after every patch
$WinTitle = "Dragonica (Client Ver : 0.1.25)"	

;Force focus on dragonica
WinActivate($WinTitle)	

;Continuous looping
While $i <> 0	
	if $i = 2 Then
		Sleep(500)
		$i = 1
	Else
		;If the game exist check for hp and mp
		If (WinExists($WinTitle)) Then
			checkHp70()
			checkMp70()
		EndIf
		$i = 2
	EndIf
WEnd

Func checkHp70()
	$size = WinGetPos($WinTitle)
	;checking if hp falls below 70%
	$checkHp70 = Hex(PixelGetColor( $size[0]+675 , $size[1]+730 ), 6)
	
	;If hp falls below 70% autopot
	If $checkHp70 = '343434' Then
		ControlSend($WinTitle,'','','{1}');Uses hp pots
		Sleep(10000)
	EndIf
EndFunc

Func checkMp70()
	$size = WinGetPos($WinTitle)
	;checking if mp falls below 70%
	$checkMp70 =  Hex(PixelGetColor( $size[0]+675 , $size[1]+767 ), 6)

	;If mp falls below 70% autopot
	If $checkMp70 = '6D6D6C' Then
		ControlSend($WinTitle,'','','{2}');Uses mp pots
		Sleep(10000)
	EndIf
EndFunc

Func Terminate()
    Exit 0
EndFunc
I'm outside now so just edit and not tested but it should work.
08/14/2009 06:11 beansprout#7
Works for me. Screen resolution 1440 x 900 no problem :D

Thanks.
08/14/2009 12:00 gseed87#8
can u make a 1280 X 800 script? thx!
08/14/2009 12:19 DragonicaIt#9
Quote:
Originally Posted by gseed87 View Post
can u make a 1280 X 800 script? thx!
It works for all the resolution cause it is base on the window x,y location. Just use it and let me know
08/14/2009 13:03 notme0914#10
autoti have time set ?
08/14/2009 13:11 notme0914#11
if i want set auto log out n in back in every 1 hour how to set the scrript ?
08/14/2009 14:42 DragonicaIt#12
Quote:
Originally Posted by notme0914 View Post
if i want set auto log out n in back in every 1 hour how to set the scrript ?
There is no implementation of such feature, will look into it if i have the time :p
08/14/2009 16:03 Zacko7#13
I'm not one to like Auto-It scripts. I'll try to find a way to prevent that "OMFG UR HaxINg TYPE THE LETTERS" from appearing. ^^
08/14/2009 18:30 gentorsic#14
newbie question. ive downloaded the auto it v3 and copied the script. but i doesnt work for me. am i gonna save the file as au3? or .dat? and save it in the FD folder?
08/14/2009 18:40 gentorsic#15
i've compiled it and tried to run it along with FD 1.25 and it was detected. any solutions for this?