Sign in to follow this  
Followers 0
autoitrulez

help with color in script

8 posts in this topic

I have this script I made:

HotKeySet("{ESC}", "quit")

$color = 0x7B5585
$game = 0

(GUI WENT HERE, I TOOK OUT TO SAVE SPACE)


While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button_1
            Exit
    EndSelect



    If $game = 1 Then
        If _IsPressed("04") Then
        ;                  ( radiius, color, ?, ?, shade)
            $aSearch = _PixToMouse( GuiCtrlRead($Input_1), 0x7B5585, 0, GUICtrlRead($Input_2) )
            If Not @error Then
                MouseClick('right', $aSearch[0], $aSearch[1], 1, 0)
                Sleep(500)
            EndIf
        EndIf
    EndIf
WEnd

Func _PixToMouse($iVariant, $iColor, $iWinCoord = 2, $iShade = 0, $iStep = 1)
    $OptPCM = Opt('PixelCoordMode', $iWinCoord)
    $OptMCM = Opt('MouseCoordMode', $iWinCoord)
    Local $aMpos = MouseGetPos(), $aPix
    If IsArray($aMpos) Then
        $aPix = PixelSearch($aMpos[0] - $iVariant, $aMpos[1] - $iVariant, _
            $aMpos[0] + $iVariant, $aMpos[1] + $iVariant, $iShade, $iStep)
        Opt('PixelCoordMode', $OptPCM)
        Opt('MouseCoordMode', $OptMCM)
        If IsArray($aPix) Then
            Return $aPix
        EndIf
    EndIf
    Return SetError(1, 0, 0)
EndFunc

Func _IsPressed($v_R, $v_dll = 'user32.dll')
    $v_R = DllCall($v_dll, 'int', 'GetAsyncKeyState', 'int', '0x' & $v_R)
    Return (Not @error And BitAND($v_R[0], 0x8000) = 0x8000) * 1
EndFunc  ;==>_IsPressed 




Func Play()
    If $game < 1 Then
        $game = $game + 1
    Else
        $game = 0
    EndIf
EndFunc

Func quit()
    Exit
EndFunc

The main line I am having trouble with is this:

$aSearch = _PixToMouse( GuiCtrlRead($Input_1), 0x7B5585, 0, GUICtrlRead($Input_2) )

because even thoguh I set color afriation to 0, it will still click on ixes xlose to this color..maybe I messed up somewhere?

I believe it is (radius to search, color, color variation?, step)

if this is wrong, pelase correct, thanks!

Share this post


Link to post
Share on other sites



I have this script I made:

CODE

HotKeySet("{ESC}", "quit")

$color = 0x7B5585

$game = 0

(GUI WENT HERE, I TOOK OUT TO SAVE SPACE)

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

Case $msg = $Button_1

Exit

EndSelect

If $game = 1 Then

If _IsPressed("04") Then

; ( radiius, color, ?, ?, shade)

$aSearch = _PixToMouse( GuiCtrlRead($Input_1), 0x7B5585, 0, GUICtrlRead($Input_2) )

If Not @error Then

MouseClick('right', $aSearch[0], $aSearch[1], 1, 0)

Sleep(500)

EndIf

EndIf

EndIf

WEnd

Func _PixToMouse($iVariant, $iColor, $iWinCoord = 2, $iShade = 0, $iStep = 1)

$OptPCM = Opt('PixelCoordMode', $iWinCoord)

$OptMCM = Opt('MouseCoordMode', $iWinCoord)

Local $aMpos = MouseGetPos(), $aPix

If IsArray($aMpos) Then

$aPix = PixelSearch($aMpos[0] - $iVariant, $aMpos[1] - $iVariant, _

$aMpos[0] + $iVariant, $aMpos[1] + $iVariant, $iShade, $iStep)

Opt('PixelCoordMode', $OptPCM)

Opt('MouseCoordMode', $OptMCM)

If IsArray($aPix) Then

Return $aPix

EndIf

EndIf

Return SetError(1, 0, 0)

EndFunc

Func _IsPressed($v_R, $v_dll = 'user32.dll')

$v_R = DllCall($v_dll, 'int', 'GetAsyncKeyState', 'int', '0x' & $v_R)

Return (Not @error And BitAND($v_R[0], 0x8000) = 0x8000) * 1

EndFunc ;==>_IsPressed

Func Play()

If $game < 1 Then

$game = $game + 1

Else

$game = 0

EndIf

EndFunc

Func quit()

Exit

EndFunc

The main line I am having trouble with is this:

$aSearch = _PixToMouse( GuiCtrlRead($Input_1), 0x7B5585, 0, GUICtrlRead($Input_2) )

because even thoguh I set color afriation to 0, it will still click on ixes xlose to this color..maybe I messed up somewhere?

I believe it is (radius to search, color, color variation?, step)

if this is wrong, pelase correct, thanks!

Per the function declaration:

Func _PixToMouse($iVariant, $iColor, $iWinCoord = 2, $iShade = 0, $iStep = 1)

It's (radius-to-search, color, coordinate-mode, color-variation, step).

:)


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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Per the function declaration:

Func _PixToMouse($iVariant, $iColor, $iWinCoord = 2, $iShade = 0, $iStep = 1)

It's (radius-to-search, color, coordinate-mode, color-variation, step).

:)

thanks, but thats already in the script, ...

unless ur saying thats the exct order?

OH< I GET IT NOW, THANK!!!!

Edited by autoitrulez

Share this post


Link to post
Share on other sites

nevermind, still doesnt work?

any help?

Share this post


Link to post
Share on other sites

nevermind, still doesnt work?

any help?

After adjusting it according to previous posts, what does your call to _PixToMouse() look like now? Or is something else broke?

:)


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

Share this post


Link to post
Share on other sites

$aSearch = _PixToMouse( GuiCtrlRead($Input_1), 0x7B5585, 2, 0, GUICtrlRead($Input_2) )

Share this post


Link to post
Share on other sites

Since I wrote that function, what exactly are you wanting _PixToMouse() to do? And please explain what you think each of the parameters are supposed to do.


[center]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.[/center]

Share this post


Link to post
Share on other sites

oh, u wrote it, i saw it in a thread of BigAssMuffin, (oh,, I looked bak, and yea, u wrote it)

I want it to simply search for that color, and click on it, but for some reason it clicks on that color, or any colors similar to it.

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