Jump to content

PixelSearch and .INI problems.


Glyph
 Share

Recommended Posts

[autoit]#Include <XSkin.au3>

#include <Misc.au3>

HotKeySet("{end}","_stop")

$winname="TB AutoSurfer v0.1b"

$dll = DllOpen("user32.dll")

$main=XSkinGUICreate($winname,400,400,@ScriptDir & "\" & "Images")

$Icon_Folder = @ScriptDir & "\Images"

$XIcon = XSkinIcon( $main, 2 )

WinSetOnTop($winname, "", 1)

$colorz="0x00DF25"

$i=0

$hacks=0

GuiCtrlCreateLabel("Bottom Box Dimensions:", 40, 260)

GUICtrlSetColor(-1,$colorz)

$in5 = GuiCtrlCreateInput(IniRead("AutoSurf.ini", "dimensions", "x1", "0"), 40, 275, 50)

GUICtrlSetColor(-1,$colorz)

GUICtrlSetbkColor(-1,"0x000000")

$in6 = GuiCtrlCreateInput(IniRead("AutoSurf.ini", "dimensions", "y1", "0"), 90, 275, 50)

GUICtrlSetColor(-1,$colorz)

GUICtrlSetbkColor(-1,"0x000000")

$in7 = GuiCtrlCreateInput(IniRead("AutoSurf.ini", "dimensions", "x2", "0"), 40, 295, 50)

GUICtrlSetColor(-1,$colorz)

GUICtrlSetbkColor(-1,"0x000000")

$in8 = GuiCtrlCreateInput(IniRead("AutoSurf.ini", "dimensions", "y2", "0"), 90, 295, 50)

GUICtrlSetColor(-1,$colorz)

GUICtrlSetbkColor(-1,"0x000000")

$carrotcolor = GuiCtrlCreateinput(IniRead("AutoSurf.ini", "images", "carrot", "0xFFFFFF"), 40, 185, 75)

GUICtrlSetColor(-1,$colorz)

GUICtrlSetbkColor(-1,"0x000000")

$hatcolor = GuiCtrlCreateinput(IniRead("AutoSurf.ini", "images", "hat", "0xFFFFFF"), 135, 228, 75)

GUICtrlSetColor(-1,$colorz)

GUICtrlSetbkColor(-1,"0x000000")

$feetcolor = GUICtrlCreateinput(IniRead("AutoSurf.ini", "images", "feet", "0xFFFFFF"), 40, 225, 75)

GUICtrlSetColor(-1,$colorz)

GUICtrlSetbkColor(-1,"0x000000")

$earscolor = GUICtrlCreateinput(IniRead("AutoSurf.ini", "images", "ears", "0xFFFFFF"), 135, 185, 75)

GUICtrlSetColor(-1,$colorz)

GUICtrlSetbkColor(-1,"0x000000")

GUICtrlCreateLabel("

tolle indicium

Link to comment
Share on other sites

I don't see any error checking. For example, you test @error after trying to IniRead(), but don't show anything if you get an error. You provide a default value for the IniRead(), but if there's an @error the default value doesn't get used. You need to start thinking about error handling and putting debug statements in your code to see where things are going wrong. Like this example:

Func _lookforhat()
    Local $IniColor = IniRead("AutoSurf.ini", "images", "hat", "0xFFFFFF")
    If @error Then ConsoleWrite("Debug: _lookforhat(), @error from IniRead() = " & @error & @LF)
    ConsoleWrite("Debug: _lookforhat(), $IniColor = " & $IniColor & @LF)

    $coord = PixelSearch(238, 140, 452, 174, $IniColor, 4)
    If @error Then
        ConsoleWrite("Debug: _lookforhat(), @error from PixelSearch() = " & @error & @LF)
    Else
        ConsoleWrite("Debug: _lookforhat(), $coord[0] = " & $coord[0] & ", $coord[1] = " & $coord[1] & @LF)
        $pos = MouseGetPos()
        MouseMove($coord[0], $coord[1], 1)
        MouseClick("left", $coord[0], $coord[1], 1)
        $clicks = $clicks + 1
        IniWrite("AutoSurf.ini", "misc", "clicks", GUICtrlRead($clickshow))
        ControlSetText($winname, "", $clickshow, "Clicks: [" & $clicks & "]")
        MouseMove($pos[0], $pos[1], 1)
        Sleep($time)
    EndIf
EndFunc   ;==>_lookforhat

Run you script from SciTE and monitor the console output to see what's happening.

:D

Edit: Tweaked example for better error reporting

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...