face Posted August 16, 2014 Posted August 16, 2014 i need to search more than one color at a time i have this code expandcollapse popup#NoTrayIcon #include <GUIConstants.au3> #include <Misc.au3> HotKeySet("!^x", "Abort") Global $CurrentColor = "0xAF0000" Global $StartX = IniRead("MineData.ini", "Pos", "X",0) Global $StartY = IniRead("MineData.ini", "Pos", "Y",0) Global $x = $StartX, $y = $StartY Global $ScanWidth = 200, $ScanHeight = 200 Global $T1[5],$T2[5] Global $SleepCheck = 500, $SleepMine = 4000 Global $Idle = 0 Global $MoveMode = True Global $AppTitle = "app" Global $ColorClay = IniRead("MineData.ini", "Colors", "Clay", "?") Global $ColorCopper = IniRead("MineData.ini", "Colors", "Copper", 9003840) Global $ColorTin = IniRead("MineData.ini", "Colors", "Tin", 7432553) Global $ColorIron = IniRead("MineData.ini", "Colors", "Iron", 4072732) Global $ColorSilver = IniRead("MineData.ini", "Colors", "Silver", 16777215) Global $ColorCoal = IniRead("MineData.ini", "Colors", "Coal", 3815975) Global $ColorGold = IniRead("MineData.ini", "Colors", "Gold", 10193720) Global $ColorMithril = IniRead("MineData.ini", "Colors", "Mithril", 5329529) Global $ColorAddy = IniRead("MineData.ini", "Colors", "Addy", "?") Global $ColorRunite = IniRead("MineData.ini", "Colors", "Runite", "?") ;beta below Global $Sens = IniRead("MineData.ini", "Beta", "Sensitifity", 8) Global $AverageX, $AverageY, $i $GUI = GUICreate($AppTitle,110,40,$x,$y,$WS_POPUP) $ColorLabel = GUICtrlCreateLabel("Color",0,1,110,20,$SS_CENTER) SetColor() $Sleep = GUICtrlCreateEdit("Stopped", 0, 20,110,20,$ES_AUTOVSCROLL+$ES_AUTOHSCROLL+$ES_READONLY+$ES_CENTER) GUICtrlSetBkColor(-1,0xFFFFFF) GUISetState() WinSetOnTop($GUI,"",1) $menu = GUICtrlCreateContextMenu ($ColorLabel) $Start = GUICtrlCreateMenuitem ("Start!", $menu,-1,1) $Stop = GUICtrlCreateMenuitem ("Stop", $menu,-1,1) GUICtrlSetState(-1,$GUI_CHECKED) GUICtrlCreateMenuitem ("",$menu) $Time1Menu = GUICtrlCreateMenu ("Check Interval", $menu) $T1[0] = GUICtrlCreateMenuitem ("200 ms", $Time1Menu,-1,1) $T1[1] = GUICtrlCreateMenuitem ("500 ms", $Time1Menu,-1,1) GUICtrlSetState(-1,$GUI_CHECKED) $T1[2] = GUICtrlCreateMenuitem ("1 sec", $Time1Menu,-1,1) $T1[3] = GUICtrlCreateMenuitem ("2 sec", $Time1Menu,-1,1) $T1[4] = GUICtrlCreateMenuitem ("Custom", $Time1Menu,-1,1) $Time2Menu = GUICtrlCreateMenu ("Mine Interval", $menu) $T2[0] = GUICtrlCreateMenuitem ("1 sec", $Time2Menu,-1,1) $T2[1] = GUICtrlCreateMenuitem ("2 sec", $Time2Menu,-1,1) $T2[2] = GUICtrlCreateMenuitem ("4 sec", $Time2Menu,-1,1) GUICtrlSetState(-1,$GUI_CHECKED) $T2[3] = GUICtrlCreateMenuitem ("6 sec", $Time2Menu,-1,1) $T2[4] = GUICtrlCreateMenuitem ("Custom", $Time2Menu,-1,1) GUICtrlCreateMenuitem ("",$menu) $move = GUICtrlCreateMenuitem ("Move Screen", $menu) $Resize = GUICtrlCreateMenuitem ("Set Scansize", $menu) $Colormenu = GUICtrlCreateMenu ("Select Color", $menu) $Pick = GUICtrlCreateMenuitem ("By Screen Color", $Colormenu) $OreMenu = GUICtrlCreateMenu ("By Ore", $Colormenu) $MenuClay = GUICtrlCreateMenuitem ("Clay", $OreMenu) $MenuTin = GUICtrlCreateMenuitem ("Tin", $OreMenu) $MenuCopper = GUICtrlCreateMenuitem ("Copper", $OreMenu) $MenuIron = GUICtrlCreateMenuitem ("Iron", $OreMenu) $MenuSilver = GUICtrlCreateMenuitem ("Silver", $OreMenu) $MenuCoal = GUICtrlCreateMenuitem ("Coal", $OreMenu) $MenuGold = GUICtrlCreateMenuitem ("Gold", $OreMenu) $MenuMithril = GUICtrlCreateMenuitem ("Mithril", $OreMenu) $MenuAddy = GUICtrlCreateMenuitem ("Adamantite", $OreMenu) $MenuRunite = GUICtrlCreateMenuitem ("Runite", $OreMenu) GUICtrlCreateMenuitem ("",$menu) $Preferences = GUICtrlCreateMenuitem ("Preferences", $menu) $Help = GUICtrlCreateMenuitem ("Help", $menu) GUICtrlCreateMenuitem ("",$menu) $Exit = GUICtrlCreateMenuitem ("Exit", $menu) $Top = GUICreate("Top Line", $ScanWidth, 2,$x,$y + 40,$WS_POPUP,-1,$GUI) GUISetBkColor(0xFF0000) GUISetState() $Left = GUICreate("Left Line", 2, $ScanHeight,$x,$y + 40,$WS_POPUP,-1,$GUI) GUISetBkColor(0xFF0000) GUISetState() $Right = GUICreate("Right Line", 2, $ScanHeight,$x + $ScanWidth - 2,$y + 40,$WS_POPUP,-1,$GUI) GUISetBkColor(0xFF0000) GUISetState() $Bottom = GUICreate("Bottom Line", $ScanWidth, 2,$x,$y + 40 + $ScanHeight,$WS_POPUP,-1,$GUI) GUISetBkColor(0xFF0000) GUISetState() HotKeySet("^f","DisplayColor") HotKeySet("^z","Start") HotKeySet("^x","Stop") HotKeySet("^x","Stop") HotKeySet("^a","Move") While 1 $msg = GUIGetMsg() Select Case $msg = $Start Check() Case $msg = $Stop AdlibUnRegister() GUICtrlSetData($Sleep,"Stopped") Case $msg = $ColorLabel $NewColor = _ChooseColor(2,$CurrentColor,2) If Not @error Then $CurrentColor = $NewColor SetColor() EndIf Case $msg = -3 Exit Case $msg = $move Stop() $MoveMode = True While 1 $MousePos = MouseGetPos() WinMove($GUI,"", $MousePos[0],$MousePos[1]) WinMove($Top,"", $MousePos[0],$MousePos[1]+40) WinMove($Left,"", $MousePos[0],$MousePos[1]+40) WinMove($Right,"", $MousePos[0]+ $ScanWidth - 2,$MousePos[1]+40) WinMove($Bottom,"", $MousePos[0],$MousePos[1]+ 40 + $ScanHeight) $x = $MousePos[0] $y = $MousePos[1] If _IsPressed(01) Then ExitLoop EndIf WEnd Case $msg = $Pick While 1 $MousePos = MouseGetPos() If Not @error Then $NewColor = PixelGetColor($MousePos[0],$MousePos[1]) GUICtrlSetBkColor($ColorLabel,$NewColor) GUISetBkColor($NewColor,$GUI) EndIf Sleep(200) If _IsPressed(01) Then ExitLoop EndIf WEnd If $NewColor <> -1 Then $CurrentColor = $NewColor EndIf SetColor() Case $msg = $Resize Resize() Case $msg = $Preferences Preferences() Case $msg = $Exit Exit Case $msg = $T1[0] $SleepCheck = 200 Case $msg = $T1[1] $SleepCheck = 500 Case $msg = $T1[2] $SleepCheck = 1000 Case $msg = $T1[3] $SleepCheck = 2000 Case $msg = $T1[4] $Input = Number(InputBox("Custom Checking Time", "How many ms do you want to wait?", $SleepCheck,"", 200,162,$x+111,$y)) If (Not @error) AND (IsNumber($Input)) AND ($Input <> 0) Then $SleepCheck = Round($Input) Else $SleepCheck = 500 GUICtrlSetState($T1[1],$GUI_CHECKED) GUICtrlSetState($T1[4],$GUI_UNCHECKED) EndIf Case $msg = $T2[0] $SleepMine = 1000 Case $msg = $T2[1] $SleepMine = 2000 Case $msg = $T2[2] $SleepMine = 4000 Case $msg = $T2[3] $SleepMine = 6000 Case $msg = $T2[4] $Input = Number(InputBox("Custom Mining Time", "How many ms do you want to wait?", $SleepMine,"", 200,162,$x+111,$y)) If (Not @error) AND (IsNumber($Input)) AND ($Input <> 0) Then $SleepMine = Round($Input) Else $SleepMine = 4000 GUICtrlSetState($T2[3],$GUI_CHECKED) GUICtrlSetState($T2[4],$GUI_UNCHECKED) EndIf Case $msg = $MenuClay $CurrentColor = $ColorClay SetColor() Case $msg = $MenuTin $CurrentColor = $ColorTin SetColor() Case $msg = $MenuCopper $CurrentColor = $ColorCopper SetColor() Case $msg = $MenuIron $CurrentColor = $ColorIron SetColor() Case $msg = $MenuSilver $CurrentColor = $ColorSilver SetColor() Case $msg = $MenuCoal $CurrentColor = $ColorCoal SetColor() Case $msg = $MenuGold $CurrentColor = $ColorGold SetColor() Case $msg = $MenuMithril $CurrentColor = $ColorMithril SetColor() Case $msg = $MenuAddy $CurrentColor = $ColorAddy SetColor() Case $msg = $MenuRunite $CurrentColor = $ColorRunite SetColor() EndSelect WEnd Func Check() Sleep(Random(0,500,1)) $Pixel = PixelSearch($x+2,$y+42,$x+2+$ScanWidth,$y+42+$ScanHeight,$CurrentColor,$Sens) If Not @error Then MouseClick("Left", $Pixel[0],$Pixel[1],1,2) GUICtrlSetData($Sleep,"Mining | " & $SleepMine & " ms") $Idle = 0 AdlibRegister("Check", $SleepMine) Else GUICtrlSetData($Sleep,"Checking | " & $SleepCheck & " ms") $Idle += $SleepCheck If $Idle >= 60000 Then MouseClick("Left") $Idle = 0 EndIf AdlibRegister("Check", $SleepCheck) EndIf EndFunc Func DisplayColor() InputBox("Copy & Paste Box", "This is the variable $CurrentColor:", $CurrentColor) EndFunc Func Resize() HotKeySet("^a") Stop() $MoveMode = True While 1 $MousePos = MouseGetPos() WinMove($Top,"", $x,$y+40,$ScanWidth,2) WinMove($Left,"", $x,$y+40,2,$ScanHeight) WinMove($Right,"", $x+ $ScanWidth - 2,$y+40,2,$ScanHeight) WinMove($Bottom,"", $x,$y+ 40 + $ScanHeight,$ScanWidth,2) If Not (($MousePos[0] - $x + 1) <= 40) Then $ScanWidth = $MousePos[0] - $x + 1 EndIf If Not (($MousePos[1] - $y - 39) <= 40) Then $ScanHeight = $MousePos[1] - $y - 39 EndIf If _IsPressed(01) Then ExitLoop EndIf WEnd HotKeySet("^a","Move") EndFunc Func SetColor() GUICtrlSetBkColor($ColorLabel,$CurrentColor) GUISetBkColor($CurrentColor,$GUI) EndFunc Func Abort() AdlibUnRegister() HotKeySet("!^x") SplashTextOn("Alert", "Emergency Exit", 200,30) Sleep(800) Exit EndFunc Func Start() Check() GUICtrlSetState($Stop,$GUI_UNCHECKED) GUICtrlSetState($Start,$GUI_CHECKED) EndFunc Func Stop() AdlibUnRegister() GUICtrlSetData($Sleep,"Stopped") AdlibUnRegister() GUICtrlSetData($Sleep,"Stopped") GUICtrlSetState($Stop,$GUI_CHECKED) GUICtrlSetState($Start,$GUI_UNCHECKED) EndFunc Func Move() If $MoveMode Then Stop() SetProgramPos($StartX,$StartY) Else SetProgramPos($x,$y) EndIf $MoveMode = Not $MoveMode EndFunc Func SetProgramPos($x,$y) WinMove($GUI,"", $x,$y) WinMove($Top,"", $x,$y+40) WinMove($Left,"", $x,$y+40) WinMove($Right,"", $x+ $ScanWidth - 2,$y+40) WinMove($Bottom,"", $x,$y+ 40 + $ScanHeight) EndFunc Func Preferences() Stop() $Pref = GUICreate("Preferences", 453, 462) ; Left side GUICtrlCreateLabel("The colors " & $AppTitle & " looks for are below." & @CRLF & "The color can be a hex or a decimal. To get a color use the ""Select Color > By Screen Color"" mode and press ""Ctrl + F""", 5, 5, 233, 52) GUICtrlCreateGroup("Colors", 0, 55, 240, 285) $InputClay = GUICtrlCreateInput($ColorClay, 105, 75, 121, 21) GUICtrlCreateLabel("Clay", 10, 80, 43, 17) $InputCopper = GUICtrlCreateInput($ColorCopper, 105, 100, 121, 21) GUICtrlCreateLabel("Copper", 10, 105, 53, 17) $InputTin = GUICtrlCreateInput($ColorTin, 105, 125, 121, 21) GUICtrlCreateLabel("Tin", 10, 130, 53, 17) $InputIron = GUICtrlCreateInput($ColorIron, 105, 150, 121, 21) GUICtrlCreateLabel("Iron", 10, 155, 53, 17) $InputSilver = GUICtrlCreateInput($ColorSilver, 105, 175, 121, 21) GUICtrlCreateLabel("Silver", 10, 180, 53, 17) $InputCoal = GUICtrlCreateInput($ColorCoal, 105, 200, 121, 21) GUICtrlCreateLabel("Coal", 10, 205, 53, 17) $InputGold = GUICtrlCreateInput($ColorGold, 105, 225, 121, 21) GUICtrlCreateLabel("Gold", 10, 230, 53, 17) $InputMithril = GUICtrlCreateInput($ColorMithril, 105, 250, 121, 21) GUICtrlCreateLabel("Mithril", 10, 255, 53, 17) $InputAddy = GUICtrlCreateInput($ColorAddy, 105, 275, 121, 21) GUICtrlCreateLabel("Adamantite", 10, 280, 53, 17) $InputRunite = GUICtrlCreateInput($ColorRunite, 105, 300, 121, 21) GUICtrlCreateLabel("Runite", 10, 305, 53, 17) GUICtrlCreateLabel("These represent the starting point for the program. They are also the coordinates used with Ctrl + A.", 0, 345, 239, 47) GUICtrlCreateGroup("X and Y", 0, 380, 240, 50) $InputX = GUICtrlCreateInput($StartX, 30, 400, 86, 21) $InputY = GUICtrlCreateInput($StartY, 120, 400, 86, 21) ;Right side GUICtrlCreateLabel("The right side contains Beta functions only. These are more advanced and may cause unexplainable errors.", 245, 5, 204, 42) GUICtrlCreateGroup("Beta Options", 245, 55, 205, 285) $CenterCheckbox = GUICtrlCreateCheckbox("", 255, 75, 187, 17) $ColorCheckbox = GUICtrlCreateCheckbox("", 255, 100, 187, 17) GUICtrlCreateLabel("Color match sensitivity. Move the slider to the left for a harder match.", 255, 125, 179, 27) $SensSlider = GUICtrlCreateSlider(255, 155, 180, 30) GUICtrlSetLimit(-1,20,1) GUICtrlSetData(-1,$Sens) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Drop Options", 250, 245, 195, 85) $DropNormal = GUICtrlCreateRadio("", 260, 265, 113, 17) $DropMagic = GUICtrlCreateRadio("", 260, 285, 113, 17) $DropNone = GUICtrlCreateRadio("No Drop (Default)", 260, 305, 113, 17) GUICtrlSetState(-1,$GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) ;Bottom Buttons $DefaultButton = GUICtrlCreateButton("Default Values", 5, 435, 135, 25) $OkButton = GUICtrlCreateButton("OK", 145, 435, 90, 25) GUICtrlSetState(-1,$GUI_FOCUS) GUISetState(@SW_SHOW) WinSetOnTop($Pref, "", 1) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $OkButton IniWrite("MineData.ini", "Colors", "Clay", GUICtrlRead($InputClay)) IniWrite("MineData.ini", "Colors", "Copper", GUICtrlRead($InputCopper)) IniWrite("MineData.ini", "Colors", "Tin", GUICtrlRead($InputTin)) IniWrite("MineData.ini", "Colors", "Iron", GUICtrlRead($InputIron)) IniWrite("MineData.ini", "Colors", "Silver", GUICtrlRead($InputSilver)) IniWrite("MineData.ini", "Colors", "Coal", GUICtrlRead($InputCoal)) IniWrite("MineData.ini", "Colors", "Gold", GUICtrlRead($InputGold)) IniWrite("MineData.ini", "Colors", "Mithril", GUICtrlRead($InputMithril)) IniWrite("MineData.ini", "Colors", "Addy", GUICtrlRead($InputAddy)) IniWrite("MineData.ini", "Colors", "Runite", GUICtrlRead($InputRunite)) IniWrite("MineData.ini", "Pos", "X", GUICtrlRead($InputX)) IniWrite("MineData.ini", "Pos", "Y", GUICtrlRead($InputY)) $ColorClay = GUICtrlRead($InputClay) $ColorCopper = GUICtrlRead($InputCopper) $ColorTin = GUICtrlRead($InputTin) $ColorIron = GUICtrlRead($InputIron) $ColorSilver = GUICtrlRead($InputSilver) $ColorCoal = GUICtrlRead($InputCoal) $ColorGold = GUICtrlRead($InputGold) $ColorMithril = GUICtrlRead($InputMithril) $ColorAddy = GUICtrlRead($InputAddy) $ColorRunite = GUICtrlRead($InputRunite) ;beta below If GUICtrlRead($CenterCheckbox) = $GUI_CHECKED Then IniWrite("MineData.ini", "Beta", "CenterOnOre", 1) ElseIf GUICtrlRead($CenterCheckbox) = $GUI_UNCHECKED Then IniWrite("MineData.ini", "Beta", "CenterOnOre", 0) EndIf If GUICtrlRead($ColorCheckbox) = $GUI_CHECKED Then IniWrite("MineData.ini", "Beta", "ColorAverage", 1) ElseIf GUICtrlRead($ColorCheckbox) = $GUI_UNCHECKED Then IniWrite("MineData.ini", "Beta", "ColorAverage", 0) EndIf $Sens = GUICtrlRead($SensSlider) IniWrite("MineData.ini", "Beta", "Sensitifity", $Sens) ExitLoop Case $msg = $DefaultButton FileDelete("MineData.ini") MsgBox(0, $AppTitle, "Default values set, please restart " & $AppTitle) Exit EndSelect WEnd GUIDelete() EndFunc how can i make it search for more than one color at a time?
Jfish Posted August 16, 2014 Posted August 16, 2014 Face, I think you probably won't get much help on this post because it appears to be related to gaming and is against the forum rules. I am sure a mod will come along shortly to lock the thread. You can find the rules on the bottom right of every page. Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
Moderators Melba23 Posted August 16, 2014 Moderators Posted August 16, 2014 face,Jfish is quite right - please read the Forum rules (the link is also at bottom right of each page) - particularly the bit about not discussing game automation - before you post again. Thread locked. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts