Sign in to follow this  
Followers 0
sandman

Script Optimization?

7 posts in this topic

Alright, this script functions fine until it starts actually doing something. Once I press Start, it doesn't respond to a Stop click or the X button. It takes about 10%CPU when it is running. How can I optimize this to run faster and respond?

; Autolooter by sandman: made for 1280x1024 screens. Soon to be remodeled for other screen sizes.

#include <GUIConstants.au3>
$lootwin = GUICreate("AutoLoot 0.1", 301, 101, 302, 173)
$startbtn = GUICtrlCreateButton("Start", 24, 16, 75, 25, 0)
$helpbtn = GUICtrlCreateButton("Help", 24, 56, 75, 25, 0)
$stopbtn = GUICtrlCreateButton("Stop", 176, 16, 75, 25, 0)
$aboutbtn = GUICtrlCreateButton("About", 176, 56, 75, 25, 0)
GUISetState(@SW_SHOW)

$active = 0

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $startbtn
            CheckActive()
        Case $msg = $stopbtn
            CheckActive()
        Case $msg = $helpbtn
            MsgBox(0, "Help", "The most commonly experienced problem and probably the only problem is that for some reason, the program isn't doing anything to" & _
            "affect the MYKO window. This is almost definitely because you need to run the HS bypass program by frognik before you run MYKO and this autolooter" & _
            "each time before you start playing.")
        Case $msg = $aboutbtn
            MsgBox(0, "About", "This program was created by sandman in a 1-week time period. Copying this product and redistributing said product is strictly" & _
            "prohibited unless you or the reproducer, whoever he or she is, has my formal written permission and authorization that I have given this permission." & _
            "Questions and comments can go to may_contain_peanuts@yahoo.com. (C) 2007 sandman. All rights reserved.")
    EndSelect
WEnd
    
Func CheckActive()
    If $active = 0 Then
        AdLibEnable("loot")
        GUICtrlSetState($startbtn, $GUI_DISABLE)
        GUICtrlSetState($stopbtn, $GUI_ENABLE)
        $start = 1
    Else
        AdLibDisable("loot")
        GUICtrlSetState($startbtn, $GUI_ENABLE)
        GUICtrlSetState($stopbtn, $GUI_DISABLE)
        $active = 0
    EndIf
EndFunc

Func loot()
    $treasure = PixelSearch(168, 143, 930, 713, "40281e") ; Search for a treasure box
    If Not @error Then
        MouseClick("", $treasure[0], $treasure[1])
        Sleep(2000)
    EndIf
    $loot1 = PixelSearch(168, 143, 930, 713, "796d5f") ; Search for money if it is dropped
    If Not @error Then
        MouseClick("", $loot1[0], $loot1[1])
    EndIf       
    Sleep(1000)
EndFunc

I have 1gig ram and a 2.3GHz CPU.. shouldn't this run fine?


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Well if you just want a simple shut off the program button... heres what i have on my script...

HotKeySet("{ESC}","Terminate")
;code here blah blah blah

;at bottom of script

Func Terminate ()
    Exit
EndFunc

EDIT: Im not sure about speeding it up...

P.S. May i ask what game this is for? :whistle:

Edited by BuddyBoy

Share this post


Link to post
Share on other sites

1

Dim $active = 0

2

Replace

$start = 1

with

$active = 1

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Oh, I already did that.. forgot to change it in the script I posted.

BuddyBoy, this game is for Malaysian Knight Online and only works for that game. I tried something like that, and it won't respond. I may have to narrow down the pixel search area.


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I may have to narrow down the pixel search area.

Yea this will certainly make you script go faster.

Try this, maybe it will work faster than Pixelsearch.

For $i = XXX to XXX ; x coordinates
    For $j = YYY to YYY ; y coordinates
        $loot1 = PixelGetColor($i, $j)
        If $loot1 = "40281e" Then MouseClick("", $loot1[0], $loot1[1])
    Next
Next
Edited by J0ker

Share this post


Link to post
Share on other sites

Func loot()
    $treasure = PixelSearch(168, 143, 930, 713, "40281e"); Search for a treasure box
    If Not @error Then
        MouseClick("", $treasure[0], $treasure[1])
        Sleep(2000)
    EndIf
    $loot1 = PixelSearch(168, 143, 930, 713, "796d5f"); Search for money if it is dropped
    If Not @error Then
        MouseClick("", $loot1[0], $loot1[1])
    EndIf     
    Sleep(1000)
EndFunc

PixelSearch(168, 143, 930, 713, "796d5f", 0, 1-20) <--- change 1-20 to whatever you wish, higher the number, the less delay, but it won't be as pinpoint accurate (I use 5-10 on games that require high accuracy)

Share this post


Link to post
Share on other sites

j0ker isn't that the same thing pixelsearch would do -.-

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