Jump to content

Click on color


ashley
 Share

Recommended Posts

  • Moderators

ok thanks for ur opinion, i ahve just one question left...

How can i use the code given to me and it clicks on the color like asked, but then how can i make it move do i diffrent pixel of the same color...

PixelSearch returns an array, once you find the first pixel color then you use MouseClick with the array it (PixelSearch) returns, then continue your search from that area on repeating the above process.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

so there no way of it doing it its self

It's done "itself" as soon as "you" code it.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Haha, ashley! That is a very funny GUI. <_<

I thought it was actually doing stuff, but it is designed to do this.. I suggest you make a working miner first, and only start with the GUI functions until you get them working properly.

Edit: Try this... I hope you study it CAREFULLY so you know what is going, and can continue with this script as a base.

#include <GUIConstants.au3>

;Global $readcolor ; classic example of Global Namespace Polution

#Region ### START Koda GUI section ### Form= ; Hey ash, I like the GUI and how it looks. :) Nicely done.
$Powercutter = GUICreate("Powercutter", 234, 83, 193, 115)
$Button1 = GUICtrlCreateButton("Start", 8, 54, 99, 25, 0)
$Combo1 = GUICtrlCreateCombo("Please select", 8, 8, 217, 25)
GUICtrlSetData($Combo1, "Tree|Oak")
$lable = GUICtrlCreateLabel("Status: Still", 115, 54, 99, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$wait = 20; wait 20ms for next progressstep
$s = 0; progressbar-saveposition
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            If GUICtrlRead($Combo1) <> "Please select" Then ; this is so it will not try to search for a tree called "Please select".. Haha! xD
                _run()
            EndIf
    EndSwitch
WEnd

Func _run()
    #region bullshit ; Sorry I commented this out ashley, I do not like to wait 10 seconds before I can test an app. :)
#cs If GUICtrlRead($Combo1) = "Please Select"  Then Return
    $Progress1 = GUICtrlCreateProgress(8, 32, 212, 20)
    $read = GUICtrlRead($Combo1)
    GUICtrlSetData($lable, "Status: Setting Tree name as: " & $read)
    For $i = $s To 100
        $s = $i;save the current bar-position to $s
        $s = 0
        GUICtrlSetData($Progress1, $i)
        Sleep($wait)
    Next
    Sleep(1000)

    GUICtrlSetData($lable, "Status: Still")
    GUICtrlDelete($Progress1)

    Sleep(1000)
    $Progress1 = GUICtrlCreateProgress(8, 32, 212, 20)
    GUICtrlSetData($lable, "Status: Loading tree infomation")
    For $i = $s To 100
        $s = $i;save the current bar-position to $s
        $s = 0
        GUICtrlSetData($Progress1, $i)
        Sleep($wait)
    Next
    Sleep(1000)

    GUICtrlSetData($lable, "Status: Still")
    GUICtrlDelete($Progress1)
    Sleep(1000)

    $Progress1 = GUICtrlCreateProgress(8, 32, 212, 20)
    GUICtrlSetData($lable, "Status: Loading Anti-Randoms")
    For $i = $s To 100
        $s = $i;save the current bar-position to $s
        $s = 0
        GUICtrlSetData($Progress1, $i)
        Sleep($wait)
    Next
    Sleep(1000)

    GUICtrlSetData($lable, "Status: Failed")
    GUICtrlDelete($Progress1)
    Sleep(1000)

    GUICtrlSetData($lable, "Status: Still")

    MsgBox(48, "Internal Error", "Powerminer has discovered an internal error" & @CRLF & @CRLF & "Code: 002050 Result: 01" & @CRLF & @CRLF & "Powerminer will continue after ok is pressed.")
    #ce
    #endregion

    _runpower()
EndFunc   ;==>_run


Func _runpower()
    Local $sSearchColor = ""
    
    GUICtrlSetData($lable, "Status: Running")
    ;If $readcolor = GUICtrlRead($Combo1) = "Tree"  Then  ; HAHA LOL!!11!1one
    ;   $coord = PixelSearch(0, 0, 20, 300, 0xFF0000, 10)
    ;EndIf
    
    Switch GUICtrlRead($Combo1)
        Case "Tree"
            $sSearchColor = 0xFF0000 ; I don't know the color from mind.. ashley, get this color properly..! Grass is also green, so you have to pick the color carefully.
        Case "Oak"
            $sSearchColor = 0x999999 ; I don't know the color from mind.. ashley, get this color!
    EndSwitch
    
    If $sSearchColor <> "" Then
        $coord = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xFF0000, 10,2) ; using a step value of 2 makes it faster, especially because you are searching the entire screen
        ; The coordinates for pixelsearch should be obtained from the Java applet. I have done this with my miner, so you should study that code and copy it to make it search a specific region
        If Not @error Then
            Sleep(Random(0,200,1)) ; this sleep is a random protection, so you won't get banned for botting :)
            MouseClick("left", $coord[0], $coord[1],1,0) ; using a speed of 0 makes it instantly click, so the user won't have a chance to mess around with us :P
        EndIf
    EndIf
    
    GUICtrlSetData($lable, "Status: Finished") ; at this point we are done cutting ONE tree.. ofcourse we have to repeat it somehow. :)
EndFunc   ;==>_runpower
Edited by Manadar
Link to comment
Share on other sites

Haha, ashley! That is a very funny GUI. <_<

I thought it was actually doing stuff, but it is designed to do this.. I suggest you make a working miner first, and only start with the GUI functions until you get them working properly.

Edit: Try this... I hope you study it CAREFULLY so you know what is going, and can continue with this script as a base.

#include <GUIConstants.au3>

;Global $readcolor ; classic example of Global Namespace Polution

#Region ### START Koda GUI section ### Form= ; Hey ash, I like the GUI and how it looks. :) Nicely done.
$Powercutter = GUICreate("Powercutter", 234, 83, 193, 115)
$Button1 = GUICtrlCreateButton("Start", 8, 54, 99, 25, 0)
$Combo1 = GUICtrlCreateCombo("Please select", 8, 8, 217, 25)
GUICtrlSetData($Combo1, "Tree|Oak")
$lable = GUICtrlCreateLabel("Status: Still", 115, 54, 99, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$wait = 20; wait 20ms for next progressstep
$s = 0; progressbar-saveposition
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            If GUICtrlRead($Combo1) <> "Please select" Then ; this is so it will not try to search for a tree called "Please select".. Haha! xD
                _run()
            EndIf
    EndSwitch
WEnd

Func _run()
    #region bullshit ; Sorry I commented this out ashley, I do not like to wait 10 seconds before I can test an app. :)
#cs If GUICtrlRead($Combo1) = "Please Select"  Then Return
    $Progress1 = GUICtrlCreateProgress(8, 32, 212, 20)
    $read = GUICtrlRead($Combo1)
    GUICtrlSetData($lable, "Status: Setting Tree name as: " & $read)
    For $i = $s To 100
        $s = $i;save the current bar-position to $s
        $s = 0
        GUICtrlSetData($Progress1, $i)
        Sleep($wait)
    Next
    Sleep(1000)

    GUICtrlSetData($lable, "Status: Still")
    GUICtrlDelete($Progress1)

    Sleep(1000)
    $Progress1 = GUICtrlCreateProgress(8, 32, 212, 20)
    GUICtrlSetData($lable, "Status: Loading tree infomation")
    For $i = $s To 100
        $s = $i;save the current bar-position to $s
        $s = 0
        GUICtrlSetData($Progress1, $i)
        Sleep($wait)
    Next
    Sleep(1000)

    GUICtrlSetData($lable, "Status: Still")
    GUICtrlDelete($Progress1)
    Sleep(1000)

    $Progress1 = GUICtrlCreateProgress(8, 32, 212, 20)
    GUICtrlSetData($lable, "Status: Loading Anti-Randoms")
    For $i = $s To 100
        $s = $i;save the current bar-position to $s
        $s = 0
        GUICtrlSetData($Progress1, $i)
        Sleep($wait)
    Next
    Sleep(1000)

    GUICtrlSetData($lable, "Status: Failed")
    GUICtrlDelete($Progress1)
    Sleep(1000)

    GUICtrlSetData($lable, "Status: Still")

    MsgBox(48, "Internal Error", "Powerminer has discovered an internal error" & @CRLF & @CRLF & "Code: 002050 Result: 01" & @CRLF & @CRLF & "Powerminer will continue after ok is pressed.")
    #ce
    #endregion

    _runpower()
EndFunc   ;==>_run
Func _runpower()
    Local $sSearchColor = ""
    
    GUICtrlSetData($lable, "Status: Running")
    ;If $readcolor = GUICtrlRead($Combo1) = "Tree"  Then  ; HAHA LOL!!11!1one
    ;   $coord = PixelSearch(0, 0, 20, 300, 0xFF0000, 10)
    ;EndIf
    
    Switch GUICtrlRead($Combo1)
        Case "Tree"
            $sSearchColor = 0xFF0000 ; I don't know the color from mind.. ashley, get this color properly..! Grass is also green, so you have to pick the color carefully.
        Case "Oak"
            $sSearchColor = 0x999999 ; I don't know the color from mind.. ashley, get this color!
    EndSwitch
    
    If $sSearchColor <> "" Then
        $coord = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xFF0000, 10,2) ; using a step value of 2 makes it faster, especially because you are searching the entire screen
        ; The coordinates for pixelsearch should be obtained from the Java applet. I have done this with my miner, so you should study that code and copy it to make it search a specific region
        If Not @error Then
            Sleep(Random(0,200,1)) ; this sleep is a random protection, so you won't get banned for botting :)
            MouseClick("left", $coord[0], $coord[1],1,0) ; using a speed of 0 makes it instantly click, so the user won't have a chance to mess around with us :P
        EndIf
    EndIf
    
    GUICtrlSetData($lable, "Status: Finished") ; at this point we are done cutting ONE tree.. ofcourse we have to repeat it somehow. :)
EndFunc   ;==>_runpower

lol thnaks m8 dose this atchuly work for u it dont seem to search for the color that u used.

Link to comment
Share on other sites

Did u ever get this to actually recognize the tree color in the Java App ? just curios as Autoit has had issues with color recognition on Java based games in the past.

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Link to comment
Share on other sites

Thanks for the info Manadar, Ima haveto play with Runescape now <_<

I have had problems with Java Widget based apps as well as some java Games, as far as I can tell one of the problems comes from the ones that adjust the transparency of the program. For instance if you set the transparency of a Java app to 99.9% it still looks solid and the End User cant see any difference, but AutoIt freeks out and can only see the pixils under the program not the actual program.

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Link to comment
Share on other sites

  • 1 year later...

But I already told you how to do it :)

here's another example

TrayTip("Click on color", "Move your mouse over the color you want to click and press F10" & @CRLF & "Then press HOME to click and ESC to exit", 3)
Global $color


HotKeySet("{F10}", "getcolor")
HotKeySet("{home}", "click")
HotKeySet("{esc}", "quit")

While 1
    Sleep(100)
WEnd

Func getcolor()
    $pos = MouseGetPos()
    $color = PixelGetColor($pos[0], $pos[1])
EndFunc   ;==>getcolor
Func click()
    $coord = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, $color)
    If Not @error Then
        MouseClick("left", $coord[0], $coord[1])
    EndIf
EndFunc   ;==>click
Func quit()
    Exit
EndFunc   ;==>quit

Nice and simple code man :lmao:

------------------------------------------------------"You are never a loser,until you quit trying"------------------------------------------------------

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...