Sign in to follow this  
Followers 0
danzar

Could this be better

7 posts in this topic

i am new but real excited about the use of this program. i would like some feedback on this rough but runable script. i just tring to learn from more experince people.

thanks

danzar

CODE
Global $mob

Opt("MouseCoordMode", 0)

Opt("PixelCoordMode", 0)

Opt("MouseClickDelay", 0)

Opt("MouseClickDownDelay", 0)

Global $Paused

HotKeySet("{HOME}", "Terminate") ;

HotKeySet("{Pause}", "TogglePause");

HotKeySet("{ESC}", "Terminate");

;starts here

Opt("WinTitleMatchMode", 4)

WinWait("RF Online","")

ControlClick("RF Online","","D3D Window0")

while 1

call("lookingfor")

WEnd

func lookingfor()

$findmob = pixelgetcolor(445,54)

if $findmob <> 16250863 Then

call("targetbrutal")

Else

sleep(0)

EndIf

EndFunc

func targetbrutal()

$rand = Random(1,2,1)

switch $rand

Case 1

Opt("SendKeyDownDelay", 10)

send("{d}")

$mob = PixelSearch(0,0,800,600,0x381E0A,1,1)

if not @error Then

MouseClick("left", $mob[0],$mob[1])

send("{SPACE}")

EndIf

CASE 2

ContinueCase

EndSwitch

EndFunc

Func TogglePause()

$Paused = NOT $Paused

While $Paused

sleep(100)

ToolTip('Script is "Paused"',0,0)

WEnd

EndFunc

Func Terminate()

Exit 0

EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Good start. Some general comments:

1. Group your Opts and Globals together.

2. Use mixed case letters in all names. All lower case/upper case is hard to read.

3. Use the "MustDeclareVars" option so that you force yourself to declare local/global variables.

4. Don't use Call() as it has very specific uses.

Opt("MouseClickDelay", 0)
Opt("MouseClickDownDelay", 0)
Opt("MouseCoordMode", 0)
Opt("MustDeclareVars", 1)
Opt("PixelCoordMode", 0)
Opt("SendKeyDownDelay", 10)
Opt("WinTitleMatchMode", 4)

Global $Mob
Global $Paused

HotKeySet("{HOME}", "Terminate") ;
HotKeySet("{Pause}", "TogglePause");
HotKeySet("{ESC}", "Terminate");

;
; Main
;
WinWait("RF Online", "") ; <-- Might want to use WinWaitActive here
ControlClick("RF Online", "", "D3D Window0")

While 1
  if PixelGetColor(445, 54) <> 16250863 Then
    if Random(1, 2, 1) = 1 then
      Send("{d}")    
      $Mob = PixelSearch(0, 0, 800, 600, 0x381E0A, 1, 1)
      if not @error Then
        MouseClick("left", $Mob[0], $Mob[1])
        Send("{SPACE}")
      EndIf
    EndIf
  EndIf
  Sleep(100)
WEnd

;
; TogglePause
;
Func TogglePause()
  $Paused = Not $Paused
  While $Paused
    Sleep(100)
    ToolTip('Script is "Paused"', 0, 0)
  WEnd
EndFunc

;
; Terminate
;
Func Terminate()
  Exit
EndFunc

Edit: Took a little more liberty with the original code :P

Edited by PaulIA

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Unnecessary use of Call :P

call("lookingfor")oÝ÷ ÙƧë-m殶­sfÆöö¶ævf÷"oÝ÷ ٩ݲ'jwp+ay)^zrÛ²¢ç;¬¶Ö¤z­¶°^[rV®±æ®¶­sdgVæ2Æöö¶ætf÷"¢b33c´fæDÖö"ÒVÆvWF6öÆ÷"CCRÃSB¢bb33c´fæDÖö"fÇC²fwC²c#Sc2FVà¢F&vWD''WF¢VÇ6R¢6ÆVW²fÇC²ÒÒ6ÆVWð¢VæD`¤VæDgVæ0
Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

Oh, and please use Tidy on your code. it is a great tool.


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

wow theguy those were so beautiful code/autoit tags :P

Share this post


Link to post
Share on other sites

wow theguy those were so beautiful code/autoit tags :D

:P

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

Thank you for your time and imput

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0