Jump to content

Recommended Posts

Posted

So i have this part of my script that didn't really work i am not sure why

what its suppose to do is to show the hex color of the green dot but it doesn't :)

#include "GUIConstants.au3"
Global $pos = MouseGetPos(), $new_bobber = 0x00FF00
while 1
Capture_Pixel()



WEnd
;Function to get Color/Coords of Mouse Position
Func GetUnderMouse ()
  ;gets mouse position
   $MouseCoord = MouseGetPos()
  ;finds color under mouse
   $MouseColor_var = PixelGetColor($MouseCoord[0] - 28,$MouseCoord[1] + 2)
  ;converts it to hex
   $MouseColor_hex = Hex ($MouseColor_var, 6)
  ;displays info
   $color = "0x" & $MouseColor_hex
   MsgBox (0,"Mouse Info", "Mouse Position = " & $Mousecoord[0]& "," & $Mousecoord[1] & "  |  MouseColor = " & $color )
EndFunc  ;==>GetUnderMouse

func capture_pixel()    
    $a = GUICreate("GUI", 5, 5, $pos[0] - 30, $pos[1], $WS_POPUP, $WS_EX_TOPMOST )
    GUISetBkColor($new_bobber, $a)
    GUISetState(@SW_SHOW)
    HotKeySet("z", "Getundermouse")
    While 1
        $new = MouseGetPos()
        If $new[0] <> $pos[0] Or $new[1] <> $pos[1] Then
            WinMove("GUI", "", $new[0] - 30, $new[1])
        EndIf
            $pos = $new
            Sleep(20)
    WEnd
    
EndFunc
Posted

Try to hide $a Gui before get the color :)

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Posted

this script is just to get the hex color at the green dot, for learning and a bot i am trying to make

#include "GUIConstants.au3"
Global $pos = MouseGetPos(), $new_bobber = 0x00FF00
while 1
Capture_Pixel()



WEnd
;Function to get Color/Coords of Mouse Position
Func GetUnderMouse ()
  ;gets mouse position
   $MouseCoord = MouseGetPos()
   GUISetState(@SW_HIDE)
  ;finds color under mouse
   $MouseColor_var = PixelGetColor($MouseCoord[0] - 28,$MouseCoord[1] + 2)
   GUISetstate(@SW_SHOW)
  ;converts it to hex
   $MouseColor_hex = Hex ($MouseColor_var, 6)
  ;displays info
   $color = "0x" & $MouseColor_hex
   MsgBox (0,"Mouse Info", "Mouse Position = " & $Mousecoord[0]& "," & $Mousecoord[1] & "  |  MouseColor = " & $color )
EndFunc  ;==>GetUnderMouse

func capture_pixel()    
    $a = GUICreate("GUI", 5, 5, $pos[0] - 30, $pos[1], $WS_POPUP, $WS_EX_TOPMOST )
    GUISetBkColor($new_bobber, $a)
    GUISetState(@SW_SHOW)
    HotKeySet("z", "Getundermouse")
    While 1
        $new = MouseGetPos()
        If $new[0] <> $pos[0] Or $new[1] <> $pos[1] Then
            WinMove("GUI", "", $new[0] - 30, $new[1])
        EndIf
            $pos = $new
            Sleep(20)
    WEnd
    
EndFunc

i added the hide and show around the get color line but it still shows me the green color :S

Posted

Works for me..

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Posted

Here is a little better code :)

#include "GUIConstants.au3"
Global $pos = MouseGetPos(), $new_bobber = 0x00FF00
Local $a
$gui = GUICreate("")
GUISetState(@SW_HIDE)
while 1
Capture_Pixel()
WEnd
;Function to get Color/Coords of Mouse Position
Func GetUnderMouse ()
  ;gets mouse position
   $MouseCoord = MouseGetPos()
   GUISetState(@SW_HIDE,$a)
  ;finds color under mouse
   $MouseColor_var = PixelGetColor($MouseCoord[0] - 28,$MouseCoord[1] + 2)
  ;converts it to hex
   $MouseColor_hex = Hex ($MouseColor_var, 6)
  ;displays info
   $color = "0x" & $MouseColor_hex
   MsgBox (0,"Mouse Info", "Mouse Position = " & $Mousecoord[0]& "," & $Mousecoord[1] & "  |  MouseColor = " & $color )
    GUISetstate(@SW_SHOW,$a)
EndFunc  ;==>GetUnderMouse

func capture_pixel()    
    $a = GUICreate("GUI", 5, 5, $pos[0] - 30, $pos[1], $WS_POPUP, $WS_EX_TOPMOST,$gui)
    GUISetBkColor($new_bobber, $a)
    GUISetState(@SW_SHOW)
    HotKeySet("z", "Getundermouse")
    While 1
        $new = MouseGetPos()
        If $new[0] <> $pos[0] Or $new[1] <> $pos[1] Then
            WinMove("GUI", "", $new[0] - 30, $new[1])
        EndIf
            $pos = $new
            Sleep(20)
    WEnd
EndFunc

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Posted

Autoit v3.2.8.1 :)

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Posted

i dont know why but i have to click it twice to get the real color, the first time it will give me the green dot i think and the 2nd time will give me the real color that i am looking for :S

Posted

I don't know why don't work :S

try on some other way ...

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Posted

well it works but i have to click it twice to work.

when u say it worked for you does it show u the color on the 1st click? or 2nd?

Posted

on 1st, because is before PixelGetColor puted GUISetState(@SW_HIDE,$a) ...

GUISetState(@SW_HIDE,$a)

$MouseColor_var = PixelGetColor($MouseCoord[0] - 28,$MouseCoord[1] + 2)

i don't know why not work for you :S

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Posted

I just noticed the title of this topic and I laughed my ass off. :)

Getting the mouse color?! Well, maybe you could ask the user with an inputbox..

Something like this:

$MouseColor = InputBox("Mouse Color","Hello there what is the color of your mouse? ")

I would have answered Grey. So $MouseColor = "Grey". ^_^

Posted (edited)

mm, anyone out there can try it?

i got the newest autoit, and i just copy pasted the code but same thing

^mine is black/blue!

Edited by d0n
Posted

This was quite obvious. It was not hiding the window fast enough, before it checked the color.

A little bit of Sleep() fixed that problem.

#include "GUIConstants.au3"
Global $pos = MouseGetPos(), $new_bobber = 0x00FF00
Local $a
$gui = GUICreate("")
GUISetState(@SW_HIDE)
while 1
Capture_Pixel()
WEnd
;Function to get Color/Coords of Mouse Position
Func GetUnderMouse ()
  ;gets mouse position
   $MouseCoord = MouseGetPos()
   GUISetState(@SW_HIDE,$a)
   Sleep(50)
  ;finds color under mouse
   $MouseColor_var = PixelGetColor($MouseCoord[0] - 28,$MouseCoord[1] + 2)
  ;converts it to hex
   $MouseColor_hex = Hex ($MouseColor_var, 6)
  ;displays info
   $color = "0x" & $MouseColor_hex
   MsgBox (0,"Mouse Info", "Mouse Position = " & $Mousecoord[0]& "," & $Mousecoord[1] & "  |  MouseColor = " & $color )
    GUISetstate(@SW_SHOW,$a)
EndFunc  ;==>GetUnderMouse

func capture_pixel()   
    $a = GUICreate("GUI", 5, 5, $pos[0] - 30, $pos[1], $WS_POPUP, $WS_EX_TOPMOST,$gui)
    GUISetBkColor($new_bobber, $a)
    GUISetState(@SW_SHOW)
    HotKeySet("z", "Getundermouse")
    While 1
        $new = MouseGetPos()
        If $new[0] <> $pos[0] Or $new[1] <> $pos[1] Then
            WinMove("GUI", "", $new[0] - 30, $new[1])
        EndIf
            $pos = $new
            Sleep(20)
    WEnd
EndFunc
Posted

got it working now, just wonder why did it work for him but not me, maybe my comp is a bit slow? lol

Thanks for all the help guys

Posted

Yes, very possible, your comp too slow hides gui and guick get pixel colors ;D

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

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
×
×
  • Create New...