Jump to content

get mouse color


d0n
 Share

Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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) :)

Link to comment
Share on other sites

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) :)

Link to comment
Share on other sites

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". ^_^

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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) :)

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