Jump to content

Found this script, but can't get it to work.


 Share

Recommended Posts

I found this while I was working on getting a better understanding of: MouseGetPos, PixelGetColor and ToolTip, it looks like it should do about exactly what I want it to, but it doesn't seem to do anything in its current condition.

Would someone explain how this works, or should work?

Func SelectColor($color_bg)
    sleep(100)
    $msg =     "Left Click on color to Record "
    while 1
        $xy = MouseGetPos()
        $currentpixel = PixelGetColor($xy[0],$xy[1])
        ToolTip("Pixel color:  " & $currentpixel & @LF & $msg)
        If _IsPressed("01") Then
            GUICtrlSetBkColor($display_Color,$currentpixel)
            GUICtrlSetData($display_Color,$currentpixel)    
            $Color_Hex = $currentpixel
    ExitLoop
    EndIf
        Sleep(25)
    WEnd
EndFunc
Link to comment
Share on other sites

I found this while I was working on getting a better understanding of: MouseGetPos, PixelGetColor and ToolTip, it looks like it should do about exactly what I want it to, but it doesn't seem to do anything in its current condition.

Would someone explain how this works, or should work?

That is not a complete script. You have a function declaration with no calls to run the function. Inside that function you have references to Global variables like $display_Color and possibly $Color_Hex for which there is no usage outside the function. It uses an include file that isn't shown, and has an input parameter that isn't used.

Try this as an educational demo:

#include <misc.au3>
HotKeySet("{ESC}", "_Quit")

While 1
    $avAnswer = SelectColor()
    MsgBox(64, "Results", $avAnswer[0] & "," & $avAnswer[1] & " = 0x" & Hex($avAnswer[2], 6))
WEnd

Func SelectColor()
    Sleep(100)
    Local $msg = "Left Click on color to Record "
    While 1
        $xy = MouseGetPos()
        $currentpixel = PixelGetColor($xy[0], $xy[1])
        ToolTip("Pixel location:  " & $xy[0] & "," & $xy[1] & @LF & _
                "Pixel color:  0x" & Hex($currentpixel, 6) & @LF & _
                $msg)
        If _IsPressed("01") Then
            Local $avRET[3] = [$xy[0], $xy[1], $currentpixel]
            Return $avRET
        EndIf
        Sleep(25)
    WEnd
EndFunc   ;==>SelectColor

Func _Quit()
    Exit
EndFunc   ;==>_Quit

:)

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

That is not a complete script. You have a function declaration with no calls to run the function. Inside that function you have references to Global variables like $display_Color and possibly $Color_Hex for which there is no usage outside the function. It uses an include file that isn't shown, and has an input parameter that isn't used.

Try this as an educational demo:

#include <misc.au3>
HotKeySet("{ESC}", "_Quit")

While 1
    $avAnswer = SelectColor()
    MsgBox(64, "Results", $avAnswer[0] & "," & $avAnswer[1] & " = 0x" & Hex($avAnswer[2], 6))
WEnd

Func SelectColor()
    Sleep(100)
    Local $msg = "Left Click on color to Record "
    While 1
        $xy = MouseGetPos()
        $currentpixel = PixelGetColor($xy[0], $xy[1])
        ToolTip("Pixel location:  " & $xy[0] & "," & $xy[1] & @LF & _
                "Pixel color:  0x" & Hex($currentpixel, 6) & @LF & _
                $msg)
        If _IsPressed("01") Then
            Local $avRET[3] = [$xy[0], $xy[1], $currentpixel]
            Return $avRET
        EndIf
        Sleep(25)
    WEnd
EndFunc   ;==>SelectColor

Func _Quit()
    Exit
EndFunc   ;==>_Quit

:)

Yea i was wondering about the $color_bg.

Now that is one nice little program! You basically showed me how to do about 3 things I have been working on figuring out, Thanks man.

Link to comment
Share on other sites

Yea i was wondering about the $color_bg.

Now that is one nice little program! You basically showed me how to do about 3 things I have been working on figuring out, Thanks man.

You're welcome.

:)

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